这里有两个简单的例子。没有多余的。它们不起作用。错误输出到控制台。
没有异步测试正在运行。这些——不是。
测试为流星应用程序编写。
关于jasmine.DEFAULT_TIMEOUT_INTERVAL
我已经知道了,是5000。
describe("Jasmine async tests", function(){
it("First test with timeout", function(done){
Meteor.setTimeout(function(){
done();
}, 300);
});
it("Second test, request to google.com", function(done){
HTTP.get("http://google.com/", {}, function(){
done();
});
});
});
控制台输出:
I20141021-21:08:35.178(3)? Async Login Test response to google.com
I20141021-21:08:35.179(3)? Error: Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
I20141021-21:08:35.180(3)? at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)
在单元测试模式中,Meteor API的大部分都被淘汰。这意味着调用Meteor.setTimeout
或HTTP.get
将只执行一个空函数,因此将不执行任何操作。您的回拨从未被调用。
您可以在此处找到使用过的存根:https://github.com/meteor-velocity/meteor-stubs/blob/master/index.js
同样相关的:https://github.com/Sanjo/meteor-jasmine/issues/55#issuecomment-61026304