fix(test): vitest 4 projects + src/web jsdom env #59
@@ -37,5 +37,6 @@ export default defineConfig({
|
|||||||
environment: 'jsdom',
|
environment: 'jsdom',
|
||||||
globals: true,
|
globals: true,
|
||||||
setupFiles: ['./tests/setup.ts'],
|
setupFiles: ['./tests/setup.ts'],
|
||||||
|
include: ['tests/**/*.test.{ts,tsx}'],
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
14
src/web/vitest.config.ts
Normal file
14
src/web/vitest.config.ts
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
/// <reference types="vitest/config" />
|
||||||
|
import { defineProject } from 'vitest/config';
|
||||||
|
import react from '@vitejs/plugin-react';
|
||||||
|
|
||||||
|
export default defineProject({
|
||||||
|
plugins: [react()],
|
||||||
|
test: {
|
||||||
|
name: 'web',
|
||||||
|
include: ['tests/**/*.test.{ts,tsx}'],
|
||||||
|
environment: 'jsdom',
|
||||||
|
globals: true,
|
||||||
|
setupFiles: ['./tests/setup.ts'],
|
||||||
|
},
|
||||||
|
});
|
||||||
@@ -9,8 +9,20 @@ export default defineConfig({
|
|||||||
exclude: ['**/node_modules/**', '**/dist/**', '**/*.config.*'],
|
exclude: ['**/node_modules/**', '**/dist/**', '**/*.config.*'],
|
||||||
},
|
},
|
||||||
include: ['src/*/tests/**/*.test.ts', 'tests/**/*.test.ts'],
|
include: ['src/*/tests/**/*.test.ts', 'tests/**/*.test.ts'],
|
||||||
exclude: ['**/node_modules/**', '**/smoke/**', 'src/db/tests/**'],
|
// src/web tests need jsdom; they're run via the web package's own
|
||||||
|
// vitest.config.ts under the projects entry below.
|
||||||
|
exclude: ['**/node_modules/**', '**/smoke/**', 'src/db/tests/**', 'src/web/tests/**'],
|
||||||
testTimeout: 10000,
|
testTimeout: 10000,
|
||||||
|
// Vitest 4 uses `projects` (in-config) instead of vitest.workspace.ts.
|
||||||
|
// Each project below is rooted in a workspace package; vitest reads
|
||||||
|
// its `vitest.config.ts` (or vite.config.ts) for the test config.
|
||||||
|
projects: [
|
||||||
|
'src/shared',
|
||||||
|
'src/cli',
|
||||||
|
'src/mcpd',
|
||||||
|
'src/mcplocal',
|
||||||
|
'src/web',
|
||||||
|
],
|
||||||
// DB tests require a test database; run them explicitly via:
|
// DB tests require a test database; run them explicitly via:
|
||||||
// pnpm --filter db exec vitest run
|
// pnpm --filter db exec vitest run
|
||||||
// globalSetup: ['src/db/tests/global-setup.ts'],
|
// globalSetup: ['src/db/tests/global-setup.ts'],
|
||||||
|
|||||||
@@ -6,4 +6,8 @@ export default defineWorkspace([
|
|||||||
'src/cli',
|
'src/cli',
|
||||||
'src/mcpd',
|
'src/mcpd',
|
||||||
'src/mcplocal',
|
'src/mcplocal',
|
||||||
|
// src/web has its own vite.config.ts with `environment: 'jsdom'` —
|
||||||
|
// listing it here makes the workspace runner pick that up so the
|
||||||
|
// browser-y tests get the right globals (localStorage, document).
|
||||||
|
'src/web',
|
||||||
]);
|
]);
|
||||||
|
|||||||
Reference in New Issue
Block a user