Storybook: Jest 26 compatibility: replace `require.requireActual` with `jest.requireActual`

Created on 3 May 2020  路  12Comments  路  Source: storybookjs/storybook

Describe the bug
Storyshot depends on require.requireActual - this has been removed from Jest 26. Please use jest.requireActual instead.

To Reproduce

  • Install storyshot using Jest 26 (currently alpha, scheduled for release Tuesday or Wednesday this week)
  • Attempt to run it

Expected behavior
Should work

Screenshots
image

Code snippets
N/A

System:
N/A

Additional context
https://github.com/facebook/jest/pull/9854

storyshots compatibility with other tools dependencies todo

Most helpful comment

https://github.com/facebook/jest/releases/tag/v26.0.0

Jest 26 has now been released. Would be great for storyshots to be updated 馃檹

All 12 comments

https://github.com/facebook/jest/releases/tag/v26.0.0

Jest 26 has now been released. Would be great for storyshots to be updated 馃檹

Yee-haw!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.0.0-beta.3 containing PR #10642 that references this issue. Upgrade today to try it out!

You can find this prerelease on the @next NPM tag.

Closing this issue. Please re-open if you think there's still more to do.

@shilman can you please merge the fix also to stable version (v5)? As I assume it will still take some time before v6 becomes stable and this issue block update of jest. Thanks

@jakubriedl ok will try to special-case this

@SimenB do we need to upgrade babel-jest also?

You don't _need_ to upgrade, jest.requireActual has been available since Jest 21 released in 2017.
If you do upgrade though, we recommend upgrading all of Jest's dependencies, including babel-jest

Great Caesar's ghost!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.0.0-beta.4 containing PR #10669 that references this issue. Upgrade today to try it out!

You can find this prerelease on the @next NPM tag.

after upgrading to latest storyshots and jest, jest-cli, and babel-jest (v 26.0.1), I get this error, which I wasn't having before:

    /var/www/html/reactapp/node_modules/node-fetch/lib/index.mjs:1
    import Stream from 'stream';
    ^^^^^^

    SyntaxError: Cannot use import statement outside a module
        at compileFunction (<anonymous>)

      35 | };
      36 | 
    > 37 | initStoryshots({
         | ^
      38 |   framework: 'react',
      39 |   test: multiSnapshotWithOptions({
      40 |     createNodeMock: (node) => document.createElement(node.type),

      at Runtime._execModule (node_modules/jest-runtime/build/index.js:1166:56)
      at Object.<anonymous> (node_modules/@storybook/addon-storyshots/node_modules/@storybook/core/dist/server/build-dev.js:33:41)
      at Object.<anonymous> (node_modules/@storybook/addon-storyshots/node_modules/@storybook/core/server.js:4:18)
      at Object.<anonymous> (node_modules/@storybook/addon-storyshots/dist/frameworks/configure.js:9:16)
      at Object.<anonymous> (node_modules/@storybook/addon-storyshots/dist/frameworks/angular/loader.js:20:35)
      at node_modules/@storybook/addon-storyshots/dist/frameworks/frameworkLoader.js:18:41
          at Array.map (<anonymous>)
      at getLoaders (node_modules/@storybook/addon-storyshots/dist/frameworks/frameworkLoader.js:18:10)
      at Object.loadFramework [as default] (node_modules/@storybook/addon-storyshots/dist/frameworks/frameworkLoader.js:21:19)
      at testStorySnapshots (node_modules/@storybook/addon-storyshots/dist/api/index.js:60:39)
      at Object.<anonymous> (src/storybook/storyshots.test.js:37:1)

I'll try to debug it on my own, but just wondering if anyone else has run into this and if this is something that was introduced or something misconfigured on my end.

I see that it is throwing from node_modules/@storybook/addon-storyshots/dist/frameworks/angular/loader.js:20:35, but I am using React, which was an issue mentioned here: https://github.com/storybookjs/storybook/issues/10455

@shilman did this get into 5.3.19?

@Hypnosphi Not yet. I was just trying to do a quick security fix. Do you want me to get this in to 5.3.20?

Yes please

Are there still plans to fix this in 5.3.20?

@liamkeily Unfortunately it was not trivial to back port it, so I put the energy into shipping 6.0 instead, which is now released. Please consider upgrading!

https://medium.com/storybookjs/storybook-6-0-1e14a2071000

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Jonovono picture Jonovono  路  3Comments

miljan-aleksic picture miljan-aleksic  路  3Comments

purplecones picture purplecones  路  3Comments

rpersaud picture rpersaud  路  3Comments

sakulstra picture sakulstra  路  3Comments