概要
このチュートリアルでは、minimal な Vitest をステップバイステップで作成します。各ステップは impls/ 配下の pnpm workspace パッケージとして管理されています。
ステップ構成
| ステップ | ディレクトリ | 説明 |
|---|---|---|
| 00 | 00-basic-test-function | test() 関数(async/await 対応) |
| 01 | 01-expect-assertions | expect() と toBe() マッチャー |
| 02 | 02-test-runner | テストファイルを検出・実行する CLI |
| 03 | 03-describe-suites | グループ化のための describe() ブロック |
| 04 | 04-lifecycle-hooks | beforeEach, afterEach, beforeAll, afterAll |
| 05 | 05-error-reporting | カラー出力、diff、スタックトレース |
| 06 | 06-parallel | Promise.all による並列テスト実行 |
| 07 | 07-isolate | Worker threads によるテストファイルの分離実行 |
| 08 | 08-watch-mode | chokidar によるファイル監視 |
| 09 | 09-reporters | プラガブルなレポーターシステム |
実行方法
各ステップは以下のコマンドで実行できます:
bash
# ルートディレクトリから
pnpm example:00 # Step 00 を実行
pnpm example:01 # Step 01 を実行
# または各ディレクトリから
cd impls/00-basic-test-function
bun run exampleプロジェクト構造
各ステップは以下の構造に従います:
impls/XX-step-name/
├── package.json
├── tsconfig.json
├── src/
│ ├── index.ts
│ └── [ステップ固有のファイル]
└── example/
└── example.test.ts