How do I change the timeout on a jasmine-node async spec

后端 未结 10 1919
生来不讨喜
生来不讨喜 2020-12-04 20:53

How can I get this test to pass without resorting to runs/waitsFor blocks?

it(\"cannot change timeout\", function(done) {

     request(\"http://localhost:30         


        
10条回答
  •  北海茫月
    2020-12-04 21:26

    Why not by spying on setTimeout()?

    Something like:

    var spy = spyOn(window, 'setTimeout').andCallFake(function (func, timeout) {
        expect(timeout).toEqual(2500);
        func();
    });
    
    setTimeOut(function () { ... }, 2500);
    expect(spy).toHaveBeenCalled();
    

提交回复
热议问题