Search code examples
react-nativedetox

How to get the currently active configuration in a detox test


In the docs it is described how to add multiple detox configs to package.json

When I run the tests with detox --configuration someconfig, how do I find out the someconfig parameter in my tests (in someTestSuite.spec.js)?

Use case: in a test I want to set username and password textinputs based on the config, eg.

await getUNameTextInput().typeText('someUsernameBasedOnConfig');

Thanks.


Solution

  • There's a non official way of accessing the configuration name, and it may change in the future:

    const argparse = require('detox/src/utils/argparse');
    const configurationName = argparse.getArgValue('configuration');