Loading...
Loading...
Enforces Behavior Driven Development. Use when: implementing new features, making significant code changes, adding functionality, refactoring behavior. Requires writing a Gherkin feature file first, getting user approval, then implementing.
npx skill4agent add vitalets/playwright-bdd playwright-bdd.feature.featureplaywright.config.tsplaywright.config.jsdefineBddConfig(...)stepsdefineBddConfig.featurenpx bddgen && npx playwright testdefineBddConfig()playwright.config.tstestDirnpx bddgen && npx playwright test .features-gen/@homepage/homepage.feature.spec.jsnpx bddgen exportWhen('I click {string} on {string}', ...)When('I click the "Add" button in the product list', ...)When I fill "Name" with "Alice"
And I fill "Email" with "alice@example.com"
And I fill "Role" with "Admin"When I fill the form with:
| Name | Alice |
| Email | alice@example.com |
| Role | Admin |Feature:@I should see {string} textfeatures/
├── fixtures.ts
├── @homepage/
│ ├── homepage.feature
│ └── steps.ts
├── @profile/
│ ├── profile.feature
│ └── steps.ts
└── shared-steps.tsfeatures/@homepage/steps.ts{ tags: '@homepage' }Feature: Shopping cart
Customers can collect products they intend to buy and review the current cart contents.
Scenario: Add item to cart
Given I am on a product page
And the cart is empty
When I add the product "banana" to the cart
Then the cart contains "banana"
And the cart badge shows 1import { Given, When, Then } from './fixtures';
Given('I am on a product page', async ({ page }) => {
await page.goto('/product');
});
When('I add the product {string} to the cart', async ({ page }, name: string) => {
await page.getByRole('button', { name: `Add ${name}` }).click();
});
Then('the cart badge should show {int}', async ({ page }, count: number) => {
await expect(page.locator('.cart-badge')).toHaveText(String(count));
});