ember-simple-auth,验收测试和等待异步动作 [英] ember-simple-auth, acceptance tests and waiting for async actions

查看:182
本文介绍了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 -form__submit-button');

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

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

解决方案

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


Struggling with acceptance tests. Started with basic login test:

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");
  });
});

The problem is that andThen callback is called before authentication completes. It's jQuery ajax request and a few promises after. From what I can see ember waits for ajax query to complete, but doesn't wait for promises to get resolved/rejected. Should this test work out of the box? Do I have to write a custom waiter?

解决方案

It sounds like your promises may not be setup right? But no, you should be able to write tests using the acceptance test helpers and not need to worry about async calls settling (or promises resolving) yourself

这篇关于ember-simple-auth,验收测试和等待异步动作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆