# Write your first BDD test Follow the steps below to create and run your first BDD test with Playwright-BDD. ?> This guide uses JavaScript for simplicity, but you can use TypeScript as well. ### Step 1: Create configuration file Create the following `playwright.config.js` in the project root: ```js import { defineConfig } from '@playwright/test'; import { defineBddConfig } from 'playwright-bdd'; const testDir = defineBddConfig({ features: 'sample.feature', steps: 'steps.js', }); export default defineConfig({ testDir, reporter: 'html', }); ``` ### Step 2: Create feature file Create a feature file named `sample.feature`: ```gherkin Feature: Playwright site Scenario: Check get started link Given I am on home page When I click link "Get started" Then I see in title "Installation" ``` ### Step 3: Implement steps Implement the steps in `steps.js`: ```ts import { expect } from '@playwright/test'; import { createBdd } from 'playwright-bdd'; const { Given, When, Then } = createBdd(); Given('I am on home page', async ({ page }) => { await page.goto('https://playwright.dev'); }); When('I click link {string}', async ({ page }, name) => { await page.getByRole('link', { name }).click(); }); Then('I see in title {string}', async ({ page }, keyword) => { await expect(page).toHaveTitle(new RegExp(keyword)); }); ``` > There are alternative ways of defining steps: [Decorators](writing-steps/decorators.md) and [Cucumber-style syntax](writing-steps/cucumber-style.md). ### Step 4: Run tests Generate and run the tests: ``` npx bddgen && npx playwright test ``` Command for **Yarn** ``` yarn bddgen && yarn playwright test ``` Command for **pnpm**: ``` pnpm bddgen && pnpm playwright test ``` Output: ``` Running 1 test using 1 worker 1 passed (2.0s) To open the last HTML report, run: npx playwright show-report ``` HTML report: ![Playwright HTML report](./_media/playwright-report.png ':size=70%') ### Step 5: Check the generated tests (optional) Check out the `.features-gen` directory to see what the generated tests look like. You will see the generated file `sample.feature.spec.js`: ```js // Generated from: sample.feature import { test } from 'playwright-bdd'; test.describe('Playwright site', () => { test('Check get started link', async ({ Given, When, Then }) => { await Given('I am on home page'); await When('I click link "Get started"'); await Then('I see in title "Installation"'); }); }); ``` ?> Here is a fully working Playwright-BDD example project: [playwright-bdd-example](https://github.com/vitalets/playwright-bdd-example). !> Don't forget to [ignore generated files](guides/ignore-generated-files.md).