ReferenceError:在Jest + Typescript中未定义describe [英] ReferenceError: describe is not defined in Jest + Typescript
问题描述
使用ts-jest进行Jest的简单配置会在运行时产生错误"ReferenceError:describe未定义".此处为最小示例: https://github.com/PFight/jest- ts-describe-not-defined-problem
Simple configuration of Jest with ts-jest produces error "ReferenceError: describe is not defined" in runtime. Here minimal example: https://github.com/PFight/jest-ts-describe-not-defined-problem
我配置错了吗?
推荐答案
我遇到了同样的问题,但是我需要将testEnvironment作为节点.解决方案是降级到"jest": "^24.9.0"
.将testEnvironment设置为node时,最新版本似乎有问题.
I had the same problem but I needed the testEnvironment to be node. The solution is to downgrade to "jest": "^24.9.0"
. It seems like there's a problem with the latest version when testEnvironment is set to node.
更新
此评论似乎在jest 25.2.2中已解决此问题 https://github.com/facebook/jest/issues/9538#issuecomment-604522345 我还没有测试过.
It looks like this issue has been fixed in jest 25.2.2 per this comment https://github.com/facebook/jest/issues/9538#issuecomment-604522345 I haven't tested it though.
这篇关于ReferenceError:在Jest + Typescript中未定义describe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!