question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Storyshots fails to run, testStorySnapshots is intended only to be used inside jest

See original GitHub issue

After 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:closed
  • Created 6 years ago
  • Comments:5

github_iconTop GitHub Comments

3reactions
axelnormandcommented, Jan 12, 2018

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.

import initStoryshots, {
  multiSnapshotWithOptions,
} from '@storybook/addon-storyshots';

jest.mock('global', () => global);

initStoryshots({
  configPath: 'src/test/Storybook',
  test: multiSnapshotWithOptions({}),
});
0reactions
perjanssoncommented, Oct 30, 2017

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found