Power Automate: Mock action outcomes
Learn how to speed up your Power Automate flows testing by mocking action outcomes using the “static result” action property. Speed up your testing and reduce these ten minutes of wasted time per run, to zero minutes! Imagine this scenario. You are building a complex Power Automate flow which involves hundreds of actions. You want to test a specific section, which unluckily comes after a five-layer approval, therefore, every time you want to test your section, you’re wasting at least ten minutes to complete all the five layers of approvals, before you can get to the section which you actually want to test. The worst part of the process is that the approvals aren't what you're after, they're already tested: what you want is for the flow to proceed to the section you do want to test. Well… you don’t need to deal with this frustration anymore. In this blog post, you’ll learn how to speed up your testing, and reduce these ten minutes of wasted time per run, to zero minutes. Yes… ZERO! One of the most time-consuming actions to complete is the “Start and wait for an approval”. This is because you must leave your flow designer, open Teams or Outlook, find your notification and complete the approval, then come back to the designer. So, for this blog post, I chose the “Start and wait for an approval” action as our example for a long running action whose outcome we can mock. However, you can use the same concept for most actions.
Let’s see how it works
In the steps below we will mock the outcome of the “Start and wait for an approval” action. We will do it in two steps:- Capture the action’s outcome
- Configure the action to return the same outcome for future flow runs, without manual intervention
Capture the action's outcome
Create a new, manually triggered, flow with two actions:
- Start and wait for an approval
- And Compose
- For Start and wait for an approval action, fill in the fields as you please
- In the Compose action, enter the outcome of the Start and wait for an approval action:
Use the Start and wait for an approval outcome for future flow runs
- Run the flow once, and complete the approval
- Now, go to your flow history and open the last run instance
- Expand Start and wait for an approval
- Click on Show raw outputs
- Add a comma after the “headers” line
- Paste the body you copied in step (5) above, on a new line
- Click Done
- Now run your flow
- It will skip running the Start and wait for an approval action, while Compose will still show the outcome that you selected in step (1) above