5

我们已经有一个应用程序正在为 CI 添加测试用例。

我们有一个小代码尝试登录过程并检查可能的登录状态(如成功、失败、无效帐户帐户锁定等)后会发生什么。

所以我尝试了以下代码。

visit('/login')
    .fillIn('#identification', "testuser")
    .fillIn('#password', "testpass")
    .click('input[type="submit"]')
    andThen(function(){
        ok(!exists('button:contains(sign in)'), '3. Login button is not displayed when authenticated');
        ok(exists('.dropDownMenuOptions li:contains(Logout)'), '4. Logout button is displayed when authenticated');
    });

它在控制台中给出以下错误。

ember.debug.js:5162 Uncaught Error: Assertion Failed: You have turned on testing mode, which disabled the run-loop's autorun. You will need to wrap any code with asynchronous side-effects in a run

执行单击后会发生此错误。当单击对服务器进行 AJAX 调用并在其响应时进行路由转换。

对于成功登录的情况,我想检查我的路线是否因此错误而无法/login更改。/

请建议。

谢谢

4

1 回答 1

14

在处理表单提交的控制器/组件中,您必须执行一组操作(示例)

save: function() {
    this.get('model').set('name', 'foo');
}

如果这项工作是在一些 ajax 事件之后在运行循环(异步)中完成的,请确保像这样用 ember run 包装它

save: function() {
    Ember.run(function() {
        this.get('model').set('name', 'foo');
    });
}
于 2015-07-17T14:18:37.983 回答