【问题标题】:How can I use “do while” in mocha testing如何在 mocha 测试中使用“do while”
【发布时间】:2021-07-29 21:58:12
【问题描述】:

例如,我有:

function test1() {
  it("Test 1", function (done) {
    ...
  });
}

function test2() {
  it("Test 2", function (done) {
    ...
  });
}

describe("main()", function () {
  do {
    test1();
    test2();
  } while (resultReturnBool);
});

虽然 resultReturnBool 为“true”,但它不会重做 test1 和 test2。

我做错了什么?我是否正确使用 do-while?

【问题讨论】:

    标签: javascript testing mocha.js


    【解决方案1】:

    do...while 似乎是正确的,可能是因为 Mocha 的工作方式,它不接受做这种事情,你见过使用 do...while 的任何测试吗? (只是一个问题,我是测试新手,我正在学习开玩笑)。

    试着做一个正常的while。

    while(resultReturnBool) {
       it('Test1', () => {
            // Yout test here
    });
       it('Test2', () => {
            // Yout test here
    });
    }
    

    【讨论】:

      猜你喜欢
      • 2015-05-11
      • 2013-02-10
      • 2020-11-13
      • 1970-01-01
      • 2012-05-26
      • 1970-01-01
      • 2018-02-08
      • 2016-11-08
      相关资源
      最近更新 更多