frontend-testing-strategy
Skill0 starsChanged 2 months agoMITView on GitHub
What to test at each layer of a frontend app — and what to leave to the type system and CI. Vitest/RTL/playwright boundaries, test-writing rules that keep suites fast and trusted. Use when adding tests, fixing a flaky suite, or deciding coverage strategy.
2 other projects use a version of this.
Adopted by
Most recently taken up by
- grafana/grafanatheir own version, first seen Oct 8, 2026
- annatchijova/SKILLStheir own version, first seen Jul 8, 2026
Other versions2 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 2
- grafana/grafana★ 78ksame name
- annatchijova/SKILLS★ 9same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository11 other files it gives its agents.
- api-contract-designSkill
- browser-debuggingSkill
- component-reviewSkill
- css-architectureSkill
- nextjs-performanceSkill
- performance-budgetSkill
- react-hooks-disciplineSkill
- state-managementSkill
- typescript-strictnessSkill
- vue3-compositionSkill
- web-a11ySkill
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 31
Test behavior through the public API, not internals (no asserting on private state shape).
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Frontend testing strategy
The pyramid, corrected
E2E (few, happy paths + money paths)
──── Integration (component + real store/router)
────── Unit (pure logic: hooks, reducers, utils)
──────── Types + lint (catch the rest for free)- Types catch the "undefined is not a function" class — don't write tests for what
tsc --strictalready proves. - E2E is the most expensive and flakiest layer: reserve it for the journeys whose breakage loses users or money.
Unit: pure logic only
Hooks, reducers, formatters, parsers — anything with inputs/outputs and no DOM:
test('discount applies only above threshold', () => {
expect(priceAfterDiscount(100, { threshold: 50, pct: 10 })).toBe(90)
expect(priceAfterDiscount(40, { threshold: 50, pct: 10 })).toBe(40)
})- Test behavior through the public API, not internals (no asserting on private state shape).
- Edge cases are the product: empty, one, many, huge, unicode, timezone boundaries.
Integration: the workhorse
Render the component with its real providers (store, router, i18n) — mock only the network:
test('adds item and shows total', async () => {
render(<Cart />, { wrapper: TestProviders })
await user.click(screen.getByRole('button', { name: /add/i }))
expect(await screen.findByText('$19.00')).toBeVisible()
})- Query by role/name (what users perceive), never by class/test-id-first.
findByfor async UI; never arbitrarywaitFortimeouts.
E2E: few and vital
- Happy path + payment/auth/delete flows. Stable selectors (
data-testidonly where roles don't exist). - One environment, seeded data, parallel-safe. If a test can't say which user journey it protects, delete it.
Flakiness is a bug, not weather
- Re-run failing test 10× locally (
--repeat) — flaky = fix or quarantine same-day. - Usual suspects: uncontrolled time/random (inject clocks/seed), animation races (disable motion in tests), network races (mock at the boundary, await explicit states), test-order coupling.
- No
sleep()in tests. Ever. Await the observable state.
The metrics that matter
- Coverage is a smoke detector, not a goal: 80% of changed code beats 60% global vanity.
- Track time-to-feedback (target: unit+integration < 60s locally) — slow suites get skipped, skipped suites rot.
- Mutation-style spot checks on critical utils: would the test fail if the logic broke?
Definition of done (agent checklist)
- New logic has tests at the lowest sufficient layer
- Queries by role/label; async via findBy
- No sleeps, no test-order coupling, no network beyond the mock boundary
- Flaky tests quarantined with an owner and a deadline
- PR diff covered where it matters (money/auth/data)
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

