Open
Description
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:
- Add an FAQ entry to the docs, to make it clear to the user that it might not be a bug in Vitest, and that they need to investigate other logs that preceded that message
- Move the
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 failed
Reproduction link
Reproduction steps
No response
System
-
Additional context
No response
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
No status