Storyshots fails to run, testStorySnapshots is intended only to be used inside jest
See original GitHub issueAfter updating to latest version of jest initStoryshots() fails:
Test suite failed to run
testStorySnapshots is intended only to be used inside jest
at testStorySnapshots (node_modules/@storybook/addon-storyshots/dist/index.js:114:11)
I’m not sure if this is due to jest update since we went from version 19.x to 21.x.
From package.json:
"@storybook/addon-storyshots": "^3.2.12"
"@storybook/react": "^3.2.12"
"babel-jest": "^21.2.0"
"jest": "^21.2.1"
__ test __/storyshots.test.js
import initStoryshots from '@storybook/addon-storyshots';
initStoryshots();
When I check inside index.js:114:11 the _global is empty object {}.
Issue Analytics
- State:
- Created 6 years ago
- Comments:5
Top Results From Across the Web
hypnosphi/addon-storyshots - Storybook
StoryShots is a Jest Snapshot Testing Addon for Storybook. ... To use StoryShots, you must use your existing Storybook stories as the input...
Read more >Storybook Addon StoryShots for Angular 12 - Stack Overflow
As I kept Karma/Jasmine for unit testing (bigger community), Jest is only for snapshots tests with Storybook , so my jest.config.js is under...
Read more >Jest Output Is Not Rendered As Expected In Storybook
setupFile.js < this will run before the tests in jest. import ... When I run jest storyshots says testStorySnapshots is intended only to...
Read more >@storybook/addon-storyshots - npm
Take a code snapshot of every story automatically with Jest. Latest version: 6.5.15, last published: 4 days ago. Start using ...
Read more >How to use the @storybook/addons.setChannel function in ...
Use Snyk Code to scan source code in minutes - no build needed - and fix issues ... new Error('testStorySnapshots is intended only...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I too had this with react native. Anyone have any ideas?
My fix was to jest.mock global so the require global in storyshots got the real jest global.
As mentioned by @florian-bd it was due to a configuration issue in our project, and as we tried setting up a minimal project with webpack, jest, storybook and storyshots it worked well. So, closing this issue.