Define and scaffold frontend testing for production readiness. Our other
frontend skills (frontend-perfection, frontend-a11y, frontend-performance)
audit a built site; they run ZERO tests. This skill closes that gap: it tells
you what to test, which layer owns each concern, and hands you the config
to wire into CI. It is a process/knowledge + scaffolding skill, not a runtime
audit.
Mapped 1:1 from the Front-End-Checklist “Testing” category. Each rule names the layer it belongs to and the reference file that scaffolds it.
| # | Rule (verbatim priority) | Layer | Scaffold |
|---|---|---|---|
| 1 | Write unit tests [High] | Unit | your unit runner (Vitest/Jest) |
| 2 | Write integration tests for key workflows [High] | Integration | your runner + MSW |
| 3 | Implement end-to-end testing [High] | E2E | references/playwright.config.ts, references/e2e-smoke.spec.ts |
| 4 | Use visual regression testing [Medium] | Visual | references/visual-regression.md |
| 5 | Include accessibility testing [High] | A11y | references/a11y-test.md |
| 6 | Test across all major browsers [High] | Cross-browser | references/playwright.config.ts (projects) |
| 7 | Test on real mobile devices and viewports [High] | Real-device | references/playwright.config.ts (Mobile projects) |
| 8 | Enforce performance budgets in CI [Medium] | Perf-budget | references/ci-perf-budget.yml |
| 9 | Use mutation testing to measure how well tests detect bugs [Medium] | Mutation | Stryker config note |
| 10 | Integrate real-time error monitoring in production [High] | Error-monitoring | Sentry note |
| 11 | Maintain test coverage thresholds [Medium] | Coverage | references/ci-perf-budget.yml (coverage gate) |
| 12 | Follow mocking best practices [Medium] | Mocking | mocking note |
| 13 | Implement consumer-driven contract testing for API boundaries [Medium] | Contract | references/contract-test.md |
/\ E2E (few, critical journeys only) → Playwright / Cypress
/ \ Visual regression (key screens) → snapshot diff
/----\ Cross-browser + real-device → Playwright projects
/ \ A11y (axe in CI) → jest-axe / @axe-core/playwright
/--------\ Integration (key workflows) → Vitest/Jest + MSW
/ \ Unit (critical logic, many) → Vitest/Jest
/____________\ Contract (API boundaries) → Pact
| Symptom / question | Reach for | Why |
|---|---|---|
| “Is this pure function correct?” | Unit | Fastest feedback, no flake |
| “Do these modules cooperate?” | Integration | Catches wiring bugs units miss |
| “Can a real user complete the flow?” | E2E (Playwright) | Only layer that proves the journey |
| “Did the layout shift unexpectedly?” | Visual regression | Pixel diff beats eyeballs |
| “Is it usable by AT users?” | A11y (axe) | Automated WCAG subset in CI |
| “Does it work in Firefox/Safari/Edge?” | Cross-browser projects | Engine differences are real |
| “Does it break on a phone?” | Real-device / mobile emulation | Touch + viewport bugs |
| “Did a backend change break the UI?” | Contract (Pact) | Fails before prod |
| “Will my tests actually catch bugs?” | Mutation (Stryker) | Coverage % lies; mutations don’t |
| “Is it fast enough to ship?” | Perf budget in CI | Fails build on regression |
| “What blew up in prod?” | Error monitoring (Sentry) | Post-deploy truth |
Rule of thumb: write the cheapest test that can fail for the right reason. Don’t E2E a pure function; don’t unit-test a user journey.
frontend-perfection — audits a built site (Lighthouse, contrast, tokens,
a11y subset). This skill adds the test suite that prevents regressions the
audit would otherwise catch late. Scaffold tests here first, then run
frontend-perfection to verify the result stays green.frontend-a11y — deep accessibility. This skill’s references/a11y-test.md
is the CI gate (axe in the pipeline); frontend-a11y is the manual/expert
pass. They share axe-core; don’t duplicate the audit — wire the gate.frontend-performance — measures field/lab perf. This skill’s
references/ci-perf-budget.yml fails the build when budgets slip;
frontend-performance tells you why and how to fix./frontend — orchestrator. Routes the testing/QA domain to this skill during
a build or pre-release handoff.Do NOT reimplement perf/security/a11y audits here — point to the siblings.
python3 scripts/scaffold.py --target /path/to/project --layers playwright,e2e,a11y,ci
# expected: one "copied references/<file> -> <dest>" line per layer;
# "Scaffolded N file(s) into <target>"; exit 0
# exit 2 if --target does not exist; exit 1 if a source is missing
The script maps each layer to its reference file and destination (the reference files stay the source of truth if you prefer to place them by hand):
playwright → references/playwright.config.ts → playwright.config.tse2e → references/e2e-smoke.spec.ts → e2e/e2e-smoke.spec.tsa11y → references/a11y-test.md → e2e/a11y-test.mdvisual → references/visual-regression.md → e2e/visual-regression.mdci → references/ci-perf-budget.yml → .github/workflows/perf-budget.ymlcontract → references/contract-test.md → tests/contract/contract-test.mdCopy only the layers you need; pass --layers to pick them.
npm i -D @playwright/test @axe-core/playwright vitest @vitest/coverage-v8 msw
npx playwright install --with-deps chromium firefox webkit
references/ci-perf-budget.yml.You must be able to demonstrate the scaffold runs, not just that files exist.
Unit / integration (Vitest):
npx vitest run --coverage
# expected: ✓ N passed; coverage summary; exit 0 when ≥ threshold
E2E (Playwright):
npx playwright test --project=chromium
# expected: Running 6 tests using 1 worker; N passed; exit 0
# on failure: trace + screenshot retained (see config use:)
A11y gate (axe in Playwright):
npx playwright test e2e/a11y.spec.ts
# expected: no violations; exit 0. On violation: list of axe rule ids + nodes
Mutation (Stryker) — critical logic only:
npx stryker run
# expected: Mutation score ≥ your threshold (e.g. 80%); report shows killed/survived
Perf budget (CI only, but locally reproducible):
npx lhci autorun --collect.url=http://localhost:3000
# expected: all budgets met; exit 0. Breach → non-zero exit fails the build
Report the exact command you ran, the real output (or its shape), and the exit code. A config that has never been executed is not “scaffolded” — it’s a draft.
When you deliver a testing scaffold, write a short report:
references/playwright.config.ts — multi-project config (devices, baseURL, trace).references/e2e-smoke.spec.ts — critical-journey E2E example.references/visual-regression.md — screenshot-diff approach + tooling.references/a11y-test.md — jest-axe and @axe-core/playwright snippets.references/ci-perf-budget.yml — GitHub Actions perf budget + coverage gate.references/contract-test.md — Pact consumer-driven contract example.frontend-perfection, frontend-a11y, or frontend-performance.