Open najeebarshad opened 4 years ago
Are you sure there's only one copy of React in your storybook bundle? Storybook tends to include one of its own.
There are two copies of react in my node_modules, the one coming from peerDependecies (node_modules/react
) and one inside storybook (node_modules/@storybook/react
). How would this impact storybook?
There can only be one copy of React in the browser at a time, basically. So, you'll need to ensure that your top-level react dep dedupes with everything in your tree.
That makes sense. This concept is new to me however, how should I ensure that only one copy of react is even being loaded?
I have had a look at multiple similar issues but unfortunately haven't able to find anything that solves my problem.
Current behavior
I have unit tests that use Enzyme's
mount
andshallow
. I am importing these tests inside my storybook files, and running them. However I get the errorCannot read property '_reactInternalFiber' of null
in any of my unit tests usingmount
.Shallow
is fine. The weird thing is, if I wrap the unit test calls inside a setTimeout, it works perfectly. Please see some code snippets below to demonstrate what I mean.Please note the code below is very stripped down, I actually have more tests and more parts in my storybook files. But I actually stripped my code down to this level of simplicity and the issue still exists.
component.test.js
component.stories.js
Expected behavior
To not need setTimeout to be able to run unit tests inside storybook.
Your environment
Package.json
API
Version
Adapter