gpt4 book ai didi

jasmine - Jasmine 2.0 中的测试用例是否并行运行

转载 作者:行者123 更新时间:2023-12-04 03:00:59 25 4
gpt4 key购买 nike

Jasmine 2.0 中的测试是否并行运行?根据我的经验,它们不只是文章,由 Jasmine.js: Race Conditions when using "runs" 引用。表明 Jasmine 确实并行运行它们,所以我想知道我是否在错误地编写测试。

这是我希望在 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);
});
});

我错过了什么吗?

jsFiddle

最佳答案

Jasmine 实际上不会以任何方式并行运行您的规范。然而,可能有一些规范的异步部分需要足够长的时间,以至于内置的时间限制过去了,这将导致 jasmine 开始运行下一个规范,即使可能仍然有来自早期规范的代码在运行。

关于jasmine - Jasmine 2.0 中的测试用例是否并行运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25652895/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com