-
Notifications
You must be signed in to change notification settings - Fork 29
Cannot use in (offline) tests #12
Copy link
Copy link
Open
Labels
Description
In test mode (at least in environments without networking), the <script> tag that this addon injects won't run and Stripe won't be defined. That means Stripe.setPublishableKey won't exist and the initializer will fail.
The smallest change I can think of that would work (which I've used locally successfully) is
// app/services/stripe.js
function createToken (card) {
Ember.assert("Cannot create Stripe token in test environment", config.environment !== 'test');
// ...
}
// app/initializers/stripe-service.js
export function initialize() {
if (config.environment === 'test') { return; }
// ...
}This isn't perfect, but it's pretty good. I end up stubbing out stripe.createToken whenever I need to actually run that function, with without a standard stubbing library, I can't think of a good way of doing this here.
Reactions are currently unavailable