Repaso
EspaƱol
Frontend & WebIntermediateFE-50

Name a common way to test React components.

Options

  1. Jest or Vitest with React Testing Library (Correct option)
  2. Only manual testing carried out in the browser
  3. Maven Surefire, run from the backend project
  4. Selenium only, used for every kind of test

Answer

Jest (or Vitest) with React Testing Library, which tests behavior the way a user sees it

Why

Jest or Vitest runs tests and provides assertions and mocks. React Testing Library renders components and lets you find elements like a user would (getByRole, getByText) and trigger events (userEvent.click).

Principle: test what the user sees and does, not internal state or implementation details.

End-to-end tests in a real browser use Selenium, Playwright or Cypress.

Remember

Jest/Vitest + React Testing Library for components; Playwright/Selenium for E2E.

Key terms

Practice this question in Repaso