我正在关注有关异步支持的 Jasmine 1.3 文档,但无法使示例正常工作。
我正在使用的(稍作修改)源代码spec/async-spec.js如下:
describe("Asynchronous specs", function() {
var value, flag;
it("should support async execution of test preparation and expectations", function() {
runs(function() {
flag = false;
value = 0;
console.log("HERE");
setTimeout(function() {
console.log("HERE2");
flag = true;
}, 750);
});
waitsFor(function() {
value++;
return flag;
}, "The Value should be incremented", 5000);
runs(function() {
expect(value).toBeGreaterThan(0);
});
});
});
我正在使用以下命令运行它:
atom --test --timeout 60 spec/async-spec.js
它给出了以下结果:
HERE
F
Asynchronous specs
it should support async execution of test preparation and expectations
timeout: timed out after 5000 msec waiting for The Value should be incremented
Finished in 5.746 seconds
1 test, 1 assertion, 1 failure, 0 skipped
我希望测试同时返回HEREandHERE2并且断言通过,但事实并非如此。
atom --version详情如下:
Atom : 1.38.2
Electron: 2.0.18
Chrome : 61.0.3163.100
Node : 8.9.3
确切的茉莉花版本是:1.3.1 revision 1354556913
我对 Atom/Jasmine 测试相当陌生,因此将不胜感激任何帮助。