buster/apps/web-tss/vitest.config.ts

105 lines
2.8 KiB
TypeScript
Raw Normal View History

2025-08-13 12:05:05 +08:00
/// <reference types="vitest/config" />
2025-08-13 12:37:41 +08:00
/// <reference types="vitest/config" />
import path, { resolve } from 'node:path';
2025-08-13 12:05:05 +08:00
import { fileURLToPath } from 'node:url';
import { storybookTest } from '@storybook/addon-vitest/vitest-plugin';
2025-08-13 12:37:41 +08:00
import tsconfigPaths from 'vite-tsconfig-paths';
import { defineConfig } from 'vitest/config';
const dirname =
typeof __dirname !== 'undefined' ? __dirname : path.dirname(fileURLToPath(import.meta.url));
2025-08-12 11:28:36 +08:00
2025-08-13 12:05:05 +08:00
// More info at: https://storybook.js.org/docs/next/writing-tests/integrations/vitest-addon
2025-08-12 11:28:36 +08:00
export default defineConfig({
2025-08-13 12:37:41 +08:00
plugins: [
tsconfigPaths({
root: resolve(__dirname),
projects: [resolve(__dirname, 'tsconfig.json')],
}) as unknown as Plugin,
],
2025-08-12 11:28:36 +08:00
esbuild: {
2025-08-13 12:37:41 +08:00
jsx: 'automatic',
2025-08-12 11:28:36 +08:00
},
test: {
globals: true,
2025-08-13 12:05:05 +08:00
environment: 'jsdom',
// For React components
2025-08-13 03:21:24 +08:00
setupFiles: ['./vitest.setup.ts'],
pool: 'forks',
2025-08-12 11:28:36 +08:00
poolOptions: {
forks: {
maxForks: process.env.CI ? 1 : 8,
2025-08-13 12:37:41 +08:00
minForks: process.env.CI ? 1 : 8,
},
2025-08-12 11:28:36 +08:00
},
2025-08-13 03:21:24 +08:00
include: ['**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
2025-08-13 12:37:41 +08:00
exclude: [
'**/node_modules/**',
'**/dist/**',
'**/.next/**',
'**/playwright-tests/**',
'**/coverage/**',
],
2025-08-12 11:28:36 +08:00
coverage: {
2025-08-13 03:21:24 +08:00
provider: 'v8',
reporter: ['text', 'json', 'html'],
2025-08-13 12:37:41 +08:00
exclude: [
'coverage/**',
'dist/**',
'**/node_modules/**',
'**/[.]**',
'packages/*/test{,s}/**',
'**/*.d.ts',
'**/virtual:*',
'**/__x00__*',
'**/\x00*',
'cypress/**',
'test{,s}/**',
'test{,-*}.{js,cjs,mjs,ts,tsx,jsx}',
'**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx}',
'**/*{.,-}spec.{js,cjs,mjs,ts,tsx,jsx}',
'**/tests/**',
'**/__tests__/**',
'**/.{eslint,mocha,prettier}rc.{js,cjs,yml}',
'**/vitest.{workspace,projects}.[jt]s?(on)',
'**/vitest.config.[jt]s',
'**/playwright.config.[jt]s',
'**/.storybook/**',
'**/storybook-static/**',
],
2025-08-13 11:54:24 +08:00
},
2025-08-13 12:37:41 +08:00
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',
},
],
},
setupFiles: ['.storybook/vitest.setup.ts'],
2025-08-13 12:05:05 +08:00
},
2025-08-13 12:37:41 +08:00
},
],
2025-08-12 11:28:36 +08:00
},
css: {
postcss: {
2025-08-13 12:37:41 +08:00
plugins: [],
},
},
});