ember-simple-auth,验收测试和等待异步动作 [英] ember-simple-auth, acceptance tests and waiting for async actions
问题描述
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屋!