BDD Generator
Use this skill to translate business requirements into executable BDD scenarios.
Use When
- The user asks for BDD, Gherkin, feature files, or scenario-based tests
- You need business-readable acceptance tests tied to Playwright execution
Setup
pnpm add -D @playwright/test playwright-bdd
npx playwright install
// playwright.config.ts
import { defineConfig } from '@playwright/test';
import { defineBddConfig } from 'playwright-bdd';
const testDir = defineBddConfig({
features: 'features/**/*.feature',
steps: 'features/steps/**/*.ts',
});
export default defineConfig({ testDir });
Workflow
- Write one feature and one scenario first (RED).
- Run
bddgento generate missing step stubs. - Implement only the first failing step.
- Re-run tests; repeat until scenario passes.
- Add next scenario only after green.
Gherkin Best Practices
- Use business language, not technical implementation details.
Givensets context,Whendescribes action,Thenverifies user-visible outcome.- Use
Backgroundfor repeated context. - Use
Scenario Outlinefor data variants.
Output
*.featurefile with clear business behavior- Step definitions in
features/steps/*.ts - Command list to run and debug tests
References
- Cucumber Gherkin reference: https://cucumber.io/docs/gherkin/reference
- playwright-bdd: https://github.com/vitalets/playwright-bdd