Jquery 通过CLI运行时,Emberjs测试挂起
我的Ember测试套件在通过命令行运行时超时。我已经找到了这一点,这是因为Jquery 通过CLI运行时,Emberjs测试挂起,jquery,ember.js,ember-data,phantomjs,teaspoon,Jquery,Ember.js,Ember Data,Phantomjs,Teaspoon,我的Ember测试套件在通过命令行运行时超时。我已经找到了这一点,这是因为ajaxComplete没有为通过调用visit启动的AJAX请求触发,但是这个请求在浏览器中运行时触发完整事件 ajaxComplete事件触发对Ember的decrementAjaxPendingRequests的调用,当该调用未被调用时,它将在wait方法期间持续旋转,如Test。pendingAjaxRequests请求不是0。你可以在这里看到: function wait(app, value) {
ajaxComplete
没有为通过调用visit
启动的AJAX请求触发,但是这个请求在浏览器中运行时触发完整事件
ajaxComplete
事件触发对Ember的decrementAjaxPendingRequests
的调用,当该调用未被调用时,它将在wait
方法期间持续旋转,如Test。pendingAjaxRequests
请求不是0。你可以在这里看到:
function wait(app, value) {
return Test.promise(function(resolve) {
// If this is the first async promise, kick off the async test
if (++countAsync === 1) {
Test.adapter.asyncStart();
}
// Every 10ms, poll for the async thing to have finished
var watcher = setInterval(function() {
console.log("watcher tick");
// 1. If the router is loading, keep polling
var routerIsLoading = !!app.__container__.lookup('router:main').router.activeTransition;
if (routerIsLoading) {
return;
}
// 2. If there are pending Ajax requests, keep polling
if (Test.pendingAjaxRequests) {
console.log("PENDING AJAX REQUESTS: ", Test.pendingAjaxRequests, " - RETURNING");
return;
}
// 3. If there are scheduled timers or we are inside of a run loop, keep polling
if (run.hasScheduledTimers() || run.currentRunLoop) {
return;
}
if (Test.waiters && Test.waiters.any(function(waiter) {
var context = waiter[0];
var callback = waiter[1];
return !callback.call(context);
})) {
return;
}
// Stop polling
clearInterval(watcher);
// If this is the last async promise, end the async test
if (--countAsync === 0) {
Test.adapter.asyncEnd();
}
// Synchronously resolve the promise
run(null, resolve, value);
}, 10);
});
}
所讨论的AJAX请求来自我的一个路由中的一个模型钩子,它是一个简单的返回this.store.find('model_name')
。我使用sinon.js来伪造这个请求,如果我在find调用中加入then
子句,我会看到它正确返回,但它仍然没有触发它的ajaxComplete
事件
这是我的堆栈:
- 余烬:1.7.1
- 余烬数据:1.0.0-beta.8.2a68c63a
- 茶匙(我的测试跑步者):0.8.0
- jQuery:1.10.2
- PhantomJS(CLI测试运行程序):1.9.7和1.8.2
有人知道这是否有任何未决问题,或者堆栈的哪个特定部分可能导致它吗?我不知该从这里走到哪里去 哇,这可能不是问题的根源,但您可能应该更新PhantomJS。1.8.2已经很老了。1.9.8是最新的,2.0即将面世。事实上,我也有同样的问题:@James_1x0 Woah,不知道这是一件事。有什么建议吗?作为记录,我已经将PhantomJS更新到1.9.7,但这个问题仍然存在。我的问题是,我的路线中有一个插座模式的断开连接插座,它使用了应用程序的parentView,出于一些无法解释的原因,这使得Test.PendingAjax请求卡在1,并且永远不会完成,因为从未调用ajaxComplete