Testing Framework Selection
Context
We need a testing framework that supports both Backend (NestJS/Node.js) and Future Frontend (React/Web) within a monorepo structure. The tool must handle ESM (ES Modules) natively and provide high performance.
Comparison (2026 Landscape)
| Feature | Vitest | Jest | Bun Test |
|---|---|---|---|
| ESM Support | Native (Excellent) | Complex/Requires Workarounds | Native |
| Performance | Ultra-fast (Vite-based) | Slower (Process overhead) | Fastest |
| Ecosystem | Compatible with Jest API | Industry Standard | Limited |
| DX | Instant Watch Mode | Slower re-runs | Instant |
Decision
Vitest.
Rationale
- ESM Native: Unlike Jest, Vitest doesn't struggle with
type: moduleand Top-level await, which are core to our project. - Monorepo Efficiency: By installing it at the root, we maintain a single version for all packages while allowing specific configurations (e.g., SWC for NestJS decorators).
- Speed: Leveraging
esbuild/swcensures that tests don't become a bottleneck as the project grows. - Compatibility: It supports the same
describe/it/expectsyntax as Jest, making it easy for contributors.
Consequences
- Specific plugins (like
unplugin-swc) are required to handle NestJS decorators.