我正在尝试在我的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)
1条答案
按热度按时间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