ember-simple-auth,验收测试和等待异步操作

时间:2017-04-21 16:16:49

标签: testing asynchronous ember.js acceptance-testing ember-simple-auth

在验收测试中苦苦挣扎。从基本登录测试开始:

import { test } from 'qunit';
import moduleForAcceptance from 'static/tests/helpers/module-for-acceptance';

moduleForAcceptance('Acceptance | authentication');

test('login', function(assert) {
  visit('/');
  click('.nav-bar__login-link');
  andThen(function() {
    assert.notOk(find('.login-form__submit-button').attr('disabled'));
  });

  fillIn('.login-form__email-block input', "ruz@email.com");
  fillIn('.login-form__password-block input', "qwe");
  click('.login-form__submit-button');

  andThen(function() {
    console.log("ftw");
    assert.equal(find('.nav-bar__profile-link').text(), "some");
  });
});

问题在于,然后在身份验证完成之前调用回调。这是jQuery ajax请求和之后的一些承诺。从我可以看到,ember等待ajax查询完成,但不等待承诺得到解决/拒绝。该测试是否应该开箱即用?我必须写一个自定义服务员吗?

1 个答案:

答案 0 :(得分:0)

听起来您的承诺可能无法正确设置?但不,你应该能够使用验收测试助手编写测试,而不必担心异步调用自己解决(或承诺解决)

相关问题