Force protractor to wait for seed data to load

自作多情 提交于 2019-12-06 05:01:36

If you are using Jasmine 2.1 or higher with Protractor you can make use of the done() function in your beforeAll.

So if you have a function called seedMyDataAsync() that takes a callback function as a parameter, you could do something as simple as this:

beforeAll( function(done) {
    seedMyDataAsync(done);
});

The done() function was introduced with Jasmine 2.0, but wasn't available for beforeAll() until Jasmine 2.1.

From the documentation:

Calls to beforeAll, afterAll, beforeEach, afterEach, and it can take an optional single argument that should be called when the async work is complete.

By default jasmine will wait for 5 seconds for an asynchronous spec to finish before causing a timeout failure. If the timeout expires before done is called, the current spec will be marked as failed and suite execution will continue as if done was called.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!