Skip to content

Testing

Lakea uses Vitest for testing. The infrastructure is configured and ready, with tests being added incrementally.

Each package has Vitest configured in its vite.config.ts:

packages/core/vite.config.ts
export default defineConfig(() => ({
test: {
name: '@lakea/core',
watch: false,
globals: true,
environment: 'node',
include: ['{src,tests}/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
reporters: ['default'],
coverage: {
reportsDirectory: './test-output/vitest/coverage',
provider: 'v8',
}
},
}));

Test files use .spec.ts or .test.ts suffix and are co-located with source:

packages/core/src/
├── types/
│ ├── index.ts
│ └── index.spec.ts # Tests next to source
├── data-fetchers/
│ └── nasa/
│ ├── exoplanetArchive.ts
│ └── exoplanetArchive.spec.ts

Each package also has a tsconfig.spec.json for test-specific TypeScript settings.

Terminal window
# Test a specific package
pnpm nx test @lakea/core
# Test all affected packages (changed since main)
pnpm nx affected -t test
# Test with watch mode
pnpm nx test @lakea/core --watch
# Test with coverage
pnpm nx test @lakea/core --coverage
FilePurpose
vite.config.tsVitest configuration per package
tsconfig.spec.jsonTypeScript settings for tests
vitest.workspace.tsRoot workspace configuration
  • Packages (core, design-system, ui): Use environment: 'node'
  • Apps (if testing UI): Would use environment: 'jsdom'

Test infrastructure is ready. Tests are being added as features are developed. When contributing:

  1. Add tests for new functions in @lakea/core
  2. Place test files next to source files
  3. Run pnpm nx affected -t test before submitting PRs