Have you ever needed to run your AskUI Workflows in parallel on multiple devices to speed up the execution?
That is possible with a little bit of configuration in Jest, the runner used to execute AskUI Workflows, and multiple AskUI Controllers.
This blog will walk you through the setup for two Android devices and running a bunch of workflows.
Prerequisites
- AskUI installed and configured on your system (Windows, Linux, macOS)
- GitHub repository to follow along
Start AskUI Controllers
⚠️ The commands shown below start the AskUI Controller on your local machine as we are controlling two Android devices. If you want to run your workflows on a remote machine, install and start the controllers there. Do not forget to get the IP of the remote machine for the URL to the controller!
Windows
Jest
Next comes Jest, the javascript framework AskUI uses to run its workflows.
.env
For Configuration Environment Variables
First, we want to have a way to configure how many parallel processes are running workflows. For this, we install the dotenv
package like this:
Then we create a file .env
in the root of the project and fill it with the following. We set the JEST_MAX_WORKER
to two as we have two Android devices:
Configure Maximum Parallel Workers in jest.config.ts
We need the max workers feature from Jest which allows us to specify the number of workers that should run in parallel. It can be configured in the file jest.config.ts
. We use the environment variable JEST_MAX_WORKER
from the .env
file.
Connect AskUI Controllers in askui-helper.ts
In the askui-helper.ts
we hold an array of all AskUI Controller URLs we want to target. We take the configured maxWorkers
and the workerId
to connect each worker with a different AskUI Controller.
⚠️ If you do not use two Android devices and the AskUI Controller runs on a remote system, you must change the URLs in the uiControllerDeviceList.
When you start your run with this configuration you will see that the *.test.ts
files will be executed in parallel and ONLY once. Each worker will generate a separate report, giving you detailed insights into the execution.
The important thing is that each worker is completely independent and encapsulated. This means the setup process from askui-helper.ts
will run separately for each worker! This ensures that the workflows do not interfere with each other.
Conclusion
With a little bit of Jest configuration and multiple AskUI Controllers you can parallelize the execution of your AskUI Workflows.
If you have questions or need support, do not hesitate to join our Outverse-Community.