使用 ts-jest 对 Jest 进行简单配置会在运行时产生错误“ReferenceError: describe is not defined”。这里最小的例子:https : //github.com/PFight/jest-ts-describe-not-defined-problem
我配置错了什么?
发现问题了。它是 jest.config.js 的下一行:
testEnvironment: 'node',
Run Code Online (Sandbox Code Playgroud)
刚刚删除它并修复了错误。
我有同样的问题,但我需要 testEnvironment 是节点。解决方案是降级到"jest": "^24.9.0". 当 testEnvironment 设置为 node 时,最新版本似乎有问题。
更新
根据此评论https://github.com/facebook/jest/issues/9538#issuecomment-604522345,这个问题似乎已在 jest 25.2.2 中得到修复, 但我还没有对其进行测试。