iamolegga / react-native-launch-arguments

Get launch arguments for testing with Detox and Appium
MIT License
55 stars 21 forks source link

Undefined values are not serialized correctly #41

Open jd20 opened 2 years ago

jd20 commented 2 years ago

Problem Description

If launch arguments are passed with an undefined value, when read back, those values are received as a string "undefined". For example:

import { device } from 'detox'
await device.launchApp({ launchArgs: { myValue: undefined } })

...

import { LaunchArguments } from 'react-native-launch-arguments'
const launchArgs = LaunchArguments.value()
console.log(inspect(launchArgs))

>>> { detoxSessionId: 'bd1e...', detoxServer: 'ws://localhost:65078', myValue: 'undefined' }

Expected Behavior

I would expect that when read back, the value should actually be undefined, not a string.

jd20 commented 2 years ago

Passing undefined values also fails on Android, but with an error:

TypeError: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received undefined