Jest.js TypeError:无法析构“options”的属性“instrument”,因为它未定义

k5ifujac  于 2023-02-27  发布在  Jest
关注(0)|答案(1)|浏览(213)

我正在尝试在我的visual studio代码中安装jest测试。我遇到了以下错误。你能帮我解决这个问题吗?
●测试套件运行失败

TypeError: Cannot destructure property 'instrument' of 'options' as it is undefined.

  at Object.getCacheKey (node_modules/fbjs-scripts/jest/createCacheKeyFunction.js:35:12)
  at ScriptTransformer._getCacheKey (node_modules/@jest/transform/build/ScriptTransformer.js:280:41)
  at ScriptTransformer._getFileCachePath (node_modules/@jest/transform/build/ScriptTransformer.js:351:27)
  at ScriptTransformer.transformSource (node_modules/@jest/transform/build/ScriptTransformer.js:588:32)
  at ScriptTransformer._transformAndBuildScript (node_modules/@jest/transform/build/ScriptTransformer.js:758:40)
  at ScriptTransformer.transform (node_modules/@jest/transform/build/ScriptTransformer.js:815:19)
xmakbtuz

xmakbtuz1#

对我来说,这是在我升级到jest版本27后开始发生的。将其版本固定为26.6.3。即:npm i -D jest@26.6.3解决了这个问题。
如果您使用 typescript 和ts-jest,请用途:npm i -D jest@26.6.3 ts-jest@26.5.5

相关问题