The dashboard backend (Express routes, services) lives under src/ and is pure Node logic, but every test was paying for jsdom env init plus full CSS-import processing. Split via environmentMatchGlobs so app/** keeps jsdom (React UI) and src/** runs in node by default. Two src tests opt back into jsdom: - status-bar.test.ts uses window.matchMedia. - proxy-routes.test.ts asserts on DOMException constructor.name, which jsdom reports as "AbortError" but node reports as "DOMException". Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
58 lines
2.2 KiB
TypeScript
58 lines
2.2 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: 1 });
|
|
|
|
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 so jsdom-based tests that assert on getComputedStyle
|
|
// see the actual rules from co-located component CSS files.
|
|
css: { include: [/.+/] },
|
|
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/**"],
|
|
},
|
|
},
|
|
});
|