Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add blacklistRegex to GREYConfiguration on init #1000

Merged
merged 2 commits into from
Oct 29, 2018

Conversation

quinlanj
Copy link
Contributor

Allow the user to set the blacklist for EarlGrey upon initialization of the DetoxManager. This will also help fix #917

Why

When device.launchApp is called, it waits for the device to be ready. In order for the device to be ready, all the tracked Earl Grey resources must be idle. Because Earl Grey tracks all network requests by default, if there are any network calls happening, the app will be considered 'busy'.

Consider the case where an app is making many network calls to an URL we wish to be blacklisted. First, the app must be launched via device.launchApp. Next, the blacklist needs to be set via device.setURLBlacklist. However, because there is currently no way to set the blacklist upon initialization, Earl Grey will always consider the app to be 'busy' and the call to device.launchApp will hang.

This can be solved if the user is able to pass in their own blacklist array in launchApp like this:

  await device.launchApp({
    ...
    newInstance: true,
    launchArgs: { detoxURLBlacklistRegex: ' \\("http://192.168.1.253:19001/onchange","https://e.crashlytics.com/spi/v2/events"\\)' },
  }); 

@quinlanj quinlanj requested a review from LeoNatan as a code owner October 27, 2018 01:07
@LeoNatan
Copy link
Contributor

This sounds like a good idea. Thanks for this PR!

@LeoNatan
Copy link
Contributor

Do you mind updating the documentation of launchApp and setURLBlacklist to mention this new feature? Thanks

Copy link
Contributor

@LeoNatan LeoNatan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update documentation with the new API. Thanks

@quinlanj quinlanj requested a review from rotemmiz as a code owner October 29, 2018 19:51
@quinlanj quinlanj force-pushed the quin_detox_blacklist_pr branch from 870df31 to a908d21 Compare October 29, 2018 19:54
@quinlanj
Copy link
Contributor Author

@LeoNatan added some docs, lmk if they are ok!

@LeoNatan
Copy link
Contributor

Looks great, thank you!

@LeoNatan LeoNatan merged commit 3ce07f2 into wix:master Oct 29, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Nov 2, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Detox hangs on detox config step with expo iOS
2 participants