Jest中如何跳过特定测试

发布时间:2024-08-28 09:55:37 作者:小樊
来源:亿速云 阅读:84

在 Jest 中,要跳过特定测试,可以使用 test.skip() 方法

例如,假设您有以下测试:

test('this test will run', () => {
  // your test code here
});

test('this test will be skipped', () => {
  // your test code here
});

要跳过第二个测试,只需将其更改为:

test('this test will run', () => {
  // your test code here
});

test.skip('this test will be skipped', () => {
  // your test code here
});

现在,当您运行测试时,第二个测试将被跳过。请注意,test.skip() 也可以与 describe 结构一起使用,以跳过整个测试套件。

describe('skipped suite', () => {
  test('this test will be skipped', () => {
    // your test code here
  });

  test('this test will also be skipped', () => {
    // your test code here
  });
}).skip();

这将跳过整个“skipped suite”中的所有测试。

推荐阅读:
  1. springBoot中elasticsearch如何使用
  2. ESLint和Jest中怎么使用esm

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

jest

上一篇:Jest测试报告生成工具推荐

下一篇:Jest与TypeScript兼容性问题解析

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》