如何使用Jest和supertest在一个测试套件中放置多个测试套件?

时间:2019-12-30 09:59:43

标签: javascript node.js jestjs supertest

我创建了多个测试套件,并希望它们在单个测试套件或单个describe测试块下运行。 我将它们放置为...

describe('',()=>{  
  require('test-suite1.test.ts')
  require('test-suite2.test.ts')
  require('test-suite3.test.ts')
  ...
  ....
}

有人可以建议我以其他方式替换需求,并仍然在单个测试套件下运行所有​​测试吗?

1 个答案:

答案 0 :(得分:0)

测试的布局可以是这样的:

describe('All of the functions from this file', () => {
  describe('first function', () => {
    test('first function test one', () => {
      // ... tests for the first function
    });
    test('first function test two', () => {
      // ... tests for the first function
    });
    test('first function test three', () => {
      // ... tests for the first function
    });

  });
  describe('second function', () => {
    test('second function test one', () => {
      // ... tests for the second function
    });
    test('second function test two', () => {
      // ... tests for the second function
    });
    test('second function test three', () => {
      // ... tests for the second function
    });
  });
});