Give the agent the existing Playwright fixture helpers, not a from-scratch test file
The agent adds settings.spec.ts with its own page.goto('/login'), a hard-coded email, and a full fill of the sign-in form. The repo already has a test.extend fixture that authenticates, a gotoSettings() helper, and a see
The agent adds settings.spec.ts with its own page.goto('/login'), a hard-coded email, and a full fill of the sign-in form. The repo already has a test.extend fixture that authenticates, a gotoSettings() helper, and a seed that creates a user. The new spec is slower, flakes on the login page, and bypasses the test account the CI secret is meant to use.
Iβve started treating a from-scratch Playwright file that ignores the fixtures as incomplete, even if the assertion at the end is right. The helper is part of the test contract.
Why the blank spec shows up
Public Playwright examples start from page.goto. The model can write that without reading tests/fixtures. A custom fixture file is local, named for your app, and easy to skip. The generated test then invents selectors for the login form that the app is about to change, and it may commit a sample password.
You also lose shared setup: feature flags, cookie consent, the locale, the viewport the team standardized. Those live in the fixture for a reason.
A simple Playwright policy
-
New tests import the existing
testandexpectfrom the fixture module, not from@playwright/testdirectly, if that is how the repo does it - Reuse auth, seed, and navigation helpers
- Do not hard-code credentials in a spec
- One new helper is fine when the flow is genuinely new; put it next to the others, not inline in the spec
If the repo uses component tests or a different runner for this surface, say so. Do not let the agent add a Playwright spec that duplicates a Cypress or Testing Library flow the team already runs.
What to put in the prompt
Use the existing Playwright fixtures in tests/e2e/fixtures.ts (authenticatedPage, gotoSettings, seedUser).
Do not write a new login flow or hard-code credentials.
Import test/expect the same way the neighboring specs do.
Add a helper next to the others if this flow will be reused; do not inline a one-off goto+fill for setup.
Paste one neighboring spec and the fixture types. In review, search the diff for page.goto('/login'), fill('#password'), and a raw import from @playwright/test when the repo wraps it.
Reject / send back
Reject
- A new spec that logs in by filling the UI
- Credentials or tokens committed in the test
- A second Playwright config invented for one file
- Selectors copied from a tutorial instead of the appβs existing
getByRolehelpers
Accept
- A spec that starts from the shared fixture and asserts one behavior
- A new helper in the fixture module, used by the new spec
- A unit or component test instead, when that is the repoβs first layer for the change
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.