storybook: Storyshots afterAll is not defined error

Describe the bug

ReferenceError: afterAll is not defined
    at Object.<anonymous> (/Users/himanshu/Desktop/headout/aer/node_modules/jest-specific-snapshot/dist/index.js:28:1)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/Users/himanshu/Desktop/headout/aer/node_modules/@storybook/addon-storyshots/dist/test-bodies.js:9:1)

To Reproduce Boilerplate of code.

https://github.com/himanshu-dixit/storybook-mock-setup

Expected behavior Should run the test

Screenshots If applicable, add screenshots to help explain your problem.

Code snippets If applicable, add code samples to help explain your problem.

System: Please paste the results of npx -p @storybook/cli@next sb info here.

Additional context Add any other context about the problem here.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 15 (3 by maintainers)

Most upvoted comments

Hey there, it’s me again! I am going close this issue to help our maintainers focus on the current development roadmap instead. If the issue mentioned is still a concern, please open a new ticket and mention this old one. Cheers and thanks for using Storybook!

I just ran into this and it took me a little bit to figure it out. Essentially, you can’t add @storybook/addon-storyshots to your list of addons in .storybook/main.js because it doesn’t have Jest globals available. Instead, you just create the test files and then run Jest and it generates the storyshot files.

I’m not exactly sure why this is called an “addon” if it can’t be added to that addon list.

This is still happening:


    ReferenceError: afterAll is not defined

      1 | import registerRequireContextHook from 'babel-plugin-require-context-hook/register';
    > 2 | import initStoryshots from '@storybook/addon-storyshots';
        |                                               ^
      3 |
      4 | registerRequireContextHook();
      5 | initStoryshots();

      at Object.<anonymous> (node_modules/jest-specific-snapshot/dist/index.js:28:1)
      at Object.<anonymous> (node_modules/@storybook/addon-storyshots/dist/test-bodies.js:9:1)
      at Object.<anonymous> (node_modules/@storybook/addon-storyshots/dist/api/ensureOptionsDefaults.js:10:19)
      at Object.<anonymous> (node_modules/@storybook/addon-storyshots/dist/api/index.js:12:53)
      at Object.<anonymous> (node_modules/@storybook/addon-storyshots/dist/index.js:52:35)
      at Object.<anonymous> (storybook/test/jest.setup.js:2:47)