frontend/testing-frontend/SKILL.md
Implement comprehensive frontend testing using Vitest for unit/integration tests and React Testing Library for component interactions.
npx skillsauth add 7a336e6e/skills testing-frontendInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
4 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Ensure frontend reliability through a mix of unit tests for logic and integration tests for components, verifying behavior from the user's perspective.
Ensure vitest and @testing-library/react are configured.
// vite.config.ts
test: {
globals: true,
environment: 'jsdom',
setupFiles: './src/test/setup.ts',
}
Test behavior, not implementation details. Query by accessible roles.
// Button.test.tsx
import { render, screen, fireEvent } from '@testing-library/react';
import { Button } from './Button';
import { vi } from 'vitest';
test('calls onClick when clicked', () => {
const handleClick = vi.fn();
render(<Button onClick={handleClick}>Submit</Button>);
const button = screen.getByRole('button', { name: /submit/i });
fireEvent.click(button);
expect(handleClick).toHaveBeenCalledTimes(1);
});
Use waitFor or findBy* queries for async operations.
test('displays user data after fetch', async () => {
render(<UserProfile id="1" />);
// Show loading first
expect(screen.getByText(/loading/i)).toBeInTheDocument();
// Wait for data
const user = await screen.findByRole('heading', { name: /john doe/i });
expect(user).toBeInTheDocument();
});
Mock external modules and API calls using MSW (Mock Service Worker) or Vitest spies. Prefer MSW for API mocking to test the full network stack.
screen.getByRole as the primary query method (ensures accessibility).describe blocks matching the component/feature name.getByTestId unless no other query works.*.test.tsx or *.spec.ts files alongside the source files.../building-components/SKILL.md../../designer/ensuring-accessibility/SKILL.mddevelopment
Implement features using the Red-Green-Refactor cycle to ensure testability and correctness from the start.
data-ai
Manage the `tasks.md` ledger with strict locking and collision avoidance protocols to allow multiple agents to work in parallel safely.
development
The git-workflow skill defines branching conventions, commit message formats, and pull request standards that all agents must follow for consistent version control.
development
The environment-config skill standardizes how agents manage environment variables, secrets, and application configuration across local development and deployed environments.