mobile-dev-inc / maestro

Painless Mobile UI Automation
https://maestro.mobile.dev/
Apache License 2.0
5.81k stars 273 forks source link

React Native boolean launch arguments #2015

Open christinachimi opened 1 month ago

christinachimi commented 1 month ago

Is there an existing issue for this?

Steps to reproduce

Create a test file with a boolean launch argument:

appId: com.myapp.development
---
- launchApp:
    appId: com.flyzipline.partner.portalapp.development
    arguments:
      isFoo: true
- assertTrue: true

In my app code, I use react-native-launch-arguments to get the value, something like:

LaunchArguments.value().isFoo === true

Actual results

The argument seems to be undefined in my app code.

Expected results

I expect the argument to be true.

About app

React Native Expo app, testing on iOS Simulator. React native version 0.74.3, react-native-launch-arguments version 4.0.2, expo 51.0.22.

About environment

Logs

Logs ``` ```

Maestro version

1.37.9

How did you install Maestro?

Homebrew

Anything else?

This may just be a documentation bug. I am able to get this working by providing the argument as a string. When I do that it is available to my app as a boolean which is great. But the docs indicate that it can be set as a boolean in the yaml file which doesn't seem to be the case, at least not for React Native.

3KINGZ commented 1 month ago

@christinachimi were you able to fix this?

christinachimi commented 1 month ago

@3KINGZ providing the argument as a string works, so it's "fixed" in that sense, but I still think either the docs or the actual functionality is wrong.

kanzelm3 commented 1 month ago

I am seeing this issue, but I am also seeing an issue where on Android, my launch args are empty altogether. LaunchArguments.value() just returns an empty object.

3KINGZ commented 1 month ago

@christinachimi thanks that works

3KINGZ commented 1 month ago

I am seeing this issue, but I am also seeing an issue where on Android, my launch args are empty altogether. LaunchArguments.value() just returns an empty object.

@kanzelm3 are you getting even after passing the arguments as a string type?

AdamTyler commented 2 weeks ago

I tested on Android with a the following:

appId: ${APP_ID}
---
- launchApp:
    arguments:
      isE2E: true
      coolThing: 'Launch app with E2E flag'

And using the following in my app:

import { LaunchArguments } from 'react-native-launch-arguments';

console.log('Launch Args:', LaunchArguments.value());

on Android I see this

image
cmw9706 commented 1 week ago

Just a heads up, if you are using Typescript you can do something like

type MyLaunchArgs ={
myArg:boolean
}
LaunchArguments.value<MyLaunchArgs>().myArg

Typescript will do the cast for you