Welcome to this hands-on tutorial where you'll learn unit testing in React with Vitest while building a small project! 🚀

We’ll cover all key concepts of unit testing step by step, and you'll apply them to a real project as we go.


🎯 What You'll Learn

  1. Introduction to Vitest
  2. Setting Up Vitest in a React + Vite Project
  3. Writing Your First Test
  4. Testing Components
  5. Testing Props and Events
  6. Mocking Functions & API Calls
  7. Testing Custom Hooks
  8. Snapshot Testing
  9. Running Tests & Debugging

🏗 Project: A Simple Todo App

We’ll build and test a Todo App with features like adding, removing, and marking tasks as completed. Each topic will involve writing tests for different parts of this app.


🔥 1. Introduction to Vitest

Vitest is a fast unit-testing framework built for Vite. It's similar to Jest but optimized for Vite projects, making it perfect for modern React + TypeScript development.

Why Vitest?