跳过测试文件中的一个测试 Jest

2022-08-30 04:07:47

我正在使用Jest框架,并有一个测试套件。我想关闭/跳过我的一个测试。

谷歌搜索文档不会给我答案。

您知道要检查的答案或信息来源吗?


答案 1

我在这里找到了答案

https://devhints.io/jest

test('it is raining', () => {
  expect(inchesOfRain()).toBeGreaterThan(0);
});

test.skip('it is not snowing', () => {
  expect(inchesOfSnow()).toBe(0);
});

链接打开文档


答案 2

也可以排除或以 .testdescribex

个人测试

describe('All Test in this describe will be run', () => {
  xtest('Except this test- This test will not be run', () => {
   expect(true).toBe(true);
  });
  test('This test will be run', () => {
   expect(true).toBe(true);
  });
});

描述中的多个测试

xdescribe('All tests in this describe will be skipped', () => {
 test('This test will be skipped', () => {
   expect(true).toBe(true);
 });

 test('This test will be skipped', () => {
   expect(true).toBe(true);
 });
});