Pending element loading in Angular script

I am using Angular scripts to complete testing my application. I would like to run tests based on elements that take time to load. I could just use the sleep() command, but I would rather do something like:

 whenLoaded('p .foo') .then(function(elem) { expect(elem.text()).toBe(something); }); 

Is it possible?

+4
source share
1 answer

Jasmine.js lets you do this. See asynchronous specifications.

http://pivotal.imtqy.com/jasmine/

 describe("Asynchronous specs", function() { var value, flag; it("should support async execution of test preparation and exepectations", function() { runs(function() { flag = false; value = 0; setTimeout(function() { flag = true; }, 500); }); waitsFor(function() { value++; return flag; }, "The Value should be incremented", 750); runs(function() { expect(value).toBeGreaterThan(0); }); }); }); 
-1
source

Source: https://habr.com/ru/post/1443301/


All Articles