Are test cases in Jasmine 2.0 parallel

Are tests conducted in Jasmine 2.0 in parallel? In my experience, this is not the article referenced by Jasmine.js: Race conditions when using "runs" suggests that Jasmine runs them in parallel, so I wondered if I wrote my tests incorrectly.

Here is a set of tests that I would expect to complete in 1 second instead of 4 seconds.

describe("first suite", function() { it("first test", function(done) { expect(true).toBeTruthy(); setTimeout(done, 1000); }); it("second test", function(done) { expect(true).toBeTruthy(); setTimeout(done, 1000); }); }); describe("second suite", function() { it("first test", function(done) { expect(true).toBeTruthy(); setTimeout(done, 1000); }); it("second test", function(done) { expect(true).toBeTruthy(); setTimeout(done, 1000); }); }); 

Did I miss something?

jsFiddle

+6
source share
2 answers

Jasmine doesn't actually run your specifications in parallel. However, it is possible to have specifications whose asynchronous part takes enough time to expire the built-in time interval, which is why jasmine will start to run the next specification, even though there may still be code running from earlier specifications.

+8
source

If you want to run your test in parallel, and you use karma as a test launcher, you can use karma-parallel to split your tests in multiple browser instances. It runs specifications in different browser instances and is very simple and easy to install:

 npm i karma-parallel 

and then add โ€œparallelโ€ to the list of frameworks in karma.conf.js file

 module.exports = function(config) { config.set({ frameworks: ['parallel', 'jasmine'] }); }; 

karma-parallel

Disclosure: I am an author

+2
source

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


All Articles