【问题标题】:Ember 2, acceptance testing, websocket pending hangs andThen() wating for pending to finishEmber 2,验收测试,websocket 挂起和 Then() 等待挂起完成
【发布时间】:2017-09-02 15:06:44
【问题描述】:

我第一次开始验收测试我的 Ember 应用程序。

所以我从 login 开始:

test/acceptance/login-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]", "user@email.com");
  fillIn("input[type=password]", "userpass");
  click("button[type=submit]");

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

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

我明白为什么。

在我的 app/templates/index.hbs 中,我有一个组件 notifications,它依赖于一个 websocket,它在我的单页应用程序中一直处于挂起状态(如果我打开Chrome 有一个待处理的 websocket 调用...)。

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

登录后我应该告诉andThen() 助手忽略一直处于待处理状态的service('notifications') 的待处理状态?

怎么办?

【问题讨论】:

    标签: sockets ember.js websocket ember-cli acceptance-testing


    【解决方案1】:

    对我来说,我遇到了这个问题,因为我使用了一种轮询方法,它在几秒钟内调用我的服务器来获取一些东西。我所做的是在测试模式下运行时禁用该代码

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

    AndThen() 基本上会在执行之前等待您的所有承诺得到解决。

    【讨论】:

    • 应该是Ember.testing,而不是Ember.test
    猜你喜欢
    • 1970-01-01
    • 2018-12-05
    • 1970-01-01
    • 2020-05-22
    • 1970-01-01
    • 2023-04-03
    • 1970-01-01
    • 2021-10-10
    • 2011-04-15
    相关资源
    最近更新 更多