writing-end-to-end-tests
Write and run Playwright end-to-end tests in `e2e/` for the web vault, browser extension and desktop app. Use only when already working in `e2e/`, not to…
by bitwarden★ 14,360 GitHub stars
Install writing-end-to-end-tests in Claude Code & Claude Desktop
Sign up to install this skill
Create a free account to reveal the install command and save the skill to your library.
- Reveal the one-line install command
- Save skills to your synced library
- Get notified when skills update
About this skill
Layout
- Tests:
e2e/tests/<web|browser|desktop|shared>/**/*.e2e.ts.sharedholds flows spanning clients. - Fixtures:
e2e/src/browser/fixtures.ts(extension in a persistent Chromium context),e2e/src/desktop/fixtures.ts(Electron). Web tests use Playwright's ownpage. - Page helpers:
e2e/src/<client>/*.tsande2e/src/*.ts(e.g.LoginPage,LockScreen). Reuse one before writing a new one. - Client internals (feature flags, lock state, fake biometrics):
automationDriver(page, "<capability>")ine2e/src/automation-driver.ts, backed bylibs/automation-driver. Prefer it over poking app state throughpage.evaluate. - Setup (credentials, builds, local server):
e2e/README.md.
Locators
- Prefer a trivial role locator: one
getByRolecall that picks out the element on its own, with nonameor anametaken from data the test seeded, e.g.page.getByRole("dialog")orpage.getByRole("link", { name: itemName }). Anidwritten in the template (page.locator("#...")) works too, but not a generated one likebit-form-field-3, which changes with render order. - Fall back to a test id when no trivial role locator works: it needs chaining or nesting (
.filter(), scoping into a row,.nth()), the role matches more than one element, or only localized copy tells the elements apart. Add adata-testidto the component template in the same change and locate it withpage.getByTestId("..."). Name it<component>-<element>, e.g.lock-biometric-unlock-button. - For new locators: no CSS classes, DOM structure or
formcontrolname. Existing helpers predate this rule; leave them alone unless you are already changing that locator. - Don't match localized copy: no
getByTextorgetByLabel, and no rolenametaken from translated text, including button, checkbox and menu labels. Matching data the test seeded itself, such as a folder name, is fine. - Reach UI owned by another team (see
.github/CODEOWNERS) through a trivial role locator, or that team's page helper (e.g.LoginPage) if one exists. Don't add test ids to their templates or depend on their DOM structure. If neither works, stop and ask rather than break one of these rules. - Keep each test id and
#idin a named constant at the top of the helper or test.
Writing tests
- Assert with web-first
expect(locator)(toBeVisible,toBeEnabled,toHaveURL). NowaitForTimeoutto wait for state; wait for the state itself. - Each test logs in fresh. Profiles are wiped per launch, so don't rely on state from an earlier test.
- Long cross-client flows: raise
test.setTimeoutinstead of the global timeout. - Put repeated steps (open settings, set a PIN) in a page helper, not in the test.
Run them
Always run the tests you wrote or touched, and report the result. A test not observed passing is not done.
npm run test:e2e:web
npm run test:e2e:browser # builds the extension first
npm run test:e2e:desktop # builds desktop first
npm run test:e2e:shared
# Only the web suite is headless. On Linux without a display, wrap the
# other three: xvfb-run -a npm run test:e2e:browser
- One test:
cd e2e && npx playwright test -c playwright.<suite>.config.ts <path> -g "<title>". Rebuild the client first if its code changed. - Bug fix: run the test without the fix too. It must fail there.
- On failure, read
e2e/test-results/<test>/(screenshot,error-context.md,trace.zip) before changing the test. Fix the cause, not the timeout.
Allowed tools
Tools this skill is permitted to call.
No restriction — this skill can use any tool.
FAQ
What does the writing-end-to-end-tests skill do?
Write and run Playwright end-to-end tests in `e2e/` for the web vault, browser extension and desktop app. Use only when already working in `e2e/`, not to start a test suite elsewhere.
How do I install the writing-end-to-end-tests skill?
Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.
Does the writing-end-to-end-tests skill run scripts?
No, this skill is instructions only (SKILL.md) with no executable scripts.
Related skills
doc-coauthoring
AnthropicGuide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
academy-guide
AnthropicStop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
internal-comms
AnthropicA set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
skill-development
AnthropicThis skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…