We use Vitest for all testing needs, leveraging its speed and compatibility with the Vite ecosystem.
- Unit Tests: Co-located with source or in
test/folders. Focus on individual functions (e.g.,classifier.test.ts,hashing.test.ts). - Integration Tests: In
packages/node/test. Test the interaction between CLI, Worker Pool, and File System. - E2E / Golden Tests:
packages/node/test/golden.spec.ts. These run the full binary against real image fixtures and compare output byte-for-byte (or visually via SSIM) against "golden" known-good outputs.
pnpm testpnpm test --watchpnpm test packages/core/test/hashing.test.ts- Describe/It: Use standard BDD syntax.
- Fixtures: Use
packages/node/test/fixturesto store small, representative inputs. - Mocking: Use
vi.mocksparingly. prefer testing public interfaces.- We mock
sharpin some unit tests to avoid binary dependencies, but E2E tests use realsharp.
- We mock
GitHub Actions (ci.yml) runs pnpm test on every PR.
Failed tests block merging.