storybook: [Bug]: (vitest integration) `test.include` should not be ignored
Describe the bug
About removing test.include here,
One drawback is then user can’t run non-storybook tests. i.e. user may have test in .test.ts which uses import { render } from 'vitest-browser-react' to write unit tests. Those needs to be included by Vitest in test.include.
I believe many users will be on the same boat as they migrate their existing projects to use Storybook to replace current tests.
Reproduction link
Reproduction steps
It is described in the migration guide: https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#addon-test-indexing-behavior-of-storybookexperimental-addon-test-is-changed
System
Storybook Environment Info:
System:
OS: Linux 5.15 Ubuntu 24.04.1 LTS 24.04.1 LTS (Noble Numbat)
CPU: (16) x64 AMD Ryzen 7 5800X 8-Core Processor
Shell: 5.9 - /usr/bin/zsh
Binaries:
Node: 20.18.0 - /run/user/1000/fnm_multishells/720_1737231505770/bin/node
npm: 10.8.2 - /run/user/1000/fnm_multishells/720_1737231505770/bin/npm
pnpm: 9.12.2 - /run/user/1000/fnm_multishells/720_1737231505770/bin/pnpm <----- active
Additional context
No response
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 4
- Comments: 23 (17 by maintainers)
Commits related to this issue
- chore: sb 8.5 blocked by: https://github.com/storybookjs/storybook/issues/30307 — committed to repobuddy/visual-testing by unional 2 years ago
- chore: sb 8.5 blocked by: https://github.com/storybookjs/storybook/issues/30307 — committed to repobuddy/visual-testing by unional 2 years ago
Not only for Storybook Test UI. Running
vitest runwill use thevitest.config.tsthat uses browser mode and withstorybookTest(). The current behavior does prevent the tests written in.test.tsxfrom being executed.Technically you can create two Vitest configs. One run in browser mode without
storybookTest()and one in browser mode with, but that would complicate the configuration unnecessary as now you need to have two different scripts and/or using Vitest workspace.It also make thing more flaky as running multiple instance of browsers causes test timeouts both locally and in CI.
Render tests written in
.test.tsxand in.stories.tsxshould run together as they are both testing rendering and interactions (and run on browser).Thing would be even more complicate if user runs multiple instances of different browsers. Everything has to be duplicated.
Hey @unional, I will take a deeper look into this use case, and will get back to this issue later!
@unional I’ll discuss with @valentinpalkovic on Monday and see what we can do. Sorry for blocking!
Happy to open a separate issue for my comment, but I think it’s ultimately the same: ignoring
test.includemakes it unclear how to use the Vitest test addon with Vitest Workspace. I have a project with multiple kinds of test files and I want the Storybook test addon to only apply to a subset of the test files (i.e. the story files). I use the followingvitest.workspace.tsfile:I’ve had no issues with this configuration in Storybook < 8.5. Ignoring
test.includein 8.5 changes the behavior of the Vitest configuration, though. Even if thestorybookTestplugin has no effect on non-story files, it still runs when I want to run non-storybook tests (e.g.pnpm vitest --project=utilities). Moreover, the warning added in https://github.com/storybookjs/storybook/commit/c385838557a30793de90759a1f53907fbe81cc86 only stops printing when I remove all 3test.includefrom the workspace file (again, becausestorybookTestis running for each project in the workspace, instead of just the first one), but removingtest.includedefeats the purpose of the workspace feature (separate Vitest configurations for separate subsets of files).