jejacks0n / teaspoon

Teaspoon: Javascript test runner for Rails. Use Selenium, BrowserStack, or PhantomJS.
1.43k stars 243 forks source link

Element does not get assigned #564

Open joshm1204 opened 5 years ago

joshm1204 commented 5 years ago

I apologize ahead of time if this is not the right place for this. Stackoverflow gets no response when posting issues with teaspoon-jasmine.

I can not get Stripe.JS to load.

describe("Helpers.Stripe.PaymentElement", function() {
  var PaymentElement;
  var html = `some HTML code`

describe("constructor", function(){
    beforeAll(function(){
      var head = document.getElementsByTagName('head')[0];
      var body = document.getElementsByTagName('body')[0];
      var tag = document.createElement('script');
      tag.setAttribute('type', 'text/javascript');
      tag.setAttribute('src', 'https://js.stripe.com/v3/');
      head.appendChild(tag);
      body.insertAdjacentHTML('afterend', html);

      PaymentElement = new Helpers.Stripe.PaymentElement();
    });

    describe("with defaults", function(){
      it("should define stripe", function(){
        expect(paymentElement.stripe).toBeDefined();
      });
    });
  });
});

I see an error:

ReferenceError: Can't find variable: Stripe in http://localhost:3000/assets/helpers/stripe/payment_element.self-36d1893424989c427cba11744bfc4fd5283eb212d58bb5174386dfd8973.js?body=1?body=1 (line 9)

So it seems that Stripe is not loading from the script tag.