0

我有一个健康检查端点的测试用例,如果该特定端点失败,我希望测试中止所有测试..因为如果 healthchek 失败,将没有必要测试其余端点。我想知道中止其余测试的最佳方法是什么。这是我想要的代码

    describe(`Health check Content services`, () => {
    it(`Trigger /status endpoint and return 200`, async () => {
        let data = await healthCheck.healthCheckRunner(config);
        if(data == true) {
            //continue rest of tests
        } else {
            //abort test execution
        }

        });
    });
4

1 回答 1

0

您可以使用断言来检查端点是否返回 true。如果不是,测试用例将失败而不进一步执行

import {assert} from 'chai';

describe('Health check Content services', () => {
  it('Trigger /status endpoint and return 200', async () => {
      let data = await healthCheck.healthCheckRunner(config);
      assert.isTrue(data, 'message to show if data is false');
      // Remaining test cases
  });
于 2019-10-16T15:13:15.303 回答