-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
detoxURLBlacklistRegex in launchArgs not working (always nil) #1861
Comments
Can you please print |
I wonder if the syntax of what is passed is perhaps not correctly understood by the system, and thus not parsed correctly as an array, which then returns |
I wasn't able to easily print
Relevant logs:
|
Ah, I think the syntax is incorrect. It needs to be an array of strings. You are missing the |
You can see in several places in the second log (example below) that I am passing strings. They're being stripped out somewhere:
|
Not good! |
Mind linking to the "rewrite of arguments"? I'd love to dive a little deeper into this. |
Yikes, are we lacking e2e coverage there? @michaelgmcd have you happened to have tried this out on Android? |
A quick note here, |
@rotemmiz The issue is the lack of quotes, because they are stripped. NSUserDefaults then fails to parse the array of strings as such. |
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. |
I am not familiar with the JS side of things. If you’d like to help us debug, please follow the launch arguments from the user-facing launch API to where it is actually sent. Somewhere there is a bug that causes incorrect stripping of quotes and possibly other characters. Thanks |
I dug a little bit into this and everything up until the native code seems ok. Below (from AppleSimUtils.js) is the only place that manipulates and uses the launch args: ...
_joinLaunchArgs(launchArgs) {
return _.map(launchArgs, (v, k) => `-${k} "${v}"`)
.join(' ')
.trim();
}
async _launchMagically(frameworkPath, udid, bundleId, launchArgs, languageAndLocale) {
const args = this._joinLaunchArgs(launchArgs);
const statusLogs = {
trying: `Launching ${bundleId}...`,
};
let dylibs = `${frameworkPath}/Detox`;
if (process.env.SIMCTL_CHILD_DYLD_INSERT_LIBRARIES) {
dylibs = `${process.env.SIMCTL_CHILD_DYLD_INSERT_LIBRARIES}:${dylibs}`;
}
let launchBin =
`SIMCTL_CHILD_DYLD_INSERT_LIBRARIES="${dylibs}" ` +
`/usr/bin/xcrun simctl launch ${udid} ${bundleId} --args ${args}`;
if (!!languageAndLocale && !!languageAndLocale.language) {
launchBin += ` -AppleLanguages "(${languageAndLocale.language})"`;
}
if (!!languageAndLocale && !!languageAndLocale.locale) {
launchBin += ` -AppleLocale ${languageAndLocale.locale}`;
}
const result = await exec.execWithRetriesAndLogs(launchBin, undefined, statusLogs, 1);
return result;
}
... The arguments to
|
I've tried escaping the
|
Any news on this? |
Is there a specific version of Detox we can use in the meantime until this gets sorted out? |
I'm sorry, I'm not sure which version introduced this issue. It was a while back. Contributions are welcome. |
@michaelgmcd when you escape those is there an easy way to set the logging through websockets up? |
@jaburx I'm missing in the docs, when is the right time to call is it before the problem is I'm using detox for Expo ejected app and it gets stuck on |
Sending the param as launch argument and using |
Its after init |
Hey Leo, we know that, but u guys were asking for a way to run it. |
But the suggestion doesn't work here, because if an app makes requests on launch, Detox will be stuck waiting for them, unable to reach idle state, so it can process the |
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 const getDetoxURLBlacklistRegexFromDomains = domains =>
'(' + domains.map(domain => `\\".*${domain}.*\\"`).join(',') + ')'; This generates the following CLI arg, with your example @michaelgmcd :
Happy to do a PR to add a more friendly API if need be. |
@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? |
Is there any solution that doesn’t involve diving into the workings of Detox, and just using the If there is (having kept a close eye on this bug) I would be very grateful to know what regex I would need to blacklist pub-nub domains. I.e. ps1.pndsn.com, ps2.pndsn.com, ps3.pndsn.com, ps22.pndsn.com etc etc I know it would seem straightforward, but nothing seems to work. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions! For more information on bots in this reporsitory, read this discussion. |
What's the status here, then? Should we pin or close? |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions! For more information on bots in this reporsitory, read this discussion. |
The issue has been closed for inactivity. |
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:'\\("http://192.168.1.253:19001/onchange","https://e.crashlytics.com/spi/v2/events"\\)'
'\\(".*"\\)'
'\\(.*\\)'
['.*']
Reproduction
Expected behavior
The value should be set to what is passed in detoxURLBlacklistRegex
Environment (please complete the following information):
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 launchingThe text was updated successfully, but these errors were encountered: