en un clic
playwright-bdd
// Creates and maintains Gherkin feature files and step definitions for Behavior-Driven Development (BDD) with Playwright. Use when creating or editing .feature files and writing BDD steps for a playwright-bdd project.
// Creates and maintains Gherkin feature files and step definitions for Behavior-Driven Development (BDD) with Playwright. Use when creating or editing .feature files and writing BDD steps for a playwright-bdd project.
| name | playwright-bdd |
| description | Creates and maintains Gherkin feature files and step definitions for Behavior-Driven Development (BDD) with Playwright. Use when creating or editing .feature files and writing BDD steps for a playwright-bdd project. |
Workflow for creating and maintaining playwright-bdd feature files and step definitions.
Run the following to see all available commands and options:
npx bddgen --help
Search playwright.config.ts (or playwright.config.js) for defineBddConfig(...) calls. This reveals the actual directory where .feature files live and steps (glob patterns pointing to step definition files).
defineBddConfig calls exist, guess the most suitable one based on the feature description (e.g. match directory names or tags to the described feature area). Only ask the user to clarify if it is genuinely ambiguous.Run npx bddgen export to list all registered step definitions:
npx bddgen export
# If the config file is not at the project root:
npx bddgen export --config <path-to-config>
The output lists steps in the format:
* Given <pattern>
* When <pattern>
* Then <pattern>
Parse these lines and use the patterns as-is when writing feature steps. Do NOT invent new step text if a matching pattern already exists.
Place the file inside features directory discovered in step 2. Prefer existing step patterns; flag any behaviors that cannot be covered and proceed to step 5.
Practical tips:
Scenario Outline with an Examples: table instead of duplicating scenarios.Given steps, extract those into a Background: block.@smoke, @regression, @jira:123) to support filtering via npx bddgen --tags "@smoke and not @slow". Match existing tag conventions visible in project .feature files.{string} values must be written in "double quotes", {int} is a bare integer, {float} is a bare decimal. Never modify the keyword pattern text itself.Given the following payload:
"""
{ "key": "value" }
"""
Given the following users:
| name | role |
| Alice | admin |
When a behavior cannot be covered by existing steps:
steps glob from defineBddConfig and read the actual step files.Given('pattern', async ({ page, ... }, arg) => { ... })Given('pattern', async function(arg) { this.page... })@Given('pattern') async methodName(arg) { ... } inside a POM classsteps/auth.steps.ts if that file exists).For deeper detail on any topic — configuration, step styles, fixtures, hooks, reporters — fetch the official documentation: https://vitalets.github.io/playwright-bdd/#/