Skip to content

Commit

Permalink
add blacklistRegex to GREYConfiguration on init (#1000)
Browse files Browse the repository at this point in the history
* add blacklistRegex to GREYConfiguration on init

* pr feedback: docs
  • Loading branch information
quinlanj authored and LeoNatan committed Oct 29, 2018
1 parent da924e7 commit 3ce07f2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
5 changes: 5 additions & 0 deletions detox/ios/Detox/DetoxManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ static void detoxConditionalInit()

NSUserDefaults* options = [NSUserDefaults standardUserDefaults];

NSArray *blacklistRegex = [options arrayForKey:@"detoxURLBlacklistRegex"];
if (blacklistRegex){
[[GREYConfiguration sharedInstance] setValue:blacklistRegex forConfigKey:kGREYConfigKeyURLBlacklistRegex];
}

NSString *detoxServer = [options stringForKey:@"detoxServer"];
NSString *detoxSessionId = [options stringForKey:@"detoxSessionId"];
if (!detoxServer || !detoxSessionId)
Expand Down
12 changes: 11 additions & 1 deletion docs/APIRef.DeviceObjectAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,16 @@ With this API, you can run sets of e2e tests per language. For example:
});
```

##### 10. Initialize the URL blacklist at device launch
Launch the app with an URL blacklist to disable network synchronization on certain endpoints. Useful if the app makes frequent network calls to blacklisted endpoints upon startup.

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

### `device.relaunchApp(params)`
**Deprecated** Use `device.launchApp(params)` instead. This method is now calling `launchApp({newInstance: true})` for backwards compatibility, it will be removed in Detox 6.X.X.<Br>
Kill and relaunch the app defined in the current [`configuration`](APIRef.Configuration.md).
Expand Down Expand Up @@ -254,7 +264,7 @@ await device.setLocation(32.0853, 34.7818);

### `device.setURLBlacklist([urls])`

Disable [EarlGrey's network synchronization mechanism](https://github.com/google/EarlGrey/blob/master/docs/api.md#network) on preffered endpoints. Useful if you want to on skip over synchronizing on certain URLs.
Disable [EarlGrey's network synchronization mechanism](https://github.com/google/EarlGrey/blob/master/docs/api.md#network) on preferred endpoints. Useful if you want to on skip over synchronizing on certain URLs. To disable endpoints at initialization, pass in the blacklist at [device launch](#10-initialize-the-url-blacklist-at-device-launch).

```js
await device.setURLBlacklist(['.*127.0.0.1.*']);
Expand Down

0 comments on commit 3ce07f2

Please sign in to comment.