// The test runner the two screen workspaces (frontend/, dashboard/) share: // vitest under jsdom with testing-library, run by the root `test:unit`, so the // product's one test command covers the screens too. export const UI_TEST_DEV_DEPENDENCIES = { "@testing-library/jest-dom": "^6.9.1", "@testing-library/react": "^16.3.2", jsdom: "^29.0.1", vitest: "^4.1.3", }; // Like vite.config.ts, kept out of the tsconfig `include`: it imports the // bundler. export const VITEST_CONFIG_TS = `import { createRequire } from "node:module"; import { dirname } from "node:path"; import react from "@vitejs/plugin-react"; import { defineConfig } from "vitest/config"; // One React instance: alias to the pair react-dom loads, so testing-library // cannot pull in a second copy (every hook then throws). const require = createRequire(import.meta.url); export default defineConfig({ plugins: [react()], resolve: { alias: { react: dirname(require.resolve("react")), "react-dom": dirname(require.resolve("react-dom")) }, dedupe: ["react", "react-dom"], }, test: { include: ["src/**/*.test.{ts,tsx}"], environment: "jsdom", setupFiles: ["./src/test/setup.ts"], }, }); `; // Without vitest globals, testing-library cannot register its own cleanup, so // renders would pile up across tests in one document. export const TEST_SETUP_TS = `import "@testing-library/jest-dom/vitest"; import { cleanup } from "@testing-library/react"; import { afterEach } from "vitest"; afterEach(cleanup); `;