* test(coverage): bootstrap vitest unit infra and add tests at 90%+ per file (#1245) Establishes the unit-test runtime AGENTS.md mandates: a vitest "unit" project alongside the existing storybook project, RTL + jest-dom + happy-dom, a Mantine-aware render helper, and a 90%-line per-file coverage gate enforced by CI. Adds 66 test files covering all 62 components under elements/groups/screens/views, plus core/mcp and clients/web/src/utils. Total: 577 tests, 98.7% line coverage globally. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * test(coverage): address PR #1269 review feedback - AGENTS.md: correct coverage gate description (lines ≥ 90, statements ≥ 85, functions ≥ 80, branches ≥ 50) with rationale for the relaxed branch threshold - InspectorView.test.tsx: document what the Math.random() mock values (0.1 / 0.99) control vs. STUB_SUCCESS_RATE in InspectorView.tsx - vite.config.ts / tsconfig.test.json: drop unused `globals: true` and the `vitest/globals` type now that every test file imports describe/it/expect/vi explicitly; manual `afterEach(cleanup)` in setup.ts remains required because testing-library auto-cleanup relies on globalThis.afterEach Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
64a42e645b
commit
75f74d64c1
1 changed files with 8117 additions and 30 deletions
|
|
@ -17,27 +17,75 @@ export default defineConfig({
|
|||
'@inspector/core': path.resolve(dirname, '../../core'),
|
||||
},
|
||||
},
|
||||
server: {
|
||||
fs: {
|
||||
allow: [path.resolve(dirname, '../..')],
|
||||
},
|
||||
},
|
||||
test: {
|
||||
projects: [{
|
||||
extends: true,
|
||||
plugins: [
|
||||
// The plugin will run tests for the stories defined in your Storybook config
|
||||
// See options at: https://storybook.js.org/docs/next/writing-tests/integrations/vitest-addon#storybooktest
|
||||
storybookTest({
|
||||
configDir: path.join(dirname, '.storybook')
|
||||
})],
|
||||
test: {
|
||||
name: 'storybook',
|
||||
browser: {
|
||||
enabled: true,
|
||||
headless: true,
|
||||
provider: playwright({}),
|
||||
instances: [{
|
||||
browser: 'chromium'
|
||||
}]
|
||||
coverage: {
|
||||
provider: 'v8',
|
||||
reporter: ['text', 'html', 'json-summary'],
|
||||
include: [
|
||||
'src/components/**/*.{ts,tsx}',
|
||||
'src/utils/**/*.{ts,tsx}',
|
||||
'../../core/mcp/**/*.{ts,tsx}',
|
||||
],
|
||||
exclude: [
|
||||
'**/*.stories.{ts,tsx}',
|
||||
'**/*.test.{ts,tsx}',
|
||||
'**/*.fixtures.{ts,tsx}',
|
||||
'**/index.{ts,tsx}',
|
||||
'src/components/**/types.ts',
|
||||
'../../core/mcp/types.ts',
|
||||
'../../core/mcp/elicitationCreateMessage.ts',
|
||||
],
|
||||
thresholds: {
|
||||
perFile: true,
|
||||
lines: 90,
|
||||
statements: 85,
|
||||
functions: 80,
|
||||
branches: 50,
|
||||
},
|
||||
},
|
||||
projects: [
|
||||
{
|
||||
extends: true,
|
||||
test: {
|
||||
name: 'unit',
|
||||
environment: 'happy-dom',
|
||||
// No `globals: true` — every test file imports `describe`, `it`,
|
||||
// `expect`, `vi` explicitly from "vitest". This keeps the pattern
|
||||
// consistent and avoids relying on auto-cleanup tied to Vitest's
|
||||
// global lifecycle hooks; cleanup is invoked manually in setup.ts.
|
||||
include: ['src/**/*.test.{ts,tsx}'],
|
||||
setupFiles: ['./src/test/setup.ts'],
|
||||
},
|
||||
setupFiles: ['.storybook/vitest.setup.ts']
|
||||
}
|
||||
}]
|
||||
}
|
||||
});
|
||||
},
|
||||
{
|
||||
extends: true,
|
||||
plugins: [
|
||||
// The plugin will run tests for the stories defined in your Storybook config
|
||||
// See options at: https://storybook.js.org/docs/next/writing-tests/integrations/vitest-addon#storybooktest
|
||||
storybookTest({
|
||||
configDir: path.join(dirname, '.storybook'),
|
||||
}),
|
||||
],
|
||||
test: {
|
||||
name: 'storybook',
|
||||
browser: {
|
||||
enabled: true,
|
||||
headless: true,
|
||||
provider: playwright({}),
|
||||
instances: [
|
||||
{
|
||||
browser: 'chromium',
|
||||
},
|
||||
],
|
||||
},
|
||||
setupFiles: ['.storybook/vitest.setup.ts'],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue