[Bug]: Storybook 9 - Error messages are unclear when stories cannot be transformed #31128
Labels
addon: test
bug
internal-qa
This issue was reported by the Storybook team, potentially on unreleased or prerelease software.
needs triage
Milestone
Describe the bug
Sometimes projects might have wrong setup (e.g. Svelte files are written incorrectly as can be seen in this repro)
And then Vitest is not able to produce test suites. The Storybook Vitest addon has a setup file that includes an

afterEach
call, which in such cases will fail as it cannot be attached to an actual test suite. However, from the error message it seems that it's a bug in Vitest, which is not necessarily the case:The other side effect is that the source in the error message is not useful, as it relates to the internal setup file from the Storybook Vitest addon. If that code didn't execute, this is how things would look like, which is much better in context:
There are two things we can do:
afterEach
call into the transformed file. By moving it, we make it so that the afterEach is not executed when the file is not transformed, and therefore the stack trace will include a more accurate source where the code failedReproduction link
Reproduction steps
No response
System
Additional context
No response
The text was updated successfully, but these errors were encountered: