Skip to content

[Bug]: Storybook 9 - Error messages are unclear when stories cannot be transformed #31128

Open
@yannbf

Description

@yannbf

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:
Image

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:

Image

There are two things we can do:

  1. 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
  2. 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

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions