Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
yannbf opened this issue Apr 15, 2025 · 0 comments
Labels
addon: test bug internal-qa This issue was reported by the Storybook team, potentially on unreleased or prerelease software. needs triage

Comments

@yannbf
Copy link
Member

yannbf commented Apr 15, 2025

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

@yannbf yannbf added addon: test bug internal-qa This issue was reported by the Storybook team, potentially on unreleased or prerelease software. needs triage labels Apr 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addon: test bug internal-qa This issue was reported by the Storybook team, potentially on unreleased or prerelease software. needs triage
Projects
None yet
Development

No branches or pull requests

1 participant