/// import { defineConfig } from 'vite'; import react from '@vitejs/plugin-react'; // https://vite.dev/config/ import path from 'node:path'; import { fileURLToPath } from 'node:url'; import { storybookTest } from '@storybook/addon-vitest/vitest-plugin'; import { playwright } from '@vitest/browser-playwright'; const dirname = typeof __dirname !== 'undefined' ? __dirname : path.dirname(fileURLToPath(import.meta.url)); // More info at: https://storybook.js.org/docs/next/writing-tests/integrations/vitest-addon export default defineConfig({ plugins: [react()], resolve: { alias: { '@inspector/core': path.resolve(dirname, '../../core'), }, }, server: { fs: { allow: [path.resolve(dirname, '../..')], }, }, test: { 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'], }, }, { 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'], }, }, ], }, });