0

2つの非同期コールバックを生成するアクションがあり、両方のコールバックが呼び出されたときにテストを終了するシナリオをプログラムするにはどうすればよいですか?

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

1 に答える 1

3

答えは、予想される追加の開始回数で stop を呼び出すことです。asyncTest は 1 回の開始を想定しているため、私の場合は停止する別の呼び出しを追加する必要があります。

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();
    }
});
于 2012-07-23T09:47:44.257 に答える