Describe the bug
I'm creating a library with create-react-library package, but this error occur with the create-react-app too. When I follow the tutorial storybook works fine, but when I
To Reproduce
Steps to reproduce the behavior:
import initStoryshots from '@storybook/addon-storyshots';
initStoryshots();
import { configure } from '@storybook/react';
import requireContext from 'require-context.macro';
import '../src/index.css';
const req = requireContext('../src/components', true, /\.stories\.js$/);
function loadStories() {
req.keys().forEach(filename => req(filename));
}
configure(loadStories, module);
MacroError: The macro you imported from "undefined" is being executed outside the context of compilation with babel-plugin-macros. This indicates that you don't have the babel plugin "babel-plugin-macros" configured correctly. Please see the documentation for how to configure babel-plugin-macros properly: https://github.com/kentcdodds/babel-plugin-macros/blob/master/other/docs/user.md
Expected behavior
I expected to execute the tests and show if they works or no, and show storybook page with my stories.
Code snippets
I upload the complete code
https://github.com/ArmandoAA/storybook-error-with-snapshot-tests
System:
Same thing here, also raised an issue in require-context.macrosince it seems to be the only thing that changed in the previous working code: https://github.com/storybookjs/require-context.macro/issues/3
Hey guys, try this:
babel-plugin-macros --> yarn add babel-plugin-macros.babelrc to root folder with {
"plugins": ["macros"]
}
See if it works
@halian-vilela it works with perfectly with your solution
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!
I have a PR running on this issue, maybe it will make it clear if went directly into the docs. Looking forward for it to be merged.
This works for me, thanks
Most helpful comment
Hey guys, try this:
babel-plugin-macros-->yarn add babel-plugin-macros.babelrcto root folder withSee if it works