Skip to content
Skills Library
Programming · Testing

frontend-testing

/frontend-testing

Testing strategy and setup for TypeScript frontends: Vitest with Testing Library for React and Next.js, the Angular Vitest builder (@angular/build:unit-test) with TestBed and component harnesses, MSW for API mocking, Playwright for end-to-end, coverage thresholds and CI wiring. Use when writing or fixing frontend unit, component or E2E tests, configuring Vitest, Playwright or MSW, or deciding what to test at which level. Not for Spring Boot tests (see spring-boot-testing).

Licence
MIT
Last repository change
03.11.2026

Assessment and security

90/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content25 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
5
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 03.11.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Testing strategy and setup for TypeScript frontends: Vitest with Testing Library for React and Next.js, the Angular Vitest builder (@angular/build:unit-test) with TestBed and component harnesses, MSW for API mocking, Playwright for end-to-end, coverage thresholds and CI wiring. Use when writing or fixing frontend unit, component or E2E tests, configuring Vitest, Playwright or MSW, or deciding what to test at which level. Not for Spring Boot tests (see spring-boot-testing).

Original author description

Testing strategy and setup for TypeScript frontends: Vitest with Testing Library for React and Next.js, the Angular Vitest builder (@angular/build:unit-test) with TestBed and component harnesses, MSW for API mocking, Playwright for end-to-end, coverage thresholds and CI wiring. Use when writing or fixing frontend unit, component or E2E tests, configuring Vitest, Playwright or MSW, or deciding what to test at which level. Not for Spring Boot tests (see spring-boot-testing).

How it works

  1. Use when / do not use
  2. Workflow
  3. Rules
  4. References
Original SKILL.md headings · 65 lines, 781 words
SKILL.md preview
---
name: frontend-testing
description: "Testing strategy and setup for TypeScript frontends: Vitest with Testing Library for React and Next.js, the Angular Vitest builder (@angular/build:unit-test) with TestBed and component harnesses, MSW for API mocking, Playwright for end-to-end, coverage thresholds and CI wiring. Use when writing or fixing frontend unit, component or E2E tests, configuring Vitest, Playwright or MSW, or deciding what to test at which level. Not for Spring Boot tests (see spring-boot-testing)."
license: MIT
metadata:
  author: baibesh/devkit-skills
---

# Frontend Testing

Targets: Vitest 5 (4.x still common), Testing Library (React 16, user-event 14, jest-dom 7), Angular 22 with `@angular/build:unit-test` (Vitest is the default runner for new projects since Angular 21), MSW 3 (2.x still common), Playwright 1.5x/1.6x, React 19, Next.js 16.
First detect the project's real versions from package.json and adapt; never downgrade a project.

## Use when / do not use

- Use when adding, fixing, or reviewing unit, component, integration, or E2E tests in a TypeScript frontend, or configuring Vitest, Playwright, MSW, coverage, or CI test jobs.
- Use when deciding which level a behavior should be tested at.
- Do not use for framework API details (signals, hooks, Server Components): see `angular-developer`, `vercel-react-best-practices`, and the Next.js skills / generated `AGENTS.md`. For TS style see `typescript-conventions`.
- Not for backend tests: Spring Boot goes to `spring-boot-testing`.

## Workflow

Test levels:

| Level | Tool | What belongs here |
| --- | --- | --- |
| Unit | Vitest (node env) | pure functions, schemas, reducers, services without DOM |
| Component / integration | Vitest + Testing Library (jsdom or browser mode), Angular TestBed + harnesses, MSW for HTTP | rendering, user interaction, a feature slice with its data layer |
| End-to-end | Playwright against a built app | critical user journeys, routing, auth, async Server Components, real browser APIs |

Most tests are component/integration tests. Keep E2E to a few journeys per feature; they are slower and flakier.

1. Detect the stack: framework, `vitest`/`@angular/build`/`karma`/`jest`, `msw`, `@playwright/test` versions, and existing config files (`vitest.config.*`, `angular.json` test target, `playwright.config.ts`). Follow the existing runner unless asked to migrate.
2. Choose the level from the table above; test behavior a user or caller can observe, not implementation details.
3. Set up or fix the runner: React/Next per `references/vitest-react.md`, Angular per `references/angular-testing.md`.
4. Mock the network, not your modules: shared MSW handlers per `references/msw-mocking.md`, with unhandled requests failing the test.
5. Write the test: arrange with factories, act through user-event or harnesses, assert on accessible output (roles, labels, text).
6. Add or update E2E for the journey if it crosses pages, auth, or server rendering (`references/playwright-e2e.md`).
7. Run locally in single-run mode, then wire CI: unit and E2E jobs, coverage thresholds, JUnit/HTML reports, Playwright traces as artifacts.
8. If a test is flaky, find the race (missing `await`, timer, unmocked request) instead of adding retries or sleeps.

## Rules

- Do query by role, label, or text (`getByRole('button', { name: 'Save' })`); use `data-testid` only when nothing accessible exists.
- Do use `@testing-library/user-event` (`const user = userEvent.setup()`) over `fireEvent`.
- Do `await` every async assertion and `findBy*`; Vitest 5 fails unawaited `resolves`/`rejects`.
- Don't use fixed sleeps; wait for UI state (`findBy*`, `expect.poll`, Playwright web-first assertions).
- Do mock HTTP with MSW; don't mock `fetch`, `HttpClient`, or your own API client module in component tests.
- Do set `onUnhandledFrame: 'error'` (MSW 3) or `onUnhandledRequest: 'error'` (MSW 2).
- Do reset MSW handlers, timers, and mocks after each test; remember Vitest 5 defaults `clearMocks: true`.
- Do build test data with typed factories (`makeUser({ role: 'admin' })`), not shared mutable fixtures.
- Don't snapshot whole component trees; snapshot small serialized values or use visual/ARIA snapshots in Playwright.
- Do use Angular component harnesses (`@angular/cdk/testing`) for Material/CDK and your own complex components.
- Don't use `fakeAsync`/`tick` with the Angular Vitest runner (zoneless); use `vi.useFakeTimers()` and `await fixture.whenStable()`.
- Do test async React Server Components and full Next.js routes with Playwright, not Vitest.
- Do keep E2E tests independent: each creates its own data or uses an isolated account; no ordering dependencies.
- Do reuse auth via a Playwright setup project and `storageState`, not a UI login in every test.
- Do enforce coverage thresholds in CI on meaningful code; exclude generated code, types, and config files.
- Don't chase 100% coverage; cover branches with business logic and error states.
- Do record Playwright traces `on-first-retry` and upload reports on failure.
- Don't retry unit tests in CI; allow at most 1-2 retries for E2E and treat retries as flakiness to fix.
- Do name tests as behavior: `it('shows an error when the card is declined')`.

## References

| File | Read when |
| --- | --- |
| [references/vitest-react.md](references/vitest-react.md) | configuring Vitest for React or Next.js, writing Testing Library tests, browser mode, coverage, Vitest 4 to 5 upgrade |
| [references/angular-testing.md](references/angular-testing.md) | configuring `@angular/build:unit-test`, TestBed, signal inputs, HTTP testing, harnesses, migrating from Karma/Jasmine |
| [references/msw-mocking.md](references/msw-mocking.md) | mocking HTTP/GraphQL/WebSocket with MSW in tests, Storybook, or dev; MSW 2 to 3 changes |
| [references/playwright-e2e.md](references/playwright-e2e.md) | writing or configuring Playwright E2E tests, auth setup, network mocking, visual checks, CI sharding |
Files in this package (5)
  • SKILL.md 6 KB
  • references/angular-testing.md 7 KB
  • references/msw-mocking.md 7 KB
  • references/playwright-e2e.md 7 KB
  • references/vitest-react.md 8 KB

Versions

RepositoryScoreLicence
This page · baibesh/devkit-skills90MIT
mintuz/claude-plugins100MIT
schalkneethling/create-project-calavera100MIT
bestdeejay-design/agent-skills100MIT
Carrerajorge/Hola100MIT
pageai-pro/ralph-loop100MIT
practicajs/the-frontend-testing-skill95MIT
j4flmao/agent-skills95MIT
tmj-90/gaffer90Apache-2.0

Database snapshot: 13.11.2026 · package version 6621ac82fca1 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100nextjs-testing
    Write Jest or Vitest unit tests with React Testing Library and Playwright E2E tests for Next.js projects. Use when testing components with RTL, mocking APIs with MSW, or creating Playwright user flow tests.
  • 90frontend-typescript-testing
    Designs frontend tests using the repository's configured React test and browser harnesses, including RTL, MSW, Vitest, and Playwright when present. Use when adding or reviewing component, loading/error-state, integration, or frontend E2E tests.
  • 100vitest-rtl-msw-patterns
    Frontend testing with Vitest, React Testing Library, MSW v2, plus contract tests where Zod schemas mirror backend Pydantic models. Use for test infra setup, component tests, or mocking API requests.
  • 100react-testing
    React component testing with React Testing Library, Vitest/Jest, MSW for network mocking, accessibility assertions with axe, and the decision boundary between component tests and Playwright/Cypress end-to-end runs. Use when writing or fixing tests for React components, hooks, or pages.
  • 90frontend-typescript-testing
    使用仓库已配置的 React 测试与浏览器测试工具(包括 RTL、MSW、Vitest,以及存在时的 Playwright)设计前端测试。适用于新增或评审组件测试、加载/错误状态测试、集成测试或前端 E2E 测试时。
  • 100react-testing
    React component testing with React Testing Library, Vitest/Jest, MSW for network mocking, accessibility assertions with axe, and the decision boundary between component tests and Playwright/Cypress end-to-end runs. Use when writing or fixing tests for React components, hooks, or pages.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.