| name | bdd-playwright-pom |
| description | Create or refactor professional tests using the repo's existing test stack, using Cucumber and Playwright with Page Object Models when browser BDD coverage is appropriate and supported by the project. |
BDD Playwright POM Skill
Purpose
This skill creates and reworks tests in a professional, easy-to-understand format using the testing tools that fit the scenario and the repository.
It supports both repo-native test workflows such as Vitest, Supertest, and view/integration tests, and browser BDD workflows using Cucumber, Playwright, and Page Object Models (POMs) when those tools are already part of the project or the user explicitly wants them added.
This skill must support both:
- Creating new tests from scratch.
- Refactoring existing tests to align with project conventions.
When To Use
Use this skill when the user asks to:
- Create a new test for UI behavior.
- Add or update Cucumber feature scenarios.
- Build or update step definitions.
- Create or refine Vitest, Supertest, view, or integration tests.
- Convert raw locator tests to POM-based tests.
- Improve directory structure or consistency of test files.
When Not To Use
Do not use this skill for:
- Pure API tests with no page interaction.
- Non-testing infrastructure tasks unrelated to test authoring/refactoring.
- Runtime debugging that does not require test changes.
Required Workflow
Always follow this order unless the user explicitly asks otherwise:
- Inspect the existing test stack, test directories, and package scripts before choosing a test approach.
- Use the project's current framework for the touched area unless the user explicitly asks for a different tool and the repo supports it.
- For service, controller, route, mapper, view, and Express integration behavior, prefer the repo's existing unit/integration tooling such as Vitest and Supertest.
- For browser-driven UI behavior that genuinely benefits from BDD flows, use Cucumber plus Playwright only when those tools already exist in the repo or the user explicitly wants them introduced.
- If using Cucumber and Playwright, create or update the feature file first, then matching step definitions, then the POM methods used by the steps.
- Run the relevant narrow validation command and report results.
Tool Selection Rules
Choose the test approach that matches the behavior under test:
- Use Vitest for unit tests and most existing view/controller/service coverage when the repo already uses Vitest.
- Use Supertest for HTTP route and app integration behavior in Express apps when the current repo already follows that pattern.
- Use Cucumber plus Playwright for end-to-end browser behavior only when the project already contains that stack or the user explicitly requests that workflow.
- Do not introduce a second test framework by default when the existing repo already has a clear local convention.
- If the scenario can be covered cleanly without a browser, avoid escalating it to browser automation.
Cucumber Feature Standards
Feature files must:
- Use clear business-readable language.
- Express meaningful behavior in Given/When/Then form.
- Avoid vague or circular scenarios (for example, starting and ending on the same page without a real action).
- Use tags when step hooks need scoping (for example, @create-user, @go-home).
- Keep scenarios focused on one behavior outcome.
Step Definition Standards
Step files must:
- Be paired to feature behavior and stay easy to read.
- Use tag-scoped hooks where appropriate so setup does not leak across features.
- Set Cucumber timeout to a reliable value for browser startup.
- Use deterministic test setup and unique test data where needed.
- Call POM methods instead of raw page locators whenever a suitable POM exists.
These standards apply only when the chosen test approach is Cucumber-based.
POM Requirement
Browser UI tests should use POMs where available and appropriate.
Rules:
- If a relevant POM already exists, use it.
- If the existing POM is missing required methods/locators, extend that POM.
- Do not duplicate locator logic in step files or test specs when a POM can own it.
- Do not force POM creation for non-browser tests such as Vitest view, controller, or route tests.
Missing POM Policy (Ask First)
If browser automation is the right approach and no relevant POM exists for a page needed by the test:
- Pause and ask the user for permission before creating a new POM file.
- Explain which page(s) require a POM and why.
- Only create the new POM after user approval.
Directory Layout Rules
Keep test assets organized according to the repository's existing structure instead of introducing a new layout by default.
Rules:
- Reuse the current top-level test directory already present in the repo, for example
test/ in Vitest-based projects or tests/ in projects that already use that layout.
- Mirror the source concern when the repo already does that, for example controller tests under the controller test area and route tests under the route test area.
- Only use
features, steps, pages, or other browser-BDD folders when the project already contains them or when the user explicitly approves introducing them.
- Do not create parallel directory trees such as both
test/ and tests/ unless the repo already intentionally uses both.
Naming conventions:
- Follow the repo's existing naming convention first.
- For Cucumber assets, feature files should use clear behavior-based names and step files should map clearly to feature intent.
- For POM files, use PascalCase and a
Page suffix when that convention is already established.
Locator And Assertion Quality
Use stable selectors and precise assertions:
- Prefer getByRole, then getByLabel, then getByTestId.
- Avoid XPath unless no robust semantic locator exists.
- Use row-scoped or container-scoped assertions to avoid strict mode collisions.
- Use strict URL expectations that avoid false positives.
These locator rules apply to browser automation, not server-rendered HTML assertions in unit or integration tests.
Environment And Execution
Respect project environment controls:
- Use the environment variable names that already exist in the repo instead of assuming
BASE_URL or HEADED.
- Read package scripts, test config, and example env files before assuming execution flags or browser launch settings.
- Preserve existing timeout, launch, and test-runner conventions unless the user asks to change them.
- If browser tooling is being introduced, define its configuration explicitly instead of relying on undocumented environment assumptions.
Refactoring Existing Tests
When reworking current tests:
- Preserve behavior and assertions first.
- Keep the existing framework unless there is a clear reason to migrate the test.
- Move duplicated locator logic into POM methods only for browser-based tests.
- Keep changes minimal and focused.
- Re-run impacted tests and report pass/fail outcomes.
Completion Checklist
Before finishing, verify:
- The chosen test tool matches the scenario and the repo's existing stack.
- The repo's current test layout and naming conventions were preserved.
- Feature-first flow is respected when using Cucumber.
- Steps map to feature language and remain readable when using Cucumber.
- POM usage is applied where appropriate for browser tests.
- Missing-POM ask-first policy was followed when relevant.
- Files are in clean, expected directories.
- Relevant tests were executed and results reported.