TypeError: require.requireActual is not a function

TypeError: require.requireActual is not a function

我在 Jest 测试中遇到错误:

 FAIL  test/storyshots.test.ts
  ● Test suite failed to run

    TypeError: require.requireActual is not a function

      1 | import initStoryshots from "@storybook/addon-storyshots"
      2 | 
    > 3 | initStoryshots({
        | ^
      4 |   configPath: "./storybook",
      5 |   framework: "react-native",
      6 | })

      at Object.load (node_modules/@storybook/addon-storyshots/dist/frameworks/react-native/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:14)
      at Object.<anonymous> (test/storyshots.test.ts:3:1)

我没有在代码中的任何地方使用 requireActual。不过看起来 Storybook 确实如此。

Google 搜索只找到一个(已删除)Whosebug 问题,没有答案。

不久前和最近 removed it in version 26

弃用了 Jest require.requireActual

降级到 Jest 25 来修复它,或者找到正在使用 require.requireActual 的软件包并让他们改用 jest.requireActual

编辑:Storybook v6.0.0-beta.3 包括添加 Jest v26 支持的更新。