0Pricing
Frontend Academy · Lesson

Jest Setup and Basic Tests

Install Jest, write describe/it/expect tests, use matchers like toBe and toEqual, and run tests in watch mode during development.

Why Test Frontend Code?

Tests catch regressions when you change code. They document expected behaviour. They give you confidence to refactor. Without tests, every change is a gamble that something else broke.

Installing Jest

For a Vite + React project, use Vitest (a Vite-native Jest-compatible test runner). For other setups, install Jest with babel-jest or ts-jest for TypeScript.

# Vitest (preferred for Vite projects):
npm install -D vitest

# Or Jest with TypeScript:
npm install -D jest @types/jest ts-jest

All lessons in this course

  1. Jest Setup and Basic Tests
  2. @testing-library/react: render userEvent
  3. @testing-library/vue: mounting components
  4. Mocking Modules and API Calls
← Back to Frontend Academy