Using fixtures with Stripe CLI
I want to test my API behaviour by triggering some specific requests using Stripe CLI.
For example:
stripe trigger customer.subscription.deleted # with some fixture here
There is a fixtures command documented as a feature but I do not know how to use it. The documentation says:
The fixtures command lets you run a json file as a series of API requests. This can be useful for things like filling data, executing specific flows, or testing API behavior.
https://github.com/stripe/stripe-cli/wiki/fixtures-command
How do I load fixtures into the CLI?
The first step is to create a JSON file with the fixtures in it. The documentation you linked to gives one such example, but it may make it easier for you to get started if you:
- Find the closest available trigger to what you want to do
- Locate the corresponding fixture file in the repo
- Modify it to suit your needs
You can then execute the fixture with stripe fixtures name_of_your_fixture_file.json
You can look up available triggers in the trigger documentation. Remember that fixtures are just going to make a series of API requests, with each object in the fixtures
array representing one API call, so you can do anything specified in the API docs.