Jasmine 2.0 rc* waits is not defined

后端 未结 2 1097
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-14 12:27

Just upgraded to jasmine 2.0 rc5 from 1.3 and now all my tests that used waits() are broken because the waits() and <

相关标签:
2条回答
  • 2021-02-14 13:12

    Use jasmine.DEFAULT_TIMEOUT_INTERVAL = 5000

    Please refer the below URL for Jasmine Documentation... http://jasmine.github.io/2.0/introduction.html

    Section is "Asynchronous Support" in the documentation.

    0 讨论(0)
  • 2021-02-14 13:24

    Well, the usage syntax for asynchronous calls changed. You can easily see the differences between the two versions in its documentations:

    Jasmine 1.3 Asynchronous support uses waitsFor() and run() functions.

    According to Jasmine 2.0 Asynchronous support, these functions has been wiped out from the library. However, Jasmine 2.0 adds async support to the primitive beforeEach(), afterEach() and it() functions. The callback functions passed to these functions now can take an argument that indicates if the spec can or can't run.

    Then, when you reach the necessary conditions to run your test (whenever your async job is complete), you simply call done(). And all the magic happens ;)

    From the documentation:

    describe("Asynchronous specs", function() {
        var value;
    
        beforeEach(function(done) {
            setTimeout(function() {
                value = 0;
                done();
            }, 1);
        });
    
        it("should support async execution of test preparation and expectations", function(done) {
            value++;
            expect(value).toBeGreaterThan(0);
            done();
        });
    });
    

    The it() spec above will run only after the setTimeout() call, because done() is called there. Note the it() callback takes an argument (done).

    0 讨论(0)
提交回复
热议问题