Unit Tests (Vitest)
Unit tests cover individual functions and modules. They live alongside the source code as*.test.ts files. Vitest is configured in vitest.config.ts to exclude *.e2e.ts files so E2E tests never run as unit tests.
vi.mock() for mocking dependencies:
Mocking AI models
For tests that interact with AI models, mock the model resolution layer rather than the AI SDK directly:End-to-End Tests (Playwright)
Playwright tests simulate real user interactions in a browser. Configuration is inplaywright.config.ts.
Test projects
The Playwright config defines five test projects that run in dependency order:| Project | File | Depends On | Purpose |
|---|---|---|---|
setup:auth | auth.setup.e2e.ts | - | Authenticate and save session |
setup:reasoning | reasoning.setup.e2e.ts | setup:auth | Prepare reasoning model state |
chat | chat.e2e.ts | setup:auth | Core chat interactions |
reasoning | reasoning.e2e.ts | setup:reasoning | Reasoning model tests |
artifacts | artifacts.e2e.ts | setup:auth | Canvas and document tests |
CI behavior
| Setting | Local | CI |
|---|---|---|
| Workers | Unlimited | 1 |
| Retries | 1 | 2 |
| Server | Reuse running dev server | Start fresh |
| Traces | On first retry | On first retry |
Writing E2E tests
Create test files in thetests/ directory using the *.e2e.ts naming convention. Tests have access to authenticated sessions via Playwright’s storage state: