Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在qunit中检查两个异步调用_Javascript_Qunit - Fatal编程技术网

Javascript 在qunit中检查两个异步调用

Javascript 在qunit中检查两个异步调用,javascript,qunit,Javascript,Qunit,我如何编程这样一个场景:我有一个生成两个异步回调的操作,并且我希望在两个回调都被调用时测试结束 asyncTest('Do two asynchronous things', 2, function() { doTwoThings(callback1, callback2); function callback1() { ok(true, 'dummy test'); start(); } function callback2()

我如何编程这样一个场景:我有一个生成两个异步回调的操作,并且我希望在两个回调都被调用时测试结束

asyncTest('Do two asynchronous things', 2, function() {
    doTwoThings(callback1, callback2);
    function callback1() {
        ok(true, 'dummy test');
        start();
    }
    function callback2() {
        ok(true, 'dummy test');
        start();
    }
});

答案是用你期望的额外启动次数呼叫stop。asyncTest需要一次启动,因此对于我的情况,我必须添加另一个停止调用

asyncTest('Do two asynchronous things', 2, function() {
    stop()
    doTwoThings(callback1, callback2);
    function callback1() {
        ok(true, 'dummy test');
        start();
    }
    function callback2() {
        ok(true, 'dummy test');
        start();
    }
});

答案是用你期望的额外启动次数呼叫stop。asyncTest需要一次启动,因此对于我的情况,我必须添加另一个停止调用

asyncTest('Do two asynchronous things', 2, function() {
    stop()
    doTwoThings(callback1, callback2);
    function callback1() {
        ok(true, 'dummy test');
        start();
    }
    function callback2() {
        ok(true, 'dummy test');
        start();
    }
});

如果你自己找到了一个解决方案,把它作为一个答案发布,然后自我接受。如果你自己找到了一个解决方案,把它作为一个答案发布,然后自我接受。