- 28 Mar 2023
- 3 Minutes to read
- DarkLight
Mock outputs
- Updated on 28 Mar 2023
- 3 Minutes to read
- DarkLight
Use mock outputs to execute steps without making the API requests they are based on and get a manually preconfigured response instead.
Mock outputs can be used to achieve a wide variety of goals, for example:
- Test workflow changes: run the workflow without all steps making changes to the production environment to test specific steps or changes you made.
- Test specific outputs: manually override the response of specific steps in the workflow to test the logic that follows in different scenarios, such as error scenarios, edge cases, and more.
- Get an output for a step without having to execute the steps before it: when adding new sections to a workflow, you can get a mock output for a previous step and use it for the development of the new section.This can also be useful when you want to test only a section of a very long workflow.
- Test the workflow without having all the integrations: when first building a workflow, you may not have all integrations configured yet. You can use a mock output as the response to specific steps that are blocking your progress.
How to use
- Select the step you want to create a mock output for and go to the Mock Output tab.
- In the Output field, provide the mock output. If available, the step output example will be suggested by default. You can use the suggestion, copy and modify the output of a previous execution of the step, or create your own mock output. To copy the output of a previous execution, go to the Execution Log tab and select one of the previous execution outputs.
To reference the step output example at any point, go to the step three-dot menu and select Output Example. This may be useful if you want to revert changes you've made.NoteThe mock output has to be a valid JSON, limited to 100 KB. - Switch the Enable mock output toggle to Yes. A step that has mock output enabled will be indicated by:
- Yellow step frame.
- Step execution: the Execute with mock output option will be added on top of the Execute option. Use execute with mock output to simulate the step execution and get the mock output as a response. Use the Execute option to run the step in production. See step 5 for information about the workflow execution with mock outputs.
- Select Execute with mock output. The mock data will be returned as the response and will be available in the context for other steps to reference.
- To run the workflow with mock outputs, click the arrow next to Test Run and select Test run with mock output. Selecting Test Run will execute the workflow in production.
- The step properties: input parameters, integration, and Execution Options (runners, ignore failure, discard data, and so on), are ignored when the step is executed with mock output.
- Mock output configurations are saved when the workflow is published (they don't affect executions in production) and will be available to use in any future development of the workflow.
- The mock output configurations will be exported and imported as part of the workflow.
Usage example
These examples demonstrate how mock outputs can be useful for different purposes.
Output example as mock output
Copy the step output example and modify the values to create a mock output that has the expected response structure with your test data. In the example below, a mock output for the Okta List Users with Filters step is created by using the step output example and modifying it to include the data of the users you don't mind testing the flow on.
Mock output to avoid API request
Use a mock output to get a preconfigured response for the step into the context for other steps to reference without having to execute the step in production. In the example below, a mock output is used for the Okta Suspend User step when running the workflow with real user data to avoid suspending anyone while being able to test the rest of the flow.
The example is a simplified version of the Suspend Contractor Accounts with no logins in 7 days template.
Mock outputs for nested workflows
You can use the instructions above to enable and configure a mock output for a nested workflow. Verify the expected nested workflow output by checking its Exit operators.
Go templates in mock outputs
You can use Go templates to customize your mock outputs even further. In the example below, the value of a variable from the context is being used to determine which of two mock output versions will be used.