Introducing the Inngest TypeScript / JavaScript SDK
Join our Discord
Sign up for free

run

We can use the inngest run command to execute your function locally against generated event payloads, specific events from the past, or a number of recent events.

We make it easy to test your function locally, not just against dummy data but also real production data in your dev environment. This functionality helps identify potential breaking changes before you make them or gives you confidence that a dangerous change does indeed still work.

Run your function with dummy data

In its most basic form, you can use inngest run to run your function locally against dummy data generated from your event's schema.

sh
$ inngest run

Here, the CLI uses the event triggers defined in the inngest.json|cue file and generates fake events based on the schema.

Dummy data is excellent for testing that your function handles the incoming schema but may not be ideal for functions with many conditional steps, where your actual data shines.

See it in action

Running a function with a generated event

Replay past events

The true power of inngest run is the ability to replay past events from either your production or test workspaces.

sh
$ inngest run --replay

Replaying is incredibly useful to ensure that a change to a function works as expected or when creating brand new functions based on existing events in your ecosystem. You can be sure your functions will run as expected in production without code ever leaving your machine.

See it in action

Running a function with past events

Replaying provides a couple of extra flags for customising the events that will be run.

Note that currently, if your function reacts to more than one trigger, you must provide which trigger you want to replay using --trigger [my-trigger]

sh
# Run your function with the last 20 events
$ inngest run --replay [-c/--count] 20
# Run your function with recent events from a specific trigger
$ inngest run --replay [-t/--trigger] stripe/customer.created
# Show input and output for each event and step
$ inngest run --replay --verbose

Replay a specific event

If you find an event causing problems for your function - or where the output wasn't quite as expected - you can choose to replay that specific event to ensure that the code change you're making will fix the issue.

No more testing in production! 🥳

sh
$ inngest run --replay --event-id 01G8BG4FT7CZVAD38D4RJNGTT1
See it in action

Running a function with a specific event

Run with local data

Events are always JSON, meaning it's easy to save an event's data locally and use it when testing via inngest run.

Pipe a JSON event (or an array of JSON events) into the command to run your functions with that data.

sh
$ cat snapshot.json | inngest run
See it in action

Running a function with snapshot data

You can create a snapshot by adding the --snapshot flag to any of the above commands, for example:

sh
# Snapshot the last 20 events
$ inngest run --replay -c 20 --snapshot > snapshot.json
# Snapshot 5 generated events
$ inngest run -c 5 --snapshot > snapshot.json
# Snapshot a single known problem event
$ inngest run --replay --event-id 01G8BG4FT7CZVAD38D4RJNGTT1 --snapshot