错误 运行 测试 - jest.mock 不是函数
Error running tests - jest.mock is not a function
我正在尝试 运行 使用 Jest 进行测试,但是我收到了这个错误:
jest.mock is not a function
我做错了什么?这是我的 CodeSandbox:https://codesandbox.io/s/polling-hook-demo-9yo8c
请注意,我正在 package.json:
中配置 Jest
"setupFilesAfterEnv": [
"./src/test/setupTestsAfterEnv.ts"
]
setupTestsAfterEnv.ts extends Jest expect using jest-dom:
import "@testing-library/jest-dom/extend-expect";
我也在用react-testing-library
更新
这似乎是我的 CodeSandbox 配置的问题。我在本地用 create-react-app 尝试了同样的事情,问题消失了!
这是我的 Github 回购协议,其中 Jest 运行 非常好:https://github.com/nareshbhatia/hooked-on-polling。
然后我将此存储库导入到新的 CodeSandbox 中:https://codesandbox.io/s/hooked-on-polling-2em7g。当我在这个沙盒中 运行 测试时,我再次得到同样的错误: jest.mock is not a function
已确认这是 CodeSandbox 的问题:https://github.com/codesandbox/codesandbox-client/issues/513
我正在尝试 运行 使用 Jest 进行测试,但是我收到了这个错误:
jest.mock is not a function
我做错了什么?这是我的 CodeSandbox:https://codesandbox.io/s/polling-hook-demo-9yo8c
请注意,我正在 package.json:
中配置 Jest"setupFilesAfterEnv": [
"./src/test/setupTestsAfterEnv.ts"
]
setupTestsAfterEnv.ts extends Jest expect using jest-dom:
import "@testing-library/jest-dom/extend-expect";
我也在用react-testing-library
更新
这似乎是我的 CodeSandbox 配置的问题。我在本地用 create-react-app 尝试了同样的事情,问题消失了!
这是我的 Github 回购协议,其中 Jest 运行 非常好:https://github.com/nareshbhatia/hooked-on-polling。
然后我将此存储库导入到新的 CodeSandbox 中:https://codesandbox.io/s/hooked-on-polling-2em7g。当我在这个沙盒中 运行 测试时,我再次得到同样的错误: jest.mock is not a function
已确认这是 CodeSandbox 的问题:https://github.com/codesandbox/codesandbox-client/issues/513