this repository demostrates an issue (nock/nock#2785, stripe/stripe-node#2211) where API requests from the stripe SDK aren't being intercepted by nock@beta
, nor its underlying interceptor library (@mswjs/interceptors
).
with node.js installed (this was tested on v20.16.0), run the following commands:
npm install
node nock.js # nock@beta
node msw.js # @mswjs/interceptors
note how the stripe.customers.create
function in request.js
hangs.
if you install nock@14.0.0-beta.7
or nock@latest
, the stripe SDK will successfully make the request:
npm install nock@14.0.0-beta.7
node nock.js
configure the stripe SDK to use fetch
by making the following change in request.js
:
-const stripe = new Stripe("your-stripe-secret-key");
+const stripe = new Stripe("your-stripe-secret-key", { httpClient: Stripe.createFetchHttpClient() });