使用 ember.js v 1.5.1。
我使用 karma 和 qunit 来测试我的 ember 应用程序。在我的几个测试中,我遇到以下情况:1.用户单击->2.对我们的服务器进行异步调用->然后 3.通过控制器中的“this.transitionToRoute('someroute')”进行转换. 当它在测试时遇到 transitionToRoute 方法时,业力挂起。尝试用 ember.run 调用来包装它,但似乎没有帮助。
当我注释掉转换调用时,它会运行,并相应地失败。
示例测试代码,它挂起并且没有达到相等的调用
test('successful registration request', function() {
setupMockRegistrationRequests();
visit("/register")
.fillIn('#email', 'test2')
.fillIn('#password','password')
.click('#submit')
.andThen(function() {
equal(find(".register-page .form-alert").length, 0, "Should be no error");
equal(find(".login-page").length, 1, "Should be on login screen");
});
});
控制器代码
测试用例运行
//this.transitionToRoute('login');
测试用例挂起
this.transitionToRoute('login');
任何人都知道它为什么挂起?/我能做些什么来让它继续下去?