-
-
Notifications
You must be signed in to change notification settings - Fork 197
tns test android no reachable hosts #5167
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
Comments
Hey @jevenson ,
Do you think these solutions could work for you? |
I'll try one of those two options, thanks for the reply. Is the goal to allow running unit tests with |
@jevenson , the idea is to include a script on your side that sets const path = require("path");
const fs = require("fs");
const childProcess = require("child_process");
const os = require("os");
const pathToAndroidManifestInAppResources = path.join(__dirname, "app", "App_Resources", "Android", "src", "main", "AndroidManifest.xml");
const currentContent = fs.readFileSync(pathToAndroidManifestInAppResources).toString();
const newContent = currentContent.replace('android:usesCleartextTraffic="false"', 'android:usesCleartextTraffic="true"');
fs.writeFileSync(pathToAndroidManifestInAppResources, newContent);
const tnsExecutable = os.platform() === "win32" ? "tns.cmd" : "tns";
try {
const result = childProcess.spawnSync(tnsExecutable, ["test", "android", "--justlaunch"], { stdio: "inherit" });
console.log(result);
} finally {
fs.writeFileSync(pathToAndroidManifestInAppResources, currentContent);
} Currently it is not possible to run the test on API level 28 or above without this setting and we do not have plans to research other ways to achieve this. |
I do have the same issue in all my apps.
I cloned the following demo project: Adding |
@rosen-vladimirov Thanks for providing that script, that helps a lot. I understand that research will not be done to enable test execution with the usesClearTextTraffic set to true. Would it be appropriate to include that provided script in the NativeScript CLI? If it were included, I would imagine it would need to store the original value of the property and revert back to it after the test run completed. |
An another option could be to install
After that you can execute The downgrade of this approach is that the app will be rebuild every time when changing from |
I made a pul request, to display an error message when this error happen |
Environment
Describe the bug && Reproduction
I'm experiencing the same issue outlined in #4119.
Run
tns test android
withusesCleartextTraffic=false
, the test app shows "no reachable hosts". SettingusesCleartextTraffic=true
allows the tests to execute.I don't want to set
usesCleartextTraffic
to true with my production application, so I'm wondering how I get around this.Expected behavior
I expect the tests to run 😄
Additional context
This was supposed to be resolved with this pull request. I see that there is an AndroidManifest.xml file in those changes, and I'm wondering if that is supposed to override the settings in my application's manifest
NativeScript/nativescript-unit-test-runner#30
package.json
The text was updated successfully, but these errors were encountered: