vendredi 28 août 2015

Create a Mock for Stripe or use a Stub on Stripe object?

I'm writing tests for my Backbone app which uses Stripe. I am using mocha-phantomjs to run the tests. In my index.html file I ha <script src="http://ift.tt/KXmU7y" type="text/javascript"></script> to get the code for Stripe. However when I run the tests, I get the error: ReferenceError: Can't find variable: Stripe, which makes sense, because I'm not running the command for the tests with a ssl certificate.

I got it working by creating a local js file and copied stripe's minified code into it, thus overriding the need of a ssl certificate and my tests passed.

However my question is if this is best practice?

Should I rather create a sinon mock object of Stripe and use that instead or would it make more sense to stub the Stripe object as to prevent any calls being made to the Stripe API?

Aucun commentaire:

Enregistrer un commentaire