skills/react/react-testing/SKILL.md
Test React components with RTL and Jest/Vitest. Use when writing React component tests with React Testing Library, Jest, or Vitest.
npx skillsauth add hoangnguyen0403/agent-skills-standard react-testingInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
getByRole / findByRole to test accessibility. Use data-testid only as fallback for complex UI.userEvent (async) instead of fireEvent to better simulate browser events (e.g., await user.click(element)).await screen.findBy* for elements that appear later. Use waitFor(() => ...) for complex non-element updates.state or props. Ensure 100% of P0 flows covered.framer-motion, react-router) or heavy assets to speed up tests.jest-axe.component.state.findBy, avoid waitFor if possible.See references/REFERENCE.md for MSW API mocking, Context testing, form testing, and React Router patterns.
test('submits form', async () => {
const user = userEvent.setup();
render(<LoginForm />);
await user.type(screen.getByLabelText(/email/i), '[email protected]');
await user.click(screen.getByRole('button', { name: /login/i }));
expect(await screen.findByText(/welcome/i)).toBeInTheDocument();
});
development
Summarizes GitHub PR, GitLab MR, or Azure DevOps PR metadata, review threads, changed files, and template completeness. Use during review-ticket or code-review workflows when PR/MR context exists.
tools
Development tools, linting, and build config for TypeScript. Use when configuring ESLint, Prettier, Jest, Vitest, tsconfig, or any TS build tooling.
development
Validate input, secure auth tokens, and prevent injection attacks in TypeScript. Use when validating input, handling auth tokens, sanitizing data, or managing secrets and sensitive configuration.
development
Apply modern TypeScript standards for type safety and maintainability. Use when working with types, interfaces, generics, enums, unions, or tsconfig settings.