Jasmine 2.0中的测试是否并行运行?根据我的经验,他们不是但文章,引用Jasmine.js: Race Conditions when using "runs"表明茉莉花并行运行它们,所以我想知道如果我错误地写我的测试。Jasmine 2.0中的测试用例是否并行运行
这是一组测试,我希望在1秒内执行而不是4秒。
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);
});
});
我错过了什么吗?
您可能想阅读[this discussion](http://stackoverflow.com/questions/2734025/is-javascript-guaranteed-to-be-single-threaded)。我刚刚在Chrome中运行jsFiddle,它“在4.012s内完成”。这可能取决于哪个浏览器以及JS如何实现。 – zerodiff 2014-09-03 21:33:59
没有理由Jasmine不能并行运行异步测试并保持单线程。这是一个[fsFiddle](http://jsfiddle.net/dspigarelliMNDNT/vr5Larxx/),理论上可能是这样的。 – Spig 2014-09-05 14:11:30