-
Notifications
You must be signed in to change notification settings - Fork 74
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
[Bug] generated testMatch assumes Storybook working dir matches Jest rootDir #133
Comments
I am using yarn with workspaces and I have the stories in a different folder to where storybook is installed (wanting to keep track of my dependencies). When I run
But when I run |
Ok, I ended up ejecting and doing this:
|
🚀 Issue was released in |
Describe the bug
A clear and concise description of what the bug is.
Steps to reproduce the behavior
.storybook
only in one of them, sourcing from all packages.yarn test-runner
from the package that has.storybook
notice only stories in that package get found.rootDir: '../..'
hoping that Jest finds the other stories as well.yarn test-runner
again and notice the absolutetestMatch
paths now end up 2 levels to high.Expected behavior
Test-runner should be able to run any story that the Storybook can build.
Screenshots and/or logs
@yannbf has details.
Environment
Only relevant version is that of
@storybook/test-runner
, which is0.2.0
.Additional context
The assumption that the Storybook working dir matches the Jest rootDir is baked into
test-runner/src/util/getStorybookMetadata.ts
Line 20 in 668e56c
We can fix this by either:
rootDir
value and make the paths relative to that.<rootDir>
and make the paths absolute.The second one might make most sense since Jest will ultimately make them absolute anyway.
However, even if we fix this, Jest isn't really made to run across multiple packages and it's very likely that we run into other issues, like multiple packages defining the same
__mocks__
.An alternative is to use
--stories-json
but that has cons like not having--watch
.Perhaps it's best to consider sourcing stories from other packages a bad-practice (if it isn't already) and steer towards one storybook per package, optionally composed.
The text was updated successfully, but these errors were encountered: