stripe-playback
NPM module to make it easy to use stripe playback
with jest tests.
Example usage:
const { initializeYourApp } = require('./yourApp.js')
const { auto } = require('stripe-playback')
describe("test suite", () =>
const { playback, clientConfig } = auto();
beforeAll(() => {
const stripe = require("stripe")(
process.env.STRIPE_SECRET_KEY,
clientConfig
);
const expressApp = initializeYourApp(stripe, env);
app = supertest(expressApp);
});
playback(it)("your test case", () => {
return app
.post("/your-endpoint-that-hits-stripe")
.send({
paymentMethod: "pm_card_authenticationRequiredOnSetup",
})
.expect(200)
.expect((req) => {
expect(req.body.paymentMethod).toBeTruthy();
});
});
Start stripe playback server
cd /path/to/your/app
stripe playback
Run tests once to record, then on subsequent runs, the recordings will be used.