jasmine 2 - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL(jasmine 2 - 在 jasmine.DEFAULT_TIMEOUT_INTERVAL 指定的超时时间内未调用异步回调)
问题描述
jasmine 2 遇到问题并连接异步规范:
Having trouble with jasmine 2 and getting async specs wired up:
define(['foo'], function(foo) {
return describe('foo', function() {
beforeEach(function(done) {
window.jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
return setTimeout((function() {
console.log('inside timeout');
return done();
}), window.jasmine.DEFAULT_TIMEOUT_INTERVAL);
});
return it('passes', function() {
return expect({}).toBeDefined();
});
});
});
当我通过业力奔跑时,我会回来
When I run via karma, I get back
错误:超时 - 未在超时内调用异步回调由 jasmine.DEFAULT_TIMEOUT_INTERVAL 指定.
Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
然后规范失败.我试图覆盖默认超时,但我无法克服错误
and then the specs fail. I have attempted to override the default timeout but I can't get past the error
推荐答案
您正在使用与 Jasmine 相同的超时间隔来失败测试超时,即您的超时被触发以使用 Jasmine 的默认间隔触发,这会导致测试失败.
You are using the same timeout interval as Jasmine is using to fail tests on timeout, i.e. your timeout is triggered to fire with Jasmine's default interval, which fails the test.
如果您将超时设置为小于 jasmine 默认超时,则测试通过.
If you set your timeout to be less than jasmine default timeout the test passes.
describe('foo', function () {
beforeEach(function (done) {
window.jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
setTimeout(function () {
console.log('inside timeout');
done();
}, 500);
});
it('passes', function () {
expect({}).toBeDefined();
});
});
见小提琴这里
这篇关于jasmine 2 - 在 jasmine.DEFAULT_TIMEOUT_INTERVAL 指定的超时时间内未调用异步回调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:jasmine 2 - 在 jasmine.DEFAULT_TIMEOUT_INTERVAL 指定的超时


- 我不能使用 json 使用 react 向我的 web api 发出 Post 请求 2022-01-01
- 为什么我的页面无法在 Github 上加载? 2022-01-01
- 在不使用循环的情况下查找数字数组中的一项 2022-01-01
- 如何调试 CSS/Javascript 悬停问题 2022-01-01
- 使用 iframe URL 的 jQuery UI 对话框 2022-01-01
- 如何向 ipc 渲染器发送添加回调 2022-01-01
- 为什么悬停在委托事件处理程序中不起作用? 2022-01-01
- 如何显示带有换行符的文本标签? 2022-01-01
- 是否可以将标志传递给 Gulp 以使其以不同的方式 2022-01-01
- 从原点悬停时触发 translateY() 2022-01-01