Files
waggle-os/apps/web/vitest.config.ts
shumeiko.it 23431550ae build: one tsc -b build and a source export condition (P2.1)
- tsconfig.build.json references the nine in-scope packages; each package
  is composite and references the workspace packages it depends on.
  build:packages is now `tsc -b tsconfig.build.json` instead of a chain
  of cd commands.
- Every in-scope package exports its TypeScript entry under a `source`
  condition next to the dist/ entries. Vitest, tsx (dev:server, the
  Tauri dev launch, the e2e server), the sidecar and launcher bundles and
  the web app resolve it, so none of them needs build:packages first or
  can pick up a stale dist/. The vitest src aliases remain only for the
  excluded packages that have no source export.
- Published packages with a files list (agent, cli, marketplace) pack
  src/ too, so the source condition never points at a missing file.
- tsconfig.tests.json and `npm run typecheck:tests` type-check the test
  suites of the in-scope packages. They report 426 existing errors, so
  the CI step is advisory for now.
- The root test run leaves out the excluded and postponed packages
  (hive-mind-*, memory-mcp, wiki-compiler, team-server, waggle-dance,
  worker, weaver); they are not built either.
- CI runs the test job on Ubuntu, macOS and Windows with Node 22.23.2
  (ADR-0008), and no longer builds the hook runtime and the memory MCP
  server.
2026-10-24 17:14:29 +02:00

35 lines
1.4 KiB
TypeScript

import { defineConfig } from "vitest/config";
import { defaultClientConditions } from "vite";
import react from "@vitejs/plugin-react-swc";
import path from "path";
// React/Vite tests load a Next.js dependency chain that still imports Node's
// deprecated built-in `punycode`; propagate the narrow suppression to Vitest
// workers so expected upstream noise does not hide real test failures.
if (!process.env.NODE_OPTIONS?.includes('--disable-warning=DEP0040')) {
process.env.NODE_OPTIONS = `${process.env.NODE_OPTIONS ?? ''} --disable-warning=DEP0040`.trim();
}
export default defineConfig({
plugins: [react()],
test: {
environment: "jsdom",
globals: true,
setupFiles: ["./src/test/setup.ts"],
include: ["src/**/*.{test,spec}.{ts,tsx}"],
// jsdom environment setup is heavy (~3s/file); under full parallel load the
// event loop starves and render-heavy waitFor/findBy assertions overran the
// default 5s timeout intermittently (every observed failure was a timeout,
// and the failing set varied run-to-run — classic load flakiness, not logic:
// the same tests pass sub-second in isolation). Give generous headroom so the
// suite is deterministic in CI, plus one retry to absorb transient spikes.
testTimeout: 20000,
hookTimeout: 20000,
retry: 1,
},
resolve: {
conditions: ["source", ...defaultClientConditions],
alias: { "@": path.resolve(__dirname, "./src") },
},
});