react-native: React Native Storyshots - RangeError: Maximum call stack size exceeded
Describe the bug
When running storyshots the following error occurs. Running the storybook within the app on the device works as expected:
FAIL ./storyshots.test.ts
● Test suite failed to run
RangeError: Maximum call stack size exceeded
at Function.get [Symbol.species] (<anonymous>)
at Array.slice (<anonymous>)
at Resolver.resolveStubModuleName (node_modules/jest-resolve/build/index.js:375:49)
at Symbol (node_modules/core-js/modules/es.symbol.description.js:25:75)
at Symbol (node_modules/core-js/modules/es.symbol.description.js:25:106)
at Symbol (node_modules/core-js/modules/es.symbol.description.js:25:106)
at Symbol (node_modules/core-js/modules/es.symbol.description.js:25:106)
To Reproduce Steps to reproduce the behavior:
- Setup React Native Story book and test
- Add
@storybook/addon-storyshots - Setup
storyshots.test.tsas per README - Run
yarn test
Expected behavior Snapshots to be generated
Code snippets storybook/index.ts
import { getStorybookUI, configure } from '@storybook/react-native';
import { loadStories } from './storyLoader';
configure(() => {
loadStories()
}, module);
configure(loadStories, module);
// Refer to https://github.com/storybooks/storybook/tree/master/app/react-native#start-command-parameters
// To find allowed options for getStorybookUI
const StorybookUIRoot = getStorybookUI({});
export default StorybookUIRoot;
storyshots.test.ts
import initStoryshots from '@storybook/addon-storyshots';
initStoryshots();
button.stories.ts
import { Button } from './Button';
import { storiesOf } from '@storybook/react-native';
storiesOf('Button', module)
.add('Default', () => (<Button title='My Button' color='#fafafa' onPress={null}></Button>
));
System:
- OS: Linux
- Device: NA
- Browser: NA
- Framework: React Native 0.57.8
- Addons: @storybook/addon-storyshots
- Version: 5.1.0-rc.2
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 22 (5 by maintainers)
It’s still an issue 😕
Inline requires changes shouldn’t be needed if you have this in your metro config
This solved the issue for me. But not sure any other thing will be affected by setting
inlineRequire: false. What do you think?For my Expo app, in
metro.config.js:@dannyhw, still having the issue with upgraded packages:
I render my storybook inside the app with a specific route.
App is working as expected. When I navigate to the Storybook route. I got this message. (But I can continue using by dismiss this message)
If I directly render Storybook in App.js (in Expo, this is the root file) like this:
🟢 It is ok.
🔴 But when I want to import both my app and Storybook, it gives the error.
Here I thought:
I can give these details. Appreciate your help. Still trying to solve this issue.
Inline requires is just an optimization disabling it shouldn’t be a problem.