storybook: Storyshots is leaking memory
Bug or support request summary
Bug
Steps to reproduce
See https://github.com/SimenB/storyshots-leak for example, but every single installation of storyshots (at least for React, haven’t tested others) should reproduce without issue following the steps in the linked README.
To satisfy template:
- Install and setup storyshots
- Run jest
- See leakage either through Jest’s builtin capabilities (
logHeapUsageanddetectLeaks) or using some OS tool to see memory usage.
Please specify which version of Storybook and optionally any affected addons that you’re running
"@storybook/addon-storyshots": "^3.3.15",
"@storybook/react": "^3.3.15",
Affected platforms
- Jest@22.4.3
Screenshots / Screencast / Code Snippets (Optional)

(A bonus would be to remove the info => Loading custom .babelrc text…)
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 17
- Comments: 15 (5 by maintainers)
I’ve ran into this issue too and while waiting for the fix, we fixed it by mocking @storybook/core/server. This solution was inspired by https://github.com/storybookjs/storybook/issues/3286#issuecomment-595011324 Thank you @jrmurad
jest.mock('@storybook/core/server', () => ({ toRequireContext: require('@storybook/core/dist/server/preview/to-require-context').toRequireContext }));Also here is a great article that helped me a lot finding memory leaks : https://chanind.github.io/javascript/2019/10/12/jest-tests-memory-leak.html
This is now causing issues for our workflow as well. We were unable to upgrade our storybook dependencies (including storyshots) from version 5.2.6 to 5.3.18 as our jest run would just fail with memory allocation errors.