Storybook: Storyshots: running `initStoryshots` fails with "require.requireActual is not a function"

Created on 27 May 2020  ·  20Comments  ·  Source: storybookjs/storybook

If you are reporting a bug or requesting support, start here:

Bug or support request summary

Created a new project for the documentation software, and got an error when running the test (step 2).

Steps to reproduce

  1. https://www.learnstorybook.com/intro-to-storybook/svelte/en/get-started/
  2. https://www.learnstorybook.com/intro-to-storybook/svelte/en/simple-component/

Please specify which version of Storybook and optionally any affected addons that you're running

//* package.json *//

{
  "name": "svelte-app",
  "version": "0.0.1",
  "scripts": {
    "build": "rollup -c",
    "dev": "rollup -c -w",
    "start": "sirv public",
    "storybook": "start-storybook -p 6006 -s public",
    "build-storybook": "build-storybook",
    "test": "jest --watchAll"
  },
  "dependencies": {
    "sirv-cli": "^0.4.4"
  },
  "devDependencies": {
    "@babel/core": "^7.9.6",
    "@rollup/plugin-commonjs": "^12.0.0",
    "@rollup/plugin-node-resolve": "^8.0.0",
    "@storybook/addon-actions": "^5.3.19",
    "@storybook/addon-links": "^5.3.19",
    "@storybook/addon-storyshots": "^5.3.19",
    "@storybook/addons": "^5.3.19",
    "@storybook/svelte": "^5.3.19",
    "@testing-library/jest-dom": "^5.8.0",
    "@testing-library/svelte": "^3.0.0",
    "babel-loader": "^8.1.0",
    "jest": "^26.0.1",
    "jest-transform-svelte": "^2.1.1",
    "rollup": "^2.3.4",
    "rollup-plugin-livereload": "^1.0.0",
    "rollup-plugin-svelte": "^5.0.3",
    "rollup-plugin-terser": "^5.1.2",
    "svelte": "^3.22.3",
    "svelte-loader": "^2.13.6"
  },
  "jest": {
    "transform": {
        "^.+\\.js$": "babel-jest",
        "^.+\\.stories\\.[jt]sx?$": "<rootDir>node_modules/@storybook/addon-storyshots/injectFileName",
        "^.+\\.svelte$": "jest-transform-svelte"
      },
      "setupFilesAfterEnv": [
        "@testing-library/jest-dom/extend-expect"
      ]
  }
}

Screenshots / Screencast / Code Snippets (Optional)

Test code:

import initStoryshots from '@storybook/addon-storyshots';

initStoryshots();

Error stack:

 PASS  tests/sample.test.js
 FAIL  tests/storybook.test.js
  ● Test suite failed to run

    TypeError: require.requireActual is not a function

      1 | import initStoryshots from '@storybook/addon-storyshots';
      2 |
    > 3 | initStoryshots();
        | ^

      at Object.load (node_modules/@storybook/addon-storyshots/dist/frameworks/svelte/loader.js:25:29)
      at Object.loadFramework [as default] (node_modules/@storybook/addon-storyshots/dist/frameworks/frameworkLoader.js:26:19)
      at testStorySnapshots (node_modules/@storybook/addon-storyshots/dist/api/index.js:48:39)
      at Object.<anonymous> (tests/storybook.test.js:3:1)

Test Suites: 1 failed, 1 passed, 2 total
Tests:       1 passed, 1 total
Snapshots:   0 total
Time:        8.368 s
Ran all test suites.
PN storyshots svelte question / support

Most helpful comment

We've ugpraded to Jest 26 in 6.0, but due to time constraints I don't think we can back-port that to 5.3. I tried it quickly, ran into problems, and aborted to focus on getting 6 shipped. I'd advise anybody who runs into this to upgrade to 6

I've updated to 6 but still getting the error. Downgrade jest to "^25.1.0"only seems to work.

"@storybook/addon-actions": "^6.0.0-rc.13",
    "@storybook/addon-links": "^6.0.0-rc.13",
    "@storybook/addon-storyshots": "^5.3.19",
    "@storybook/addon-storysource": "^6.0.0-rc.13",
    "@storybook/addons": "^6.0.0-rc.13",
    "@storybook/react": "^6.0.0-rc.13",
"storybook": "^6.0.0-rc.13",

Error:

 FAIL  stories/Storyshots.test.js
  ● Test suite failed to run

    TypeError: require.requireActual is not a function

      1 | import initStoryshots from '@storybook/addon-storyshots';
      2 |
    > 3 | initStoryshots();
        | ^
      4 |

      at Object.load (node_modules/@storybook/addon-storyshots/dist/frameworks/react/loader.js:23:29)
      at Object.loadFramework [as default] (node_modules/@storybook/addon-storyshots/dist/frameworks/frameworkLoader.js:26:19)
      at testStorySnapshots (node_modules/@storybook/addon-storyshots/dist/api/index.js:48:39)
      at Object.<anonymous> (stories/Storyshots.test.js:3:1)

All 20 comments

cc @jonniebigodes

I'm also experiencing this issue with React.

@cpsTinK and @SaubereSache sorry that you're experiencing the issue. I'm going to take a look at it and see what i can come up with. Do you mind waiting a bit while i check this?

I'm having this issue too. It started when I upgraded to from Jest 24 to 26.

Looks like this may be the issue? Should be using jest.requireActual instead of require.requireActual?

I saw the theme #10455 and the closed #10631.
But the problem is apparently not completely fixed.
I am new to Storybook and find it difficult to fix the problem or offer a solution on my own.
I also understand that we are actively working on a new version, but I hope that this error will be fixed in the current stable version in the near future, since it is probably not only related to Svelte.

Thank you for your attention to this issue.

I'm having this issue too. It started when I upgraded to from Jest 24 to 26.

Downgrading to Jest 24.0.1 fixed the issue for me.

@pelotom that seems to be the case. I was checking it and the behaviour occurs. Bumping back to Jest 24 the addon will work properly. And when the 5.3.20 version of the addon goes live i'm going to bump to jest 26 take another look at it to see if the problem persists

We've ugpraded to Jest 26 in 6.0, but due to time constraints I don't think we can back-port that to 5.3. I tried it quickly, ran into problems, and aborted to focus on getting 6 shipped. I'd advise anybody who runs into this to upgrade to 6

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

It’s not stale

сб, 11 июля 2020 г. в 04:33, stale[bot] notifications@github.com:

Hi everyone! Seems like there hasn't been much going on in this issue
lately. If there are still questions, comments, or bugs, please feel free
to continue the discussion. Unfortunately, we don't have time to get to
every issue. We are always open to contributions so please send us a pull
request if you would like to help. Inactive issues will be closed after 30
days. Thanks!


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/storybookjs/storybook/issues/10942#issuecomment-656961172,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAKXL7L7ICAGWUQYMYAULQ3R266ODANCNFSM4NL4RBPA
.

yeah just experienced this error today

We've ugpraded to Jest 26 in 6.0, but due to time constraints I don't think we can back-port that to 5.3. I tried it quickly, ran into problems, and aborted to focus on getting 6 shipped. I'd advise anybody who runs into this to upgrade to 6

I've updated to 6 but still getting the error. Downgrade jest to "^25.1.0"only seems to work.

"@storybook/addon-actions": "^6.0.0-rc.13",
    "@storybook/addon-links": "^6.0.0-rc.13",
    "@storybook/addon-storyshots": "^5.3.19",
    "@storybook/addon-storysource": "^6.0.0-rc.13",
    "@storybook/addons": "^6.0.0-rc.13",
    "@storybook/react": "^6.0.0-rc.13",
"storybook": "^6.0.0-rc.13",

Error:

 FAIL  stories/Storyshots.test.js
  ● Test suite failed to run

    TypeError: require.requireActual is not a function

      1 | import initStoryshots from '@storybook/addon-storyshots';
      2 |
    > 3 | initStoryshots();
        | ^
      4 |

      at Object.load (node_modules/@storybook/addon-storyshots/dist/frameworks/react/loader.js:23:29)
      at Object.loadFramework [as default] (node_modules/@storybook/addon-storyshots/dist/frameworks/frameworkLoader.js:26:19)
      at testStorySnapshots (node_modules/@storybook/addon-storyshots/dist/api/index.js:48:39)
      at Object.<anonymous> (stories/Storyshots.test.js:3:1)

Same here :(

Issue still happening. Got it today with jest v26.4.0.

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

It’s not stale

Yes it's not inactive please :(

What's the current state of this on the latest stable version of jest and the latest stable version of storybook?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tirli picture tirli  ·  3Comments

arunoda picture arunoda  ·  3Comments

dnlsandiego picture dnlsandiego  ·  3Comments

miljan-aleksic picture miljan-aleksic  ·  3Comments

xogeny picture xogeny  ·  3Comments