diff --git a/README.md b/README.md index 1969676..c93b830 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ Storybook test runner turns all of your stories into executable tests. > [!WARNING] -> If you're using Storybook in a Vite-based project, you might want to use [Storybook's Vitest integration](https://storybook.js.org/docs/writing-tests/integrations/vitest-addon?ref=test-runner-migration) instead. It's faster, provides features out of the box such as a11y and coverage, and integrates well with all Storybook's latest features. +> If you're using Storybook in a Vite-based project, you might want to use [Storybook's Vitest integration](https://storybook.js.org/docs/writing-tests/integrations/vitest-addon?ref=test-runner-migration) instead. It's faster, provides features out of the box such as a11y and coverage, and integrates well with all Storybook's latest features. [Read the migration steps here](https://storybook.js.org/docs/writing-tests/integrations/vitest-addon/migration-guide).

Table of Contents

diff --git a/src/test-storybook.ts b/src/test-storybook.ts index bc21563..323a100 100644 --- a/src/test-storybook.ts +++ b/src/test-storybook.ts @@ -421,8 +421,18 @@ const main = async () => { process.env.TEST_MATCH = '**/*.test.js'; } - const { storiesPaths, lazyCompilation, disableTelemetry, enableCrashReports } = + const { storiesPaths, lazyCompilation, disableTelemetry, enableCrashReports, frameworkName } = await getStorybookMetadata(); + + const shouldMigrateToVitest = + frameworkName.includes('vite') || frameworkName.includes('sveltekit'); + + if (shouldMigrateToVitest) { + warnOnce( + 'Detected Vite-based Storybook project: You might benefit from migrating to the Vitest addon. A modern, faster, and more feature-rich testing solution for Storybook:\nhttps://storybook.js.org/docs/writing-tests/integrations/vitest-addon/migration-guide?ref=test-runner-migration' + )(); + } + if (!shouldRunIndexJson) { process.env.STORYBOOK_STORIES_PATTERN = storiesPaths; diff --git a/src/util/getStorybookMetadata.ts b/src/util/getStorybookMetadata.ts index c35d1eb..6896bd8 100644 --- a/src/util/getStorybookMetadata.ts +++ b/src/util/getStorybookMetadata.ts @@ -24,6 +24,9 @@ export const getStorybookMetadata = async () => { const lazyCompilation = !!main.core?.builder?.options?.lazyCompilation; + const frameworkName = + main.framework && typeof main.framework === 'string' ? main.framework : main.framework?.name; + const { disableTelemetry, enableCrashReports } = main.core || {}; return { @@ -34,5 +37,6 @@ export const getStorybookMetadata = async () => { lazyCompilation, disableTelemetry, enableCrashReports, + frameworkName, }; };