lundi 14 mars 2016

Wait for external event in acceptance tests

In an Ember 2.3 app, I'm using stripe and I have this acceptance test :

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

When I click on pay button, it show the Stripe box with this code :

  var checkout = StripeCheckout.configure({
    key: "...",
    locale: 'fr'
  }).open({
    email: owner.get('email'),
    amount: price,
    token: (result) => {
      # ...
    }
  });

It loads and execute and external script. The test is failing before the box is displayed. The external script is not loaded completely when the test fail.

I'm using EmberCliMirage with this.passthrough('http://ift.tt/1M3WU9o');.

What can I do to make the test pass?

Aucun commentaire:

Enregistrer un commentaire