Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jest 26 compatibility: replace require.requireActual with jest.requireActual #10631

Closed
SimenB opened this issue May 3, 2020 · 12 comments
Closed

Comments

@SimenB
Copy link
Contributor

SimenB commented May 3, 2020

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
jestjs/jest#9854

@radoi90
Copy link

radoi90 commented May 4, 2020

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

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

@Hypnosphi Hypnosphi self-assigned this May 4, 2020
nicksellen added a commit to karrot-dev/karrot-frontend that referenced this issue May 6, 2020
nicksellen added a commit to karrot-dev/karrot-frontend that referenced this issue May 6, 2020
* Update dependencies

* Fix deprecated use of require.requireActual

See storybookjs/storybook#10631

* Update test snapshots

* Fix use of deprecated @vue/test-utils methods
@shilman
Copy link
Member

shilman commented May 7, 2020

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.

@jakubriedl
Copy link
Contributor

@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

@shilman
Copy link
Member

shilman commented May 8, 2020

@jakubriedl ok will try to special-case this

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

@SimenB
Copy link
Contributor Author

SimenB commented May 8, 2020

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

@shilman
Copy link
Member

shilman commented May 8, 2020

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.

tiltec pushed a commit to karrot-dev/karrot-frontend that referenced this issue May 9, 2020
* Update dependencies

* Fix deprecated use of require.requireActual

See storybookjs/storybook#10631

* Update test snapshots

* Fix use of deprecated @vue/test-utils methods
Kikobeats added a commit to microlinkhq/sdk that referenced this issue May 13, 2020
storybook is using a removed jest API

related: storybookjs/storybook#10631
@aloukianova-godaddy
Copy link

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: #10455

@Hypnosphi
Copy link
Member

@shilman did this get into 5.3.19?

@shilman
Copy link
Member

shilman commented May 26, 2020

@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?

@Hypnosphi
Copy link
Member

Yes please

@liamkeily
Copy link

Are there still plans to fix this in 5.3.20?

@shilman
Copy link
Member

shilman commented Aug 13, 2020

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants