|
| 1 | +import path from 'node:path'; |
| 2 | +import { fileURLToPath } from 'node:url'; |
| 3 | + |
| 4 | +import { storybookTest } from '@storybook/experimental-addon-test/vitest-plugin'; |
| 5 | +import { nodePolyfills } from 'vite-plugin-node-polyfills'; |
| 6 | +import { defineWorkspace } from 'vitest/config'; |
| 7 | + |
| 8 | +const dirname = typeof __dirname !== 'undefined' ? __dirname : path.dirname(fileURLToPath(import.meta.url)); |
| 9 | + |
| 10 | +// More info at: https://storybook.js.org/docs/writing-tests/test-addon |
| 11 | +export const config = defineWorkspace([ |
| 12 | + 'vite.config.mts', |
| 13 | + { |
| 14 | + extends: 'vite.config.mts', |
| 15 | + plugins: [ |
| 16 | + // The plugin will run tests for the stories defined in your Storybook config |
| 17 | + // See options at: https://storybook.js.org/docs/writing-tests/test-addon#storybooktest |
| 18 | + storybookTest({ configDir: path.join(dirname, '.storybook') }), |
| 19 | + nodePolyfills({ |
| 20 | + // // To exclude specific polyfills, add them to this list. Note: if include is provided, this has no effect |
| 21 | + // exclude: [ |
| 22 | + // 'http', // Excludes the polyfill for `http` and `node:http`. |
| 23 | + // ], |
| 24 | + // Whether to polyfill specific globals. |
| 25 | + globals: { |
| 26 | + Buffer: true, // can also be 'build', 'dev', or false |
| 27 | + global: true, |
| 28 | + process: true, |
| 29 | + }, |
| 30 | + // To add only specific polyfills, add them here. If no option is passed, adds all polyfills |
| 31 | + include: ['path', 'util'], |
| 32 | + // // Override the default polyfills for specific modules. |
| 33 | + // overrides: { |
| 34 | + // // Since `fs` is not supported in browsers, we can use the `memfs` package to polyfill it. |
| 35 | + // fs: 'memfs', |
| 36 | + // }, |
| 37 | + // // Whether to polyfill `node:` protocol imports. |
| 38 | + // protocolImports: false, |
| 39 | + }), |
| 40 | + ], |
| 41 | + test: { |
| 42 | + browser: { |
| 43 | + enabled: true, |
| 44 | + headless: true, |
| 45 | + name: 'chromium', |
| 46 | + provider: 'playwright', |
| 47 | + }, |
| 48 | + name: 'storybook', |
| 49 | + setupFiles: ['.storybook/vitest.setup.ts'], |
| 50 | + }, |
| 51 | + }, |
| 52 | +]); |
0 commit comments