Merges FN-3470 in two steps: first, runtime plugins now prefer source path aliases over build artifacts, with hardening tests for vitest alias resolution and plugin view registry updates; second, a new `ensure-test-artifacts.mjs` bootstrap script guarantees required test files exist before test runs Fusion-Task-Id: FN-3470
79 lines
3.1 KiB
TypeScript
79 lines
3.1 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"),
|
|
"@fusion-plugin-examples/droid-runtime/probe": resolve(
|
|
__dirname,
|
|
"../../plugins/fusion-plugin-droid-runtime/src/probe.ts",
|
|
),
|
|
"@fusion-plugin-examples/droid-runtime": resolve(
|
|
__dirname,
|
|
"../../plugins/fusion-plugin-droid-runtime/src/index.ts",
|
|
),
|
|
"@fusion-plugin-examples/hermes-runtime": resolve(
|
|
__dirname,
|
|
"../../plugins/fusion-plugin-hermes-runtime/src/index.ts",
|
|
),
|
|
"@fusion-plugin-examples/openclaw-runtime": resolve(
|
|
__dirname,
|
|
"../../plugins/fusion-plugin-openclaw-runtime/src/index.ts",
|
|
),
|
|
"@fusion-plugin-examples/paperclip-runtime": resolve(
|
|
__dirname,
|
|
"../../plugins/fusion-plugin-paperclip-runtime/src/index.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/**"],
|
|
},
|
|
},
|
|
});
|