How do I change the appID based on a parameter passed on the command line when running Maestro tests?
I'm aware that it's possible to set the app ID for a maestro test suite based on an env variable (Is it possible to run a single Maestro flow against two different app ids?), but how can I programmatically set the appID based on a more simple flag as a parameter?
I'd like to be able to run tests with either maestro test . -e android
or maestro test . -e iOS
, and for this I'd need to take that parameter and use it to work out the appID string programatically in javascript (I think?).
I have a rough idea of the javascript code to do this (see below), but not sure how to pull the parameter for this:
output.result = function getAppId() {
// Assuming parameters passed to Maestro can be accessed from command line arguments
const args = process.argv;
const isAndroid = args.includes("android");
// Default app ID
let appId = "com.ios.appid";
// If 'android' parameter is present, change the app ID accordingly
if (isAndroid) {
appId = "com.android.appid";
}
return appId;
};