ReferenceError:在 Jest + Typescript 中未定义描述 [英] ReferenceError: describe is not defined in Jest + Typescript

查看:28
本文介绍了ReferenceError:在 Jest + Typescript 中未定义描述的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 ts-jest 简单配置 Jest 会在运行时产生错误ReferenceError: describe is not defined".这里最小的例子:https://github.com/PFight/jest-ts-描述未定义的问题

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 为 node.解决办法是降级到"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 中未定义描述的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆