Testing workflows
Learn more about how to test workflows you build in Knock.
Once you've built your workflow, you'll want to test it to make sure it works as expected. Knock provides a number of tools to help you test your workflows.
The workflow test runner
#You can use the Knock workflow test runner to test an end-to-end workflow and verify that it works as expected.
To use the workflow test runner, navigate to the workflow you want to test and click "Run a test." You'll have options to select the workflow's recipient, actor, tenant, and input any data that you'd like to pass to the workflow.
Two things to know about workflow test configuration:
- The data field is populated using the workflow's schema as defined in your templates. You can click "Reset" at any time to reset the data field to the latest and greatest schema for your workflow.
- The recipient and actor fields can contain either a user or an object. Use the toggle above the field to switch between these options.
After clicking "Run test," you will see a confirmation and a link to see the log to review the output and what was sent. You can learn more about Knock logs and the debugger here.
Note that trigger frequency is not enforced during test runs. Settings like "once per recipient" are bypassed — each time you run a test, the workflow will execute for the selected recipient regardless of your frequency setting. To validate trigger frequency as it behaves in production, use the trigger API.
You can also use the workflow test runner to run a test payload for a source event trigger. If your workflow is triggered by an event, you will automatically see a JSON payload of the last received event that you can use to run a test. You can edit this payload or click "Fetch the latest event" to get the most recent from your source.
Test run settings
#The test runner includes a few settings that control how the workflow executes during a test run:
- Sandbox mode. When enabled, all messages sent from the workflow are forced to send in sandbox mode. Knock generates and previews the messages without delivering them to the underlying providers, regardless of how sandbox mode is configured on each channel. This is useful for testing a workflow end-to-end without sending real notifications to your recipients.
- Skip delays. When enabled, all delay steps in the workflow are force skipped. The workflow runs straight through without waiting, which lets you verify the full execution path without waiting for delays to elapse.
You can also apply both of these settings when triggering a workflow via the API using the settings.sandbox_mode and settings.skip_delay properties, which is useful when testing workflows programmatically.
Testing workflows using the Knock CLI
#You can also generate workflow runs using the workflow run command from the Knock CLI. You can learn more in our CLI reference.