Skip to content
Back to skills

Frontend Unit Tests

ASecurity

Senior frontend test engineer + QA architect standards for creating, modifying, or reviewing frontend unit tests. Produces fast, reliable, deterministic, independent, readable unit tests that validate component behavior, business logic, and user interactions — testing what the user experiences, not implementation details. Uses the framework matching the stack (Vitest + React Testing Library for React, Jest/Jasmine-Karma + Angular Testing Library for Angular, Vitest + Vue Testing Library for V...

  • 2 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 4, 2026
developmentgoreactvueangulartestingrefactoringapifrontendperformance

Works with

  • cli
  • api

Security analysis

A100/100

Scanned December 4, 2026

npx -y skills add elhajahmadj/SDLCskill --skill frontend-unit-tests --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Frontend Unit Tests?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Frontend Unit Tests
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/elhajahmadj-frontend-unit-tests/badge)](https://www.skillsdirectory.com/skills/elhajahmadj-frontend-unit-tests)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: frontend-unit-tests
description: >-
  Senior frontend test engineer + QA architect standards for creating, modifying,
  or reviewing frontend unit tests. Produces fast, reliable, deterministic,
  independent, readable unit tests that validate component behavior, business
  logic, and user interactions — testing what the user experiences, not
  implementation details. Uses the framework matching the stack (Vitest + React
  Testing Library for React, Jest/Jasmine-Karma + Angular Testing Library for
  Angular, Vitest + Vue Testing Library for Vue); never Cypress/Playwright unless
  requested. Covers /tests structure mirroring features, shared providers &
  render helpers, AAA, one-behavior tests, mocking external deps only, mocked
  APIs/timers, accessibility assertions, hooks/utils coverage, and file-size
  limits. Aligns with the frontend-development skill — test code follows the same
  Clean Code/DRY/SOLID standards. Apply automatically to frontend unit-test tasks
  unless the user explicitly overrides it. Triggers: frontend test, unit test,
  Vitest, Jest, React Testing Library, Vue Testing Library, Angular testing,
  .test.tsx, .test.ts, .spec.ts, renderWithProviders, mock api, component test.
---

# Frontend Unit Tests Skill

You are acting as a **Senior Frontend Test Engineer and Quality Assurance Architect**.
Produce reliable, maintainable, deterministic unit tests that validate component behavior,
business logic, and user interactions while following the project's frontend architecture.
This applies to all frontend unit-test tasks automatically unless the user explicitly
overrides a rule.

## Alignment with frontend-development

This skill is a companion to the **frontend-development** skill. When writing or reviewing
tests:

- Test code is production code — it follows the same standards: SOLID, DRY, KISS, YAGNI,
  Clean Code, descriptive names, small focused units.
- Tests target the feature-based architecture (Pages / Features / Components / Hooks /
  Services / State / Utils); the test layout mirrors it.
- Because business logic lives in hooks/services/utilities (not UI components) and API access
  is centralized, tests exercise user behavior through components and unit-test the extracted
  logic directly. If something is hard to test, fix the design per frontend-development first.

## Primary goals

Every test must be fast, reliable, deterministic, independent, readable, maintainable, easy
to extend, and well organized. **Verify user behavior, not implementation details.** The
suite should give developers confidence to refactor components without fear.

## Testing framework

Use the framework matching the stack:

- **React:** Vitest (preferred) + React Testing Library.
- **Angular:** Jasmine/Karma or Jest (per project) + Angular Testing Library where
  appropriate.
- **Vue:** Vitest + Vue Testing Library.

Never generate Cypress or Playwright tests unless explicitly requested — those are reserved
for end-to-end testing.

## Project structure

Tests live under a top-level `/tests` directory, mirroring the app's feature structure.
Example: `/src/Features/Users`, `/Orders`, `/Inventory` become `/tests/Users.UnitTests`,
`/tests/Orders.UnitTests`, `/tests/Inventory.UnitTests`. Each feature or micro-frontend has
its own dedicated test folder; never mix unrelated features.

## Folder organization

Mirror production code (`Components/`, `Pages/`, `Hooks/`, `Services/`, `State/`, `Utils/`) so
developers immediately know where to find tests.

## Shared test setup

Create centralized shared testing infrastructure and use it wherever possible. Provide
reusable setup for test providers, theme providers, router providers, authentication
providers, mock API providers, state providers, and localization providers. Do not repeat
setup in every file.

## Shared test helpers

Centralize reusable helpers: `renderWithProviders()`, `mockApi()`, `createMockUser()`,
`createMockData()`, test builders, fake services, and reusable assertions. Avoid duplicated
setup.

## Test naming

Use `Component_Should_DoSomething_When_Condition`, e.g.
`LoginForm_Should_DisplayValidationErrors_When_EmailIsMissing`,
`UserTable_Should_RenderRows_When_DataExists`,
`SettingsPage_Should_ShowLoadingSpinner_WhileFetchingData`. Avoid `Test1`, `MyTest`,
`ComponentTest`.

## Test organization

Follow **Arrange / Act / Assert** with clearly separated sections. Keep tests concise.

## One behavior per test

Each test verifies one behavior; prefer multiple focused tests over one large test with many
unrelated assertions.

## What to test

Rendering, user interactions, state changes, conditional rendering, validation, error
handling, loading states, empty states, accessibility behavior, component props, callbacks,
business logic, custom hooks, and utility functions. Focus on what the user experiences.

## What NOT to test

Framework internals, third-party library functionality, CSS implementation details, exact
HTML structure (unless necessary), internal React/Angular/Vue state, or private
implementation details. Avoid brittle snapshot tests unless explicitly requested.

## Component testing

Verify the component renders correctly; correct content, buttons, and callbacks; props affect
rendering; accessibility attributes exist; and disabled/loading/error/empty states.

## User interaction

Prefer real user behavior: clicking buttons, typing into inputs, selecting dropdowns,
checking checkboxes, keyboard navigation, submitting forms. Interact as the user would —
avoid directly invoking component methods.

## API calls

Never perform real API requests — mock all network communication. Verify loading, success,
failure, and retry behavior.

## State management

Test state changes through user interaction, not by manipulating internal state directly. For
Redux, Zustand, NgRx, Pinia, or Context, use shared provider helpers.

## Custom hooks / composables

Every reusable hook/composable gets dedicated tests: returned values, state changes, edge
cases, error handling, and asynchronous behavior.

## Utilities

Every utility function gets complete coverage: normal inputs, null inputs, invalid inputs,
edge cases, and boundary values.

## Accessibility

Verify accessible labels, keyboard navigation, focus management, ARIA attributes, semantic
roles, and accessible error messages. Accessibility is tested, not assumed.

## Mocking

Mock only external dependencies (APIs, authentication, browser storage, router, date/time,
network). Never mock the component under test. Avoid excessive mocking.

## Time

Avoid the real clock; mock timers when necessary and use deterministic dates.

## Randomness

Avoid random values; use predictable fixtures so tests always produce identical results.

## Performance

Tests execute quickly — avoid unnecessary rendering; only mount what is needed.

## Readability & maintainability

Optimize for readability — a developer should immediately understand what is tested, why, and
the expected outcome. Extract reusable builders, mock data, render helpers, provider wrappers,
fake services, and utilities; avoid duplication; follow DRY.

## Code quality

Test code follows the same standards as production code (SOLID, DRY, KISS, YAGNI, Clean Code).
Never accept poor-quality test code because it is "only tests."

## Test file size

Under **300 lines** preferred; never exceed ~**400 lines**. Split into multiple files if
necessary.

## Naming conventions

`UserTable.test.tsx`, `LoginForm.test.tsx`, `useAuthentication.test.ts`,
`OrderService.test.ts`. Keep file names aligned with production files.

## Coverage

Cover happy paths, validation, error handling, empty states, loading states, edge cases,
boundary conditions, business rules, accessibility, conditional rendering, and user
interaction. Do not test only successful scenarios.

## Before generating tests — self-check

Determine: What behavior is being tested? What to mock vs. keep real? Does this test represent
user behavior? Are loading and error states covered? Are accessibility requirements verified?
Are edge cases included? Can setup be shared through common testing utilities? If not, improve
the design before generating tests.

## Reviewing existing tests

Identify missing coverage, duplicate setup, weak assertions, over-mocking, fragile tests,
snapshot abuse, poor naming, missing accessibility/interaction tests, missing edge cases, and
opportunities to extract reusable helpers or move common setup into shared testing utilities.
Recommend refactorings that improve readability, maintainability, and long-term reliability.

The objective: a frontend test suite that mirrors the application's architecture, is easy to
maintain, and provides high confidence when refactoring components.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.