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

查看:23
本文介绍了在 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天全站免登陆