2025-11-23 10:55:04 +08:00
|
|
|
import { defineConfig } from "vitest/config";
|
2025-12-01 07:22:08 +08:00
|
|
|
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));
|
2025-11-23 10:55:04 +08:00
|
|
|
|
2025-12-01 07:22:08 +08:00
|
|
|
// More info at: https://storybook.js.org/docs/next/writing-tests/integrations/vitest-addon
|
2025-11-23 10:55:04 +08:00
|
|
|
export default defineConfig({
|
|
|
|
|
test: {
|
|
|
|
|
environment: "jsdom",
|
|
|
|
|
globals: true,
|
|
|
|
|
include: ["src/**/*.test.ts", "src/**/*.test.tsx"],
|
2025-12-01 07:22:08 +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']
|
|
|
|
|
}
|
|
|
|
|
}]
|
|
|
|
|
}
|
|
|
|
|
});
|