playwright-bdd-gherkin-syntax
Use when writing Gherkin feature files, using Scenario Outline with Examples, applying tags for test organization, and leveraging Background sections for shared setup.
What this skill does
# Playwright BDD Gherkin Syntax
Expert knowledge of Gherkin syntax for writing feature files in Playwright BDD, including scenarios, outlines, backgrounds, tags, and internationalization.
## Overview
Gherkin is a domain-specific language for describing software behavior in plain text. Playwright BDD uses Gherkin feature files (`.feature`) that are transformed into Playwright test files via `bddgen`.
## Feature File Structure
### Basic Structure
```gherkin
Feature: User Authentication
As a user
I want to be able to log in
So that I can access my account
Background:
Given I am on the login page
Scenario: Successful login
When I enter valid credentials
And I click the login button
Then I should see the dashboard
Scenario: Failed login
When I enter invalid credentials
And I click the login button
Then I should see an error message
```
### Feature Declaration
```gherkin
Feature: Short descriptive title
Optional description spanning
multiple lines explaining the
feature's purpose and context.
```
## Keywords
### Given - Preconditions
Describes the initial context or state:
```gherkin
Given I am logged in as "admin"
Given the shopping cart is empty
Given the following users exist:
| name | email |
| Alice | [email protected] |
| Bob | [email protected] |
```
### When - Actions
Describes the action or event:
```gherkin
When I click the "Submit" button
When I fill in "email" with "[email protected]"
When I select "Express" from the shipping options
When 24 hours have passed
```
### Then - Outcomes
Describes the expected outcome:
```gherkin
Then I should see "Welcome back!"
Then the cart should contain 3 items
Then I should be redirected to the dashboard
Then an email should be sent to "[email protected]"
```
### And / But - Continuation
Continues the previous Given/When/Then:
```gherkin
Given I am logged in
And I have items in my cart
But I have not entered a shipping address
When I click checkout
And I enter my payment details
Then I should see the confirmation page
And I should receive an order email
But I should not be charged twice
```
## Scenario Types
### Basic Scenario
```gherkin
Scenario: Add item to cart
Given I am on the product page
When I click "Add to Cart"
Then the cart count should be 1
```
### Scenario Outline (Data-Driven)
Run the same scenario with different data:
```gherkin
Scenario Outline: Login with different roles
Given I am on the login page
When I login as "<role>"
Then I should see the "<dashboard>" dashboard
Examples:
| role | dashboard |
| admin | Admin |
| user | User |
| manager | Manager |
```
Multiple example tables:
```gherkin
Scenario Outline: Product pricing
Given I am viewing product "<product>"
Then the price should be "<price>"
And the discount should be "<discount>"
Examples: Regular Products
| product | price | discount |
| Laptop | $999 | 0% |
| Mouse | $29 | 0% |
Examples: Sale Products
| product | price | discount |
| Keyboard | $79 | 20% |
| Headphones | $149 | 15% |
```
### Background (Shared Setup)
Runs before each scenario in the feature:
```gherkin
Feature: Shopping Cart
Background:
Given I am logged in
And I have an empty cart
Scenario: Add single item
When I add "Product A" to cart
Then the cart should have 1 item
Scenario: Add multiple items
When I add "Product A" to cart
And I add "Product B" to cart
Then the cart should have 2 items
```
### Rule (Grouping Related Scenarios)
Group scenarios under business rules:
```gherkin
Feature: Discount System
Rule: Bulk discounts apply to orders over 10 items
Scenario: Order with 10 items gets no discount
Given I have 10 items in my cart
Then I should see no discount applied
Scenario: Order with 11 items gets bulk discount
Given I have 11 items in my cart
Then I should see a 10% discount applied
Rule: VIP members get additional discounts
Scenario: VIP member gets member discount
Given I am a VIP member
When I view my cart
Then I should see a 5% member discount
```
## Tags
### Basic Tags
```gherkin
@smoke
Feature: User Authentication
@critical
Scenario: Successful login
Given I am on the login page
When I enter valid credentials
Then I should see the dashboard
@regression @slow
Scenario: Password recovery
Given I am on the forgot password page
When I request a password reset
Then I should receive an email
```
### Special Playwright BDD Tags
```gherkin
# Skip this scenario
@skip
Scenario: Feature not ready
Given this is skipped
# Run only this scenario (like test.only)
@only
Scenario: Debug this specific test
Given I need to focus on this
# Mark as known failure
@fail
Scenario: Known bug #123
Given this is expected to fail
# Mark as flaky but continue
@fixme
Scenario: Intermittently failing test
Given this sometimes fails
```
### Tag Expressions
Filter tests by tags when running:
```bash
# Run only smoke tests
npx playwright test --grep @smoke
# Run critical tests
npx playwright test --grep @critical
# Run everything except slow tests
npx playwright test --grep-invert @slow
# Combine tags (AND)
npx playwright test --grep "@smoke.*@critical"
```
### Tag Inheritance
Tags on Feature apply to all scenarios:
```gherkin
@authentication @web
Feature: User Login
@happy-path
Scenario: Successful login
# Has tags: @authentication, @web, @happy-path
...
@error-handling
Scenario: Invalid password
# Has tags: @authentication, @web, @error-handling
...
```
## Data Tables
### Simple Lists
```gherkin
Scenario: Add multiple items
When I add the following items:
| Milk |
| Bread |
| Butter |
```
### Key-Value Tables
```gherkin
Scenario: Fill registration form
When I fill in the form with:
| First Name | John |
| Last Name | Doe |
| Email | [email protected] |
| Password | secret123 |
```
### Tables with Headers
```gherkin
Scenario: Create multiple users
Given the following users exist:
| username | email | role |
| alice | [email protected] | admin |
| bob | [email protected] | user |
| carol | [email protected] | user |
```
### Complex Tables
```gherkin
Scenario: Order with multiple products
When I create an order with:
| product | quantity | price | discount |
| Laptop | 1 | 999 | 0% |
| Mouse | 2 | 29 | 10% |
| Keyboard | 1 | 79 | 5% |
Then the order total should be $1123.55
```
## Doc Strings
### Plain Text
```gherkin
Scenario: Submit feedback
When I enter the following feedback:
"""
Great product! Would recommend.
Fast shipping and excellent quality.
"""
And I click submit
Then I should see "Thank you for your feedback"
```
### JSON Content
```gherkin
Scenario: Create product via API
When I send a POST request with:
"""json
{
"name": "New Product",
"price": 49.99,
"category": "electronics",
"tags": ["new", "featured"]
}
"""
Then the response status should be 201
```
### Code Blocks
```gherkin
Scenario: Execute script
When I run the following script:
"""javascript
const result = await page.evaluate(() => {
return document.title;
});
console.log(result);
"""
```
## Internationalization (i18n)
### Language Header
```gherkin
# language: de
Funktionalität: Benutzeranmeldung
Grundlage:
Angenommen ich bin auf der Anmeldeseite
Szenario: Erfolgreiche Anmeldung
Wenn ich gültige Anmeldedaten eingebe
Dann sollte ich das Dashboard sehen
```
### Supported Languages
Common languages and their keywords:
**German (de):**
```gherkin
# language: de
Funktionalität: Feature title
SzenarioRelated in Writing & Docs
jax-development
IncludedUse this skill when the user is writing, debugging, profiling, refactoring, reviewing, benchmarking, parallelising, exporting, or explaining JAX code, or when they mention JAX, jax.numpy, jit, grad, value_and_grad, vmap, scan, lax, random keys, pytrees, jax.Array, sharding, Mesh, PartitionSpec, NamedSharding, pmap, shard_map, Pallas, XLA, StableHLO, checkify, profiler, or the JAX repo. It helps turn NumPy or PyTorch-style code into pure functional JAX, fix tracer/control-flow/shape/PRNG bugs, remove recompiles and host-device syncs, choose transforms and sharding strategies, inspect jaxpr/lowering/IR, and benchmark compiled code correctly.
nature-article-writer
IncludedDrafts, rewrites, diagnostically critiques, and style-calibrates primary research manuscripts for Nature and Nature Portfolio journals. Use when the user wants a Nature-style title, summary paragraph or abstract, introduction, results, discussion, methods, figure legends, presubmission enquiry, cover letter, reviewer response, or when a scientific draft sounds generic, jargon-heavy, structurally weak, or AI-ish and needs precise, broad-reader-friendly prose without inventing data, analyses, or references. Best for primary research articles and letters rather than reviews or press releases unless explicitly adapting one.
deckrd
IncludedDocument-driven framework that derives requirements, specifications, implementation plans, and executable tasks from goals through structured AI dialogue. Use when user says "write requirements", "create spec", "plan implementation", "derive tasks", "structure this feature", "break down into tasks", or "document this module". Also use for reverse engineering existing code into docs (/deckrd rev). Do NOT use for direct code writing — use /deckrd-coder after tasks are generated. Do NOT use when the user only wants to run or fix existing code without planning.
clinical-decision-support
IncludedGenerate professional clinical decision support (CDS) documents for pharmaceutical and clinical research settings, including patient cohort analyses (biomarker-stratified with outcomes) and treatment recommendation reports (evidence-based guidelines with decision algorithms). Supports GRADE evidence grading, statistical analysis (hazard ratios, survival curves, waterfall plots), biomarker integration, and regulatory compliance. Outputs publication-ready LaTeX/PDF format optimized for drug development, clinical research, and evidence synthesis.
handling-sf-data
IncludedSalesforce data operations with 130-point scoring. Use this skill to create, update, delete, bulk import/export, generate test data, and clean up org records using sf CLI and anonymous Apex. TRIGGER when: user creates test data, performs bulk import/export, uses sf data CLI commands, needs data factory patterns for Apex tests, or needs to seed/clean records in a Salesforce org. DO NOT TRIGGER when: SOQL query writing only (use querying-soql), Apex test execution (use running-apex-tests), or metadata deployment (use deploying-metadata).
accelint-ac-to-playwright
IncludedConvert and validate acceptance criteria for Playwright test automation. Use when user asks to (1) review/evaluate/check if AC are ready for automation, (2) assess if AC can be converted as-is, (3) validate AC quality for Playwright, (4) turn AC into tests, (5) generate tests from acceptance criteria, (6) convert .md bullets or .feature Gherkin files to Playwright specs, (7) create test automation from requirements. Handles both bullet-style markdown and Gherkin syntax with JSON test plan generation and validation.