Skip to content

Overview

This tutorial walks you through building a minimal Vitest implementation step by step. Each step is managed as a pnpm workspace package under the impls/ directory.

Step Overview

StepDirectoryDescription
0000-basic-test-functiontest() function with async/await support
0101-expect-assertionsexpect() and toBe() matcher
0202-test-runnerCLI to detect and run test files
0303-describe-suitesdescribe() blocks for grouping tests
0404-lifecycle-hooksbeforeEach, afterEach, beforeAll, afterAll
0505-error-reportingColored output, diff, and stack traces
0606-parallelParallel test file execution with Promise.all
0707-isolateTest file isolation via Worker threads
0808-watch-modeFile watching with chokidar
0909-reportersPluggable reporter system

Running Examples

Each step can be run with the following commands:

bash
# From the root directory
pnpm example:00  # Run Step 00
pnpm example:01  # Run Step 01

# Or from each directory
cd impls/00-basic-test-function
bun run example

Project Structure

Each step follows this structure:

impls/XX-step-name/
├── package.json
├── tsconfig.json
├── src/
│   ├── index.ts
│   └── [step-specific files]
└── example/
    └── example.test.ts