playwright-bdd-configuration
Use when configuring Playwright BDD projects, setting up defineBddConfig(), configuring feature and step file paths, and integrating with Playwright config.
What this skill does
# Playwright BDD Configuration
Expert knowledge of Playwright BDD configuration, project setup, and integration with Playwright's testing framework for behavior-driven development.
## Overview
Playwright BDD enables running Gherkin-syntax BDD tests with Playwright Test. Configuration is done through the `playwright.config.ts` file using the `defineBddConfig()` function, which generates Playwright test files from your `.feature` files.
## Installation
```bash
# Install playwright-bdd
npm install -D playwright-bdd
# Or with specific Playwright version
npm install -D playwright-bdd @playwright/test
```
## Basic Configuration
### Minimal Setup
```typescript
// playwright.config.ts
import { defineConfig } from '@playwright/test';
import { defineBddConfig } from 'playwright-bdd';
const testDir = defineBddConfig({
features: 'features/**/*.feature',
steps: 'steps/**/*.ts',
});
export default defineConfig({
testDir,
});
```
### Generated Test Directory
The `defineBddConfig()` function returns a path to the generated test directory. By default, this is `.features-gen` in your project root:
```typescript
const testDir = defineBddConfig({
features: 'features/**/*.feature',
steps: 'steps/**/*.ts',
});
// testDir = '.features-gen/features'
```
### Custom Output Directory
```typescript
const testDir = defineBddConfig({
features: 'features/**/*.feature',
steps: 'steps/**/*.ts',
outputDir: '.generated-tests', // Custom output directory
});
```
## Configuration Options
### Feature Files
Configure where to find feature files:
```typescript
defineBddConfig({
// Single pattern
features: 'features/**/*.feature',
// Multiple patterns
features: [
'features/**/*.feature',
'specs/**/*.feature',
],
// Exclude patterns
features: {
include: 'features/**/*.feature',
exclude: 'features/**/skip-*.feature',
},
});
```
### Step Definitions
Configure step definition locations:
```typescript
defineBddConfig({
// Single pattern
steps: 'steps/**/*.ts',
// Multiple patterns
steps: [
'steps/**/*.ts',
'features/**/*.steps.ts',
],
// Mixed JavaScript and TypeScript
steps: [
'steps/**/*.ts',
'steps/**/*.js',
],
});
```
### Import Test Instance
When using custom fixtures, import the test instance:
```typescript
defineBddConfig({
features: 'features/**/*.feature',
steps: 'steps/**/*.ts',
importTestFrom: 'steps/fixtures.ts', // Path to your custom test instance
});
```
The fixtures file should export the test instance:
```typescript
// steps/fixtures.ts
import { test as base, createBdd } from 'playwright-bdd';
export const test = base.extend<{
todoPage: TodoPage;
}>({
todoPage: async ({ page }, use) => {
const todoPage = new TodoPage(page);
await use(todoPage);
},
});
export const { Given, When, Then } = createBdd(test);
```
## Advanced Configuration
### Multiple Feature Sets
Configure different feature sets for different test projects:
```typescript
import { defineConfig } from '@playwright/test';
import { defineBddConfig } from 'playwright-bdd';
const coreTestDir = defineBddConfig({
features: 'features/core/**/*.feature',
steps: 'steps/core/**/*.ts',
outputDir: '.features-gen/core',
});
const adminTestDir = defineBddConfig({
features: 'features/admin/**/*.feature',
steps: 'steps/admin/**/*.ts',
outputDir: '.features-gen/admin',
});
export default defineConfig({
projects: [
{
name: 'core',
testDir: coreTestDir,
},
{
name: 'admin',
testDir: adminTestDir,
},
],
});
```
### Language Configuration
Configure the Gherkin language:
```typescript
defineBddConfig({
features: 'features/**/*.feature',
steps: 'steps/**/*.ts',
language: 'de', // German keywords (Gegeben, Wenn, Dann)
});
```
Supported languages follow the Gherkin specification:
- `en` (English - default)
- `de` (German)
- `fr` (French)
- `es` (Spanish)
- `ru` (Russian)
- And many more...
### Quote Style
Configure quote style in generated test files:
```typescript
defineBddConfig({
features: 'features/**/*.feature',
steps: 'steps/**/*.ts',
quotes: 'single', // 'single' | 'double' | 'backtick'
});
```
### Verbose Mode
Enable verbose output during generation:
```typescript
defineBddConfig({
features: 'features/**/*.feature',
steps: 'steps/**/*.ts',
verbose: true,
});
```
## Integration with Playwright Config
### Full Configuration Example
```typescript
// playwright.config.ts
import { defineConfig, devices } from '@playwright/test';
import { defineBddConfig } from 'playwright-bdd';
const testDir = defineBddConfig({
features: 'features/**/*.feature',
steps: 'steps/**/*.ts',
importTestFrom: 'steps/fixtures.ts',
});
export default defineConfig({
testDir,
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 1 : undefined,
reporter: [
['html'],
['json', { outputFile: 'test-results/results.json' }],
],
use: {
baseURL: 'http://localhost:3000',
trace: 'on-first-retry',
screenshot: 'only-on-failure',
},
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},
{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
},
{
name: 'webkit',
use: { ...devices['Desktop Safari'] },
},
],
webServer: {
command: 'npm run start',
url: 'http://localhost:3000',
reuseExistingServer: !process.env.CI,
},
});
```
### Environment-Specific Configuration
```typescript
import { defineConfig } from '@playwright/test';
import { defineBddConfig } from 'playwright-bdd';
const isCI = !!process.env.CI;
const testDir = defineBddConfig({
features: 'features/**/*.feature',
steps: 'steps/**/*.ts',
verbose: !isCI,
});
export default defineConfig({
testDir,
timeout: isCI ? 60000 : 30000,
retries: isCI ? 2 : 0,
workers: isCI ? 4 : undefined,
});
```
## Running Tests
### Generate and Run
```bash
# Generate test files from features
npx bddgen
# Run Playwright tests
npx playwright test
# Or combine both
npx bddgen && npx playwright test
```
### Watch Mode
For development, regenerate on file changes:
```bash
# Watch feature and step files
npx bddgen --watch
# In another terminal, run tests
npx playwright test --watch
```
### Export Step Definitions
Export all step definitions for documentation:
```bash
npx bddgen export
```
## Directory Structure
Recommended project structure:
```
project/
├── playwright.config.ts
├── features/
│ ├── auth/
│ │ ├── login.feature
│ │ └── logout.feature
│ └── products/
│ └── catalog.feature
├── steps/
│ ├── auth/
│ │ ├── login.steps.ts
│ │ └── logout.steps.ts
│ ├── products/
│ │ └── catalog.steps.ts
│ └── fixtures.ts
└── .features-gen/ # Generated (gitignore this)
└── features/
├── auth/
│ ├── login.feature.spec.js
│ └── logout.feature.spec.js
└── products/
└── catalog.feature.spec.js
```
### Gitignore Generated Files
Add to `.gitignore`:
```
# Playwright BDD generated files
.features-gen/
```
## Common Configuration Patterns
### Monorepo Setup
```typescript
// packages/e2e/playwright.config.ts
import { defineConfig } from '@playwright/test';
import { defineBddConfig } from 'playwright-bdd';
const testDir = defineBddConfig({
features: 'features/**/*.feature',
steps: 'steps/**/*.ts',
importTestFrom: 'steps/fixtures.ts',
});
export default defineConfig({
testDir,
use: {
baseURL: process.env.BASE_URL || 'http://localhost:3000',
},
});
```
### Component Testing
```typescript
import { defineConfig } from '@playwright/test';
import { defineBddConfig } from 'playwright-bdd';
const testDir = defineBddConfig({
features: 'features/components/**/*.feature',
steps: 'steps/components/**/*.ts',
});
export default defineConfig({
testDir,
use: {
ctPort: 3100,
},
});
```
### API TRelated in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.