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

Storyshots: running initStoryshots fails with "require.requireActual is not a function" #10942

Closed
gevrum opened this issue May 27, 2020 · 22 comments

Comments

@gevrum
Copy link

gevrum commented May 27, 2020

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.
@shilman
Copy link
Member

shilman commented May 27, 2020

cc @jonniebigodes

@constantins2001
Copy link

I'm also experiencing this issue with React.

@jonniebigodes
Copy link
Contributor

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

@pelotom
Copy link
Contributor

pelotom commented May 28, 2020

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

@pelotom
Copy link
Contributor

pelotom commented May 28, 2020

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

@gevrum
Copy link
Author

gevrum commented May 28, 2020

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.

@constantins2001
Copy link

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.

@jonniebigodes
Copy link
Contributor

@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

@shilman
Copy link
Member

shilman commented Jun 6, 2020

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

@bannndi
Copy link

bannndi commented Jun 16, 2020

May be this would help #10351 (comment)

@stale
Copy link

stale bot commented Jul 11, 2020

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!

@stale stale bot added the inactive label Jul 11, 2020
@stereodenis
Copy link
Contributor

stereodenis commented Jul 12, 2020 via email

@stale stale bot removed the inactive label Jul 12, 2020
@invious
Copy link

invious commented Jul 14, 2020

yeah just experienced this error today

@brendonco
Copy link

brendonco commented Jul 22, 2020

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)

@lauthieb
Copy link
Contributor

Same here :(

@enrique-ramirez
Copy link

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

@stale
Copy link

stale bot commented Sep 5, 2020

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!

@stale stale bot added the inactive label Sep 5, 2020
@stereodenis
Copy link
Contributor

It’s not stale

@stale stale bot removed the inactive label Sep 5, 2020
@lauthieb
Copy link
Contributor

lauthieb commented Sep 6, 2020

Yes it's not inactive please :(

@stale stale bot added the inactive label Oct 4, 2020
@shilman shilman added the PN label Oct 4, 2020
@stale stale bot removed the inactive label Oct 4, 2020
@storybookjs storybookjs deleted a comment from stale bot Oct 4, 2020
@shilman
Copy link
Member

shilman commented Oct 4, 2020

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

@stale
Copy link

stale bot commented Dec 26, 2020

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!

@stale stale bot added the inactive label Dec 26, 2020
@jonniebigodes
Copy link
Contributor

Closing this @shilman as the issue has not presented itself for the last 2 iterations of Storybook and Jest. I've tested the tutorial and associated template in 2 separate environments.

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