-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
initStoryShots, jest can't parse sample mdx file #14602
Comments
I'm running into this same issue. I printed the underlying stack trace from the error being thrown which contains some more info on where the export is coming from (this is from a What's odd is I have other mdx files in a different directory that have been able to load without any issues. Working on trying to isolate if something in particular is causing it, but this is at least what I found so far.
|
I've had some variation of this for the last month or so, identical environment. I even tried excluding .mdx files entirely, but jest still picks them up |
Spent some time today looking into this with the help of a coworker, and it looks like this broke when the storybook/addons/docs/blocks.js Line 1 in 416944c
This confuses Jest, the storyshots runner, because MDX compiler plugin in Storybook ends up generating ESM flavored javascript importing the "deep" import: storybook/addons/docs/src/mdx/mdx-compiler-plugin.js Lines 461 to 469 in 416944c
...which ends up un-transformed by babel-jest because it lives in There are a few different workarounds; it may be possible to tweak your jest config to transform this storybook module and any which import it so that it's still transpiled. But this seems like a packaging bug, and shouldn't be this way. Will try to see if there's a straightforward patch if I have time. |
@saranrapjs thanks for tracking this down. i've put together a proposed fix at #14769, can you take a look, and ideally add a test case to the monorepo to exercise this change? |
@shilman I wasn't able to find a way to write a test against this, because the behavior that's failing (Jest isn't able to parse MDX generated files) isn't observe-able within Jest tests run within the Storybook repo. Must be some kind of Jest runner/node environment issue. I was able to confirm this change fixes the issue using a kind of more basic tactic, though... running this throws both on your draft branch and on node -e "require('@storybook/addon-docs/blocks')" ...however, on your branch, running this doesn't throw: node -e "require('@storybook/addon-docs')" There's one other thing: I think for your fix to work, the "deep" import path needs to repointed from where it's currently referenced in the MDX compiler. Here's a patch I submitted to your branch with that in place. |
Yee-haw!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.3.0-alpha.18 containing PR #14769 that references this issue. Upgrade today to the
Closing this issue. Please re-open if you think there's still more to do. |
Describe the bug
@storybook/addon-docs/jest-transform-mdx
can't properly transform sample mdx file for jestTo Reproduce
Expected behavior
no error
Error log
System
Environment Info:
System:
OS: macOS 10.15.7
CPU: (8) x64 Intel(R) Core(TM) i5-1038NG7 CPU @ 2.00GHz
Binaries:
Node: 12.20.1 - ~/.nvm/versions/node/v12.20.1/bin/node
Yarn: 1.22.10 - /usr/local/bin/yarn
npm: 6.14.11 - ~/.nvm/versions/node/v12.20.1/bin/npm
Browsers:
Chrome: 89.0.4389.128
Safari: 14.0.3
The text was updated successfully, but these errors were encountered: