Detox: detoxURLBlacklistRegex in launchArgs not working (always nil)

  • I have tested this issue on the latest Detox release and it still reproduces

Description

No matter what value I set detoxURLBlacklistRegex to in launchArgs when launching the app, it is always nil when picked up in the native code.

If I replace [options arrayForKey:@"detoxURLBlacklistRegex"];with @[@".*"]; my tests run as expected. I’ve tried setting the values to all of the following:

  • The example: '\\("http://192.168.1.253:19001/onchange","https://e.crashlytics.com/spi/v2/events"\\)'
  • '\\(".*"\\)'
  • '\\(.*\\)'
  • ['.*']

Reproduction

  1. Update detox/ios/Detox/DetoxManager.m to print out “blacklistRegex”
  2. Run detox tests using detoxURLBlacklistRegex in launchApp (as mentioned in the docs)

Expected behavior

The value should be set to what is passed in detoxURLBlacklistRegex

Environment (please complete the following information):

  • Detox: 15.1.2
  • React Native: 0.61.5
  • Node: 12.14.1
  • Device: iPhone 8 (tried on multiple)
  • Xcode: 11.3.1
  • iOS: 13.3
  • macOS: 10.14.5

Logs

If you are experiencing a timeout in your test

Omitting the log for brevity. It shows a lot of App State -> busy Waiting for network requests to finish: ... logs while launching

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 3
  • Comments: 34 (19 by maintainers)

Most upvoted comments

@LeoNatan

This likely broke after the rewrite of arguments. It means this feature is broken.

Is there a specific version of Detox we can use in the meantime until this gets sorted out?

@mckenzit Have you seen my comment?

You would then have to do :

const detoxURLBlacklistRegex = getDetoxURLBlacklistRegexFromDomains(['pndsn.com']);
await detox.init(config, { launchApp: false, detoxURLBlacklistRegex });

What’s the status here, then? Should we pin or close?

@Minishlink, it works! Weird that I tried a very similar function that didn’t. I think a friendlier API would make sense. Maybe just accept an array of url regex strings?

Hello, I dug into this issue and couldn’t find where it was altered. I played with NSUserDefaults and launch args in XCode, and in fact there’s no problem with detox.

You can use this function to generate the correct value of detoxURLBlacklistRegex from a list of domains:

const getDetoxURLBlacklistRegexFromDomains = domains =>
  '(' + domains.map(domain => `\\".*${domain}.*\\"`).join(',') + ')';

This generates the following CLI arg, with your example @michaelgmcd :

-detoxURLBlacklistRegex "(\".*codepush.azurewebsites.*\",\".*clients3.google.*\",\".*googleapis.*\",\".*app-measurement.*\",\".*crashlytics.*\")"

Happy to do a PR to add a more friendly API if need be.

Hey @LeoNatan, following up here. What are the next steps? I’d love some advice on how to debug this a little better. The “Debugging in XCode” doc doesn’t seem to apply here because we’re launching the app a different way.

Not good!