playwright-bdd

Playwright-BDD

Run BDD tests with Playwright runner
[![lint](https://github.com/vitalets/playwright-bdd/actions/workflows/lint.yaml/badge.svg)](https://github.com/vitalets/playwright-bdd/actions/workflows/lint.yaml) [![test](https://github.com/vitalets/playwright-bdd/actions/workflows/test.yaml/badge.svg)](https://github.com/vitalets/playwright-bdd/actions/workflows/test.yaml) [![npm version](https://img.shields.io/npm/v/playwright-bdd)](https://www.npmjs.com/package/playwright-bdd) [![npm downloads](https://img.shields.io/npm/dw/playwright-bdd)](https://www.npmjs.com/package/playwright-bdd) [![license](https://img.shields.io/npm/l/playwright-bdd)](https://github.com/vitalets/playwright-bdd/blob/main/LICENSE)

🚀 Getting Started  📚 Documentation  ▶️ Example  📝 Changelog

## BDD in the Era of AI [Behavior-Driven Development (BDD)](https://cucumber.io/docs/bdd/) describes product requirements as `Given / When / Then` scenarios written in plain-text files. In the AI era, these scenarios become valuable artifacts for agents because they are both: * ✅ **Readable**: You can easily draft and refine scenarios with an agent to clearly define the behavior. * ✅ **Executable**: The same scenarios can be executed as automated tests to verify the implementation. Unlike plain Markdown specs, BDD does not just describe a feature; it makes the spec live and keeps it aligned with the codebase. Watch the YouTube [1-minute workflow overview](https://www.youtube.com/watch?v=0bOdxvK1Tmk) or read the [blog post](https://vitalets.github.io/posts/bdd-agentic-workflow/) for more details on agentic BDD workflow. Install the [playwright-bdd skill](https://vitalets.github.io/playwright-bdd/#/getting-started/agent-skill) to get started. ```diff Feature: Agentic development Scenario: Implement a new feature Given business requirements When a human defines the behavior as BDD steps - Then the human implements the feature and verifies it with tests + Then the agent implements the feature and verifies it with tests ``` The ultimate goal: **review only feature files** and let automations check code quality and scenario compliance. ## Why Playwright Runner? [Playwright](https://playwright.dev/) provides both browser automation APIs and a powerful test runner. Playwright-BDD converts `.feature` files into native Playwright tests, so you can use all Playwright runner capabilities: - Automatic browser setup and cleanup - Auto-waiting for page elements - Auto-capture of screenshots, videos, and traces - Parallel execution and sharding - Built-in reports and visual comparison testing - Playwright fixtures - [...and more](https://playwright.dev/docs/library#key-differences) ## How It Works ## Extras Playwright-BDD has several unique features: - 🔥 Advanced tagging [by path](https://vitalets.github.io/playwright-bdd/#/writing-features/tags-from-path) and [special tags](https://vitalets.github.io/playwright-bdd/#/writing-features/special-tags) - 🎩 [Step decorators](https://vitalets.github.io/playwright-bdd/#/writing-steps/decorators) for class methods - 🎯 [Scoped step definitions](https://vitalets.github.io/playwright-bdd/#/writing-steps/scoped) - ✨ [Exporting steps](https://vitalets.github.io/playwright-bdd/#/writing-features/chatgpt) for AI - ♻️ [Re-usable step functions](https://vitalets.github.io/playwright-bdd/#/writing-steps/reusing-step-fn) ## Documentation Check out the [documentation website](https://vitalets.github.io/playwright-bdd/#/). ## Demos - Check out [`examples`](/examples) folder - Clone the fully working repo: [playwright-bdd-example](https://github.com/vitalets/playwright-bdd-example) ## Playwright Versions Support `playwright-bdd` supports the latest stable Playwright release and the **10 previous releases**. ## Changelog Check out the latest changes in the [CHANGELOG.md](https://github.com/vitalets/playwright-bdd/blob/main/CHANGELOG.md). ## 💖 Sponsors Great thanks to the **amazing people and companies** already supporting Playwright-BDD! Your help keeps the project alive and growing:

Currents

TestMu AI

User avatar: Arturs LeščinskisUser avatar: User avatar: Francesco Borzì

If you find Playwright-BDD useful in your personal or work projects, consider [becoming a sponsor](https://github.com/sponsors/vitalets). Even small contributions help me dedicate more time to maintenance, new features, and community support. ## Feedback & Community Feel free to report a bug, propose a feature or share your experience: * [GitHub issues](https://github.com/vitalets/playwright-bdd/issues) * [Playwright-BDD Discord](https://discord.gg/5rwa7TAGUr) ## Contributing Your contributions are welcome! Please review [CONTRIBUTING.md](https://github.com/vitalets/playwright-bdd/blob/main/.github/CONTRIBUTING.md) for the details. ## My Other Playwright tools * [playwright-timeline-reporter](https://github.com/vitalets/playwright-timeline-reporter) - Interactive timeline report for Playwright test runs. * [@global-cache/playwright](https://github.com/vitalets/global-cache) - Key-value cache for sharing data between parallel workers. * [request-mocking-protocol](https://github.com/vitalets/request-mocking-protocol) - Mock server-side API calls in Playwright. * [playwright-network-cache](https://github.com/vitalets/playwright-network-cache) - Speed up Playwright tests by caching network requests on the filesystem. * [playwright-magic-steps](https://github.com/vitalets/playwright-magic-steps) - Auto-transform JavaScript comments into Playwright steps. ## License This project is licensed under the [MIT License](https://github.com/vitalets/playwright-bdd/blob/main/LICENSE), allowing you to use, modify, and share the code freely, even for commercial purposes. Enjoy building something amazing! 🎉