Local single-package runs were single-threaded due to defaultCap: 1; bump to 3 so iterative `pnpm --filter @fusion/dashboard test` actually uses available cores (workspace runs still clamp via FUSION_TEST_TOTAL_WORKERS). CSS transform was applied to every file via /.+/ but only jsdom-environment tests under app/** read computed styles. Restrict include to /app\// so node-env src/** tests skip the CSS pipeline. Wall time on the dashboard suite drops from ~205s to ~148s (-28%). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
59 lines
2.3 KiB
TypeScript
59 lines
2.3 KiB
TypeScript
import { defineConfig } from "vitest/config";
|
|
import react from "@vitejs/plugin-react";
|
|
import { resolve } from "node:path";
|
|
import { computeMaxWorkers } from "../core/src/__test-utils__/vitest-workers";
|
|
|
|
const maxWorkers = computeMaxWorkers({ defaultCap: 3 });
|
|
|
|
export default defineConfig({
|
|
plugins: [react()],
|
|
resolve: {
|
|
alias: {
|
|
"@fusion/core": resolve(__dirname, "../core/src/index.ts"),
|
|
"@fusion/engine": resolve(__dirname, "../engine/src/index.ts"),
|
|
"@fusion/plugin-sdk": resolve(__dirname, "../plugin-sdk/src/index.ts"),
|
|
"@fusion/test-utils": resolve(__dirname, "../core/src/__test-utils__/workspace.ts"),
|
|
},
|
|
},
|
|
test: {
|
|
// `app/**` is React UI — needs jsdom + CSS. `src/**` is the Express
|
|
// backend, mostly Node-only logic; running it in node env trims jsdom
|
|
// env+CSS-include cost. The handful of src tests that genuinely need DOM
|
|
// opt-in via `// @vitest-environment jsdom`.
|
|
environment: "node",
|
|
environmentMatchGlobs: [
|
|
["app/**", "jsdom"],
|
|
],
|
|
// Process CSS imports only for jsdom-based tests that assert on
|
|
// getComputedStyle. Node-env tests under src/** don't need CSS rules and
|
|
// skipping the transform there cuts a large slice of total wall time.
|
|
css: { include: [/app\//] },
|
|
globals: true,
|
|
include: ["app/**/*.test.{ts,tsx}", "src/**/*.test.{ts,tsx}"],
|
|
setupFiles: [
|
|
"./src/__tests__/setup-test-isolation.ts",
|
|
resolve(__dirname, "../core/src/__test-utils__/vitest-setup.ts"),
|
|
"./vitest.setup.ts",
|
|
],
|
|
globalSetup: [resolve(__dirname, "../core/src/__test-utils__/vitest-teardown.ts")],
|
|
// Threads share a V8 heap so they're much lighter than forks for jsdom +
|
|
// React suites; forks duplicated the entire renderer per worker (~500MB).
|
|
pool: "threads",
|
|
maxWorkers,
|
|
poolOptions: { threads: { minThreads: 1, maxThreads: maxWorkers } },
|
|
fileParallelism: true,
|
|
isolate: true,
|
|
// Dashboard route and integration-heavy suites can exceed the Vitest
|
|
// 5s default under workspace-concurrent runs.
|
|
testTimeout: 15_000,
|
|
hookTimeout: 15_000,
|
|
coverage: {
|
|
enabled: false,
|
|
reporter: ["text", "html", "json"],
|
|
reportsDirectory: "./coverage",
|
|
include: ["app/**/*.{ts,tsx}", "src/**/*.{ts,tsx}"],
|
|
exclude: ["**/*.test.{ts,tsx}", "**/*.d.ts", "dist/**"],
|
|
},
|
|
},
|
|
});
|