在Ember 2.3应用程序中,我正在使用条纹,我有这个验收测试:
it('can visit /user-subscription', () => {
visit('/');
andThen(() => {
click('#pay');
andThen(() => {
fillIn('#card_number', '4242424242424242');
fillIn('#cc-exp', '1299');
fillIn('#cc-csc', '444');
click('#submitButton');
andThen(() => {
done();
expect(currentPath()).to.equal('subscriptions.success');
});
});
});
});
当我点击pay
按钮时,它会显示带有此代码的条纹框:
var checkout = StripeCheckout.configure({
key: "...",
locale: 'fr'
}).open({
email: owner.get('email'),
amount: price,
token: (result) => {
# ...
}
});
它加载并执行外部脚本。在显示框之前测试失败。当测试失败时,外部脚本不会完全加载。
我将EmberCliMirage与this.passthrough('https://checkout.stripe.com/**');
一起使用。
如何让测试通过?
答案 0 :(得分:0)
您可以暂停测试,直到收到活动为止。 https://api.qunitjs.com/async/
let eventReceived = assert.async();
// ... callback for that async event ...
function eventComplete() {
eventReceived();
// ... do some more assertions
}
// supply the callback to something that knows about the external event