
This course contains the use of artificial intelligence.
I can copy Jest's syntax. But I can't explain why it's written that way. — This course exists to get you out of exactly that state.
Vitest is a test runner that reuses Vite's transform pipeline directly to execute your tests. Once you grasp this single fact, everything connects on one line: why TypeScript runs with zero config, why `vi.mock` takes effect before your imports, why Promises don't resolve under fake timers. This course builds up that "how it works" understanding systematically through 50 hands-on drills.
Learning follows a roadmap of 10 chapters. Chapter 0 nails down Vitest's execution model. Chapter 1 covers the "three levels of equality" (`toBe` / `toEqual` / `toStrictEqual`), asymmetric matchers, and even writing your own custom matchers. Chapter 2 covers data-driven testing with `test.each` / `describe.each` / `test.for`; Chapter 3 covers hook execution order and the dependency graph and scope design of Vitest's fixture mechanism `test.extend`.
Chapter 4 is a full system for mocks. The three-tier reset distinction of `mockClear` / `mockReset` / `mockRestore` that trips up so many learners, and the hoisting behavior of `vi.mock`, are made to click through running code. Chapter 5 conquers async testing end to end: `resolves` / `rejects`, fake timers × Promises, `vi.waitFor`, `test.concurrent`, and `retry` for flaky tests.
From Chapter 6 we turn to real targets. You'll build designs that verify temporary-file I/O, the repository pattern over in-memory SQLite (`node:sqlite`), and HTTP APIs with Hono and zod as "real I/O, but fast and deterministic." Chapter 7's snapshots show how to remove noise with custom serializers; Chapter 8 covers Vitest-only weapons: in-source tests, type tests (`expectTypeOf`), benchmarks (`bench`), and browser mode. The final chapter closes with a coverage-threshold gate, unit/integration separation via `projects`, and a capstone that implements `PriceCalculator` via TDD and builds a mock CI.
Not just becoming able to write tests, but becoming able to design tests. That is the goal of this course.
Practice in Google Cloud Shell by uploading the exercise ZIP and running the included setup script. Node 24+ is required; no local Node installation is needed. A Google account is required. Free quotas: 50 hours/week, 5GB. Accounts under 18 or with unknown age cannot use Cloud Shell. A local Node alternative is included. Follow the updated startup lecture when videos show CodeSandbox. Grading requires no API keys or paid Cloud resources.