在Jest中,如何使测试失败? [英] In Jest, how can I make a test fail?

查看:75
本文介绍了在Jest中,如何使测试失败?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道我可能会在测试内部抛出一个错误,但是我想知道是否存在像Jasmine提供的全局fail()方法之类的东西?

I know I could throw an error from inside the test, but I wonder if there is something like the global fail() method provided by Jasmine?

推荐答案

您可以通过引发错误来做到这一点.例如:

You can do it by throwing an error. For example:

test('Obi-Wan Kenobi', () => {
  throw new Error('I have failed you, Anakin')
})

这篇关于在Jest中,如何使测试失败?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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