2017-09-02 58 views
0

我开始第一次接受测试我的Ember应用程序。Ember 2,验收测试,websocket等待挂起,然后()等待完成

测试/接受/登录-test.js

所以我从登录这个开始

import { test } from "qunit"; 
import moduleForAcceptance from "myapp/tests/helpers/module-for-acceptance"; 

moduleForAcceptance("Acceptance | login"); 

test("Should login", function(assert) { 
    visit("/login"); 
    fillIn("input[type=email]", "[email protected]"); 
    fillIn("input[type=password]", "userpass"); 
    click("button[type=submit]"); 

    andThen(() => { 
    assert.equal(currentURL(), "/"); 
    assert.equal(find("h1").text(), "Hello!"); 
    }); 
}); 

永不熄灭的andThen(),所以它挂在click("button[type=submit]");

我明白为什么。

在我应用程序/模板/ index.hbs我有一个组件通知它依靠的WebSocket是不断地在我的单页的应用程序挂起(如果我打开Chrome浏览器存在未决的WebSocket调用.. )。

如果我从我的index.hbs中删除此组件,一切都按预期工作。

登录后,我应该告诉andThen()帮手忽略那个持续处于挂起状态的service('notifications')的挂起状态?

怎么办?

回答

1

对我来说,我正面临着这个问题,因为我使用了一种轮询方法,在几秒钟内调用我的服务器来获取内容。在测试模式

if(!Ember.testing){ 
    //polling 
} 

AndThen()运行时,我所做的就是禁用代码基本上等待所有你的承诺在执行之前得到解决。

+0

它应该是'Ember.testing',而不是'Ember.test'。 – TBieniek

+0

已编辑。感谢纠正我:) – Sandeep