Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

<h2>Table of Contents</h2>

Expand Down
12 changes: 11 additions & 1 deletion src/test-storybook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 4 additions & 0 deletions src/util/getStorybookMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -34,5 +37,6 @@ export const getStorybookMetadata = async () => {
lazyCompilation,
disableTelemetry,
enableCrashReports,
frameworkName,
};
};