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
| Step | Directory | Description |
|---|---|---|
| 00 | 00-basic-test-function | test() function with async/await support |
| 01 | 01-expect-assertions | expect() and toBe() matcher |
| 02 | 02-test-runner | CLI to detect and run test files |
| 03 | 03-describe-suites | describe() blocks for grouping tests |
| 04 | 04-lifecycle-hooks | beforeEach, afterEach, beforeAll, afterAll |
| 05 | 05-error-reporting | Colored output, diff, and stack traces |
| 06 | 06-parallel | Parallel test file execution with Promise.all |
| 07 | 07-isolate | Test file isolation via Worker threads |
| 08 | 08-watch-mode | File watching with chokidar |
| 09 | 09-reporters | Pluggable 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 exampleProject Structure
Each step follows this structure:
impls/XX-step-name/
├── package.json
├── tsconfig.json
├── src/
│ ├── index.ts
│ └── [step-specific files]
└── example/
└── example.test.ts