import path from 'node:path'; import { fileURLToPath } from 'node:url'; import { defineConfig } from 'vitest/config'; import react from '@vitejs/plugin-react'; const rootDir = path.dirname(fileURLToPath(import.meta.url)); export default defineConfig({ plugins: [react()], resolve: { alias: { '@': path.resolve(rootDir, 'src'), /* The showcase's own root, mirroring `showcase/vite.config.ts` and `showcase/tsconfig.json`. Only its one test file needs it, but a test has to compile the same way the app does. */ '~': path.resolve(rootDir, 'showcase/src'), }, }, test: { globals: true, environment: 'jsdom', setupFiles: ['./test/setup.ts'], /* Per-component tests sit next to the component; test/ holds the suites that cut across the whole kit (the axe smoke run). The showcase is not part of the published package and carries exactly one test — `showcase/src/chrome/lib/prop-params.test.ts`, the share link's codec, which is the one piece of it that could break without anything failing. */ include: [ 'src/**/*.test.{ts,tsx}', 'test/**/*.test.{ts,tsx}', 'showcase/src/**/*.test.{ts,tsx}', ], /* Was `false`, which is still the effective setting for every stylesheet: with no `exclude`/`include` match, Vitest replaces the module with an empty string, and no test asserts on a compiled rule. The one exception is `tokens.css?raw`, which is not a stylesheet import at all — `showcase/src/chrome/lib/token-values.ts` reads the file as *text* to recover the hex comments the CSSOM drops. Vitest decides what is CSS from the id alone (`/\.css($|\?)/`), so `?raw` was being blanked too and the token table arrived empty. Naming it here hands the request back to Vite, which resolves `?raw` to the file's contents. */ css: { include: [/tokens\.css/] }, }, });