import { defineConfig } from 'vitest/config'; import path from 'node:path'; import { INFRA_TEST_SUITES } from './vitest.infra-suites'; import { WAGGLE_SOURCE_CONDITIONS, waggleSrcAliases } from './vitest.aliases'; export default defineConfig({ resolve: { // Workspace packages resolve to src/ through their `source` export, so // tests need no build step (P2.1). conditions: WAGGLE_SOURCE_CONDITIONS, alias: { // Packages without a `source` export (the excluded ones) map to src/. ...waggleSrcAliases(__dirname), // App uses @/ alias for src directory '@/': path.resolve(__dirname, 'app/src') + '/', '@': path.resolve(__dirname, 'app/src'), }, }, ssr: { resolve: { conditions: WAGGLE_SOURCE_CONDITIONS }, }, test: { globals: true, // Passing tests should not bury failures under expected provider/startup // diagnostics. Use `--silent=false` when investigating a failing case. silent: true, testTimeout: 30_000, setupFiles: ['./vitest.setup.ts'], pool: 'forks', maxWorkers: 4, include: [ 'packages/*/tests/**/*.test.ts', 'packages/*/tests/**/*.test.tsx', 'packages/*/src/**/*.test.ts', 'tests/**/*.test.ts', 'scripts/**/*.test.ts', 'app/scripts/**/*.test.ts', 'app/tests/**/*.test.ts', ], // INFRA_TEST_SUITES require live Postgres (5434) + Redis (6381); excluded // from the default gate so `npm test` runs green without Docker. Run them // via `npm run test:infra`. exclude: [ 'apps/**', 'node_modules/**', '**/__faza1-closed/**', // Packages outside the community edition: excluded ones (ADR-0002) and // the postponed team runtime (ADR-0003). They are not built either. 'packages/hive-mind-*/**', 'packages/memory-mcp/**', 'packages/wiki-compiler/**', 'packages/team-server/**', 'packages/waggle-dance/**', 'packages/worker/**', 'packages/weaver/**', // Tests of those packages kept outside them; they go with the packages (P2.2). 'packages/agent/tests/hook-packages-runtime.test.ts', 'tests/mcp-context-profile-security.test.ts', 'tests/mcp-import-path-security.test.ts', 'tests/mcp-save-memory-security.test.ts', 'tests/oss-subtree-split.test.ts', ...INFRA_TEST_SUITES, // Copies the ~13MB pre-built packages/marketplace/marketplace.db fixture // (createTempDb). Proper fix: regenerate it from sources-seed.ts in test // setup (P1.6). 'packages/marketplace/tests/sync-verification.test.ts', // Wall-clock budgets run in a dedicated lane so filesystem/process // contention cannot make the deterministic correctness gate flaky. 'packages/server/tests/performance/**', ], coverage: { provider: 'v8', include: ['packages/*/src/**/*.ts'], exclude: ['packages/*/src/**/*.d.ts'], }, }, });