askill
react-testing

react-testingSafety 90Repository

Testing strategies with RTL and Jest/Vitest.

144 stars
2.9k downloads
Updated 1/27/2026

Package Files

Loading files...
SKILL.md

React Testing

Priority: P2 (MAINTENANCE)

Reliable tests focusing on user behavior.

Implementation Guidelines

  • Tooling: React Testing Library + Vitest.
  • Philosophy: Test behavior, not implementation (State/Internal vars).
  • Queries: getByRole > getByText > getByTestId.
  • Events: Use userEvent (async) over fireEvent.
  • Async: await screen.findBy* for async updates.
  • Mocks: MSW for network. Mock heavy 3rd-party libs.
  • Accessibility: Testing Lib implicitly tests a11y roles.

Anti-Patterns

  • No Shallow Rendering: Render full tree.
  • No Testing Implementation Details: Don't check component.state.
  • No Wait: Use findBy, avoid waitFor if possible.

Code

test('submits form', async () => {
  const user = userEvent.setup();
  render(<LoginForm />);

  await user.type(screen.getByLabelText(/email/i), 'test@test.com');
  await user.click(screen.getByRole('button', { name: /login/i }));

  expect(await screen.findByText(/welcome/i)).toBeInTheDocument();
});

Install

Download ZIP
Requires askill CLI v1.0+

AI Quality Score

95/100Analyzed 2/4/2026

Excellent skill document providing clear, actionable guidelines for React testing with RTL and Vitest. Includes triggers, anti-patterns, and a practical code example.

90
95
100
95
95

Metadata

Licenseunknown
Version-
Updated1/27/2026
PublisherHoangNguyen0403

Tags

testing