努力应对验收测试。从基本登录测试开始:
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', "[email protected] /cdn-cgi/l/email-protection");
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");
});
});
问题是 andThen 回调在身份验证完成之前被调用。这是 jQuery ajax 请求和之后的一些承诺。据我所知,ember 等待 ajax 查询完成,但不等待承诺得到解决/拒绝。这个测试应该开箱即用吗?我必须写一个自定义服务员吗?
听起来你的承诺可能没有兑现吧?但不,您应该能够使用验收测试助手编写测试,而不必担心异步调用自己解决(或承诺解决)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)