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

Detox Port #694

Closed
Rob117 opened this issue Apr 26, 2018 · 7 comments
Closed

Detox Port #694

Rob117 opened this issue Apr 26, 2018 · 7 comments

Comments

@Rob117
Copy link

Rob117 commented Apr 26, 2018

Description

Very simply, my company has some kind of admin process (most likely a virus scanner) running on port 8081. This is a problem, because in order to run detox I need to go into the project and change every internal reference to 8088 (just some other random port I can use).

When I run react-native run-ios I get the option to pass flag --port=8088 to it so I don't need to manually configure those files. Does Detox have such a flag? Manually changing each port works, but on update / project copy, it has to be redone, which is error prone.

Steps to Reproduce

Block port 8081.
Try to run detox build

Detox, Node, Device, Xcode and macOS Versions

Detox: 7.3.4
OS: macOS Sierra 10.12.6
Node: 9.5.0
Yarn: 1.3.2
npm: 5.6.0
Watchman: 4.9.0
react: ^16.3.0-alpha.1 => 16.3.1
react-native: 0.54.4 => 0.54.4
Xcode: Xcode 9.2 Build version 9C40b
Android Studio: 3.1 AI-173.4670197

@Rob117
Copy link
Author

Rob117 commented Apr 26, 2018

As an addendum, can I just build with react-native run-ios --port=8088 and then have detox use that build on the correct port when I run detox test?

Edit: tried this. It works, but it unfortunately opens two simulators and closes neither upon completion.

@Salakar
Copy link

Salakar commented Apr 26, 2018

@Rob117 if it helps in the interim, I use https://www.npmjs.com/package/patch-package to automatically patch files in node_modules - it has a postinstall hook that will auto patch on npm/yarn install - I use this on a few react native projects myself - and a lot of other people do as well. You could use this to change the ports in node modules and then create a patch and commit that patch file as part of your git repo - until you can actually change the port in detox.

@Rob117
Copy link
Author

Rob117 commented Apr 27, 2018

@Salakar Absolutely awesome, will try as a stopgap until we can hopefully get a port feature!

@noomorph
Copy link
Collaborator

noomorph commented Apr 27, 2018

@Rob117, I am not sure whether Detox indeed has port 8081 hard-coded. Let's see:

git clone git@github.com:wix/detox.git
cd detox
git grep 8081

The only occurrence it prints is here, but this is just a test app for Detox E2E runs on CI:

detox/test/ios/example/AppDelegate.m:   jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle?platform=ios&dev=true"];

Did I overlook something? Could you point, please? As far as I understand it now, Detox doesn't use 8081 port specifically.

@rotemmiz
Copy link
Member

@noomorph , he refers to the packager port.
react-native cli has support for running the both the packager and the app on different ports for debug builds.

All it requires is running the build command with RCT_METRO_PORT as env variable.

I think running detox commands with this env var set will solve your problem.

RCT_METRO_PORT=8099 detox build {params}
RCT_METRO_PORT=8099 detox test {params}

@noomorph
Copy link
Collaborator

noomorph commented May 3, 2018

I wonder if we can close this one?

@Rob117
Copy link
Author

Rob117 commented May 3, 2018

The proposed solution works for me; absolutely. Marking as closed,

@Rob117 Rob117 closed this as completed May 3, 2018
@wix wix locked and limited conversation to collaborators Jul 23, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants