Saturday, 6 July 2019

How to include script tag in teaspoon-Jasmine testing

How do I get the stripe script loaded so Stripe is defined during my Teaspoon-Jasmine testing.

Error:

Failure/Error: ReferenceError: Stripe is not defined

Teaspoon Tests:

describe("Stripe", function() {
  var paymentElement ;

  describe("constructor", function(){
    beforeAll(function(){
     // Tried this..

      var head = document.getElementsByTagName('head')[0];
      var jQueryScript = document.createElement('script');
      jQueryScript.setAttribute('type', 'text/javascript');
      jQueryScript.setAttribute('src', 'https://js.stripe.com/v3/');
      head.appendChild(jQueryScript);

     // also tried..

      $.getScript( "https://js.stripe.com/v3/");

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

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

    });
  });
});



from How to include script tag in teaspoon-Jasmine testing

No comments:

Post a Comment