Jasmine 2.0 how to wait real time before running an expectation

后端 未结 2 816
甜味超标
甜味超标 2021-01-04 00:11

I am trying to test the postMessage API as there is a slight delay before message are receive i can not run expectation right after sending a message.

In jasmine 1.3

2条回答
  •  半阙折子戏
    2021-01-04 00:38

    This works for me:

    beforeAll(function (done) {
        setTimeout(done, 5000);
    });
    

    The beforeAll function occurred first, but it will end when you invoke the done callback function. So if you use setTimeout function with 5000, it will wait 5000 milliseconds before continuing.

提交回复
热议问题