Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
137
rated 0 times [  142] [ 5]  / answers: 1 / hits: 18595  / 11 Years ago, tue, january 7, 2014, 12:00:00

The recently released Jasmine 2.0 removes the waits functions and the runs() from the Async Jasmine 1.3.



I have old 1.3 tests I'd like to transition to the new style.



For the waits, in most cases it seems like you can write beforeEach() and afterEach() carefully for the same effect.



What is the best way to reproduce the runs() which simply executes the contained functions sequentially?



My first try:



runs(function() {
expect(true).toBe(true);
}


becomes



(function() {
expect(true).toBe(true);
})()

More From » jasmine

 Answers
9

It is possible to use a setTimeout in your it() block.



it(is asynchronous, function(done) {
var isItDone = false;
$.ajax('/some/url').success(function() { isItDone = true; });

setTimeout(function(){
expect(isItDone).toBeTrue();
done(); // call this to finish off the it block
}, 500);

});


However, I found that that slowed down my test suite dramatically so I created my own extension which recreates the polling functionality that waitsFor provided.



https://gist.github.com/abreckner/110e28897d42126a3bb9


[#73342] Saturday, January 4, 2014, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
dayshadelaniej

Total Points: 668
Total Questions: 121
Total Answers: 121

Location: Sao Tome and Principe
Member since Wed, Dec 21, 2022
1 Year ago
dayshadelaniej questions
;