Local Integration Testing

I need to test my stripe webhook and also test against my d1 database after the webhook is ran which is not possible via vitest.
I cannot use vitest-pool-workers because the endpoint will not be available to my local machine, only the internal testing environment.
This is not possible stripe listen --forward-to localhost:PORT/endpoint

The first option listed here looks like my best choice:
https://developers.cloudflare.com/workers/testing/integration-testing/

My question is that if there is a better way to setup my tests than the following (Resembles option #1 from the above link):
  • Create my tests and route them to the following endpoint /test/...
  • Start dev server
  • curl localhost:PORT/test/...
Example of test
// Use stripe api to create a customer and create an invoice
stripeClient.createCustomer(...);
...
// Wait for the webhook to be called since stripe will receive the above event
...
// Check if the webhook successfully created a user in our backend
const user = db.getUser("...");
// expect user to be defiend
Cloudflare Docs
Test multiple units of your Worker working together.
Was this page helpful?