We're running integration tests on our app and running into a problem working with the Stripe JavaScript library. We have a component that wraps the library and between when it begins the token creation process to when it completes the component gets destroyed (which in turn is failing the rest of our test.) The typical "fix" for this is to wrap that method in an Ember.run but it seems to have no affect on it. Let me give an example.
actions: {
update: function() {
// Starting here this.get('isDestroyed') == false
Stripe.card.createToken({
number: "xx",
cvc: "xx"
}, function() {
// Once we are here this.get('isDestroyed') == true
})
}
}
Because it's getting destroyed early the normal action here isn't taken. How can we get Ember to stay alive while waiting for this callback to complete?
Update 1
I posted an answer below but curious on why I wouldn't want to do this and/or why it's not part of the official documentation.
Update 2
This answer I posted below fixes the test but the actual site itself stops working (just sits there.) So while it seemed superficially to fix the problem it clearly didn't fully work.