-
-
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
Getting "Cannot use import statement outside a module" with MDX files running with Jest #11376
Comments
Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks! |
@shilman Any update on this? |
Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks! |
Nope, would appreciate if someone else can take a look. @Hypnosphi do you have any ideas? |
@ajkl2533 you also need babel-jest: https://github.com/storybookjs/storybook/tree/next/addons/docs#installation |
I have the same problem when running Jest after enabling the storyshot addon. It can also be reproduced on the 'sb init' project. |
I just discovered this project, so I pretty much don't know what I'm doing. I got this error because my .babel file wasn't in the root directory of the project. I know nothing about Babel, but I'd make sure that's straight. |
@ajkl2533 Did you get this to work with ts-jest ? |
I replaced 1. Install the babel
2. Create the
|
@oxilor this did not fix for me :( |
So we can't use |
I have the latest version of the Storybook and this way still works. |
It appears #13478 was my actual problem. |
I created a repo with configuration that works for me, but in this project storyshots started to include Storybook's stories from node_modules. In my real project it works nice. Unfortunately, I don't have time to deal with this problem. If someone knows how to fix it, let me know. |
The config that @oxilor shared seems to work 🤞 |
My repo's setup to use CSF for Stories with MDX for docs. Because my MDX is only for docs, I don't actually need the MDX for my unit tests so I can just tell Jest to throw it away: jest.config.jsmodule.exports = {
moduleNameMapper: {
'\\.mdx?$': '<rootDir/__mocks__/mdxMock.js',
}
} mocks/mdxMock.jsmodule.exports = {} |
The future of storyshots is the test-runner: And use the play function for expectations: We will not be making any improvement / changes to storyshots. |
As a suggestion, if this is how it will go forward, please update the documentation on your website, as it states that Snapshots is an alternative to Chromatic.
It will be simpler and we won't need to invest time to try and implement it only to have it not work and spend a couple of hours trying to find a solution on search engines. Also, perhaps you can add a notice to the README on Storyshots and archive the repo. |
@ndelangen what about puppeteer integration for visual regression snapshots ? Will it be supported by test-runner approach ? We currently use @storybook/addon-storyshots-puppeteer for the job. |
Describe the bug
When I add MDX documentation files into my Storybook and run Storyshots with Jest I'm getting
SyntaxError: Cannot use import statement outside a module
for each of loaded MDX.Expected behavior
Console should be without errors
Code snippets
System:
The text was updated successfully, but these errors were encountered: