React Native E2E tests - Unable to run mock server (express app) in background

I have E2E tests for my React Native app that are written using Detox & YakBak. Although my tests are currently failing as it is unable to ping the mock express server that is running in the background.

About:

Here’s a brief explanation on how the system works:

  • E2E tests are written in React Native using Detox
  • The tests are running in “testing” schema on ios which hits localhost:3001
  • There is an express app running on localhost:3001 with Yakbak
  • If the request is made for the first time, it hits localhost:3000 & saves the response in tapes.
  • The next time that same response is made, it returns the tape and doesn’t hit the actual server

Hence once all the tapes are recorded, we can run our E2E tests with pre-recorded tapes and without actually hitting our backend servers (localhost:3000 or any other url)

Problem:

In my Bitrise workflow, I have a step that starts this express server and runs it in the background:
node proxy_server.js &>/dev/null &

When the tests run and it tries to make a network request to localhost:3001, it is unable to hit the express server and the tests fail.

Hence I need help trying to figure out why the express server in the background is not accessible.

Also the reason I think this is a Bitrise issue is that I was able to download the bitrise.yml file and run the same workflow locally on my computer and it ran the express server in the background and passed all the tests.

If anyone has any ideas/way to diagnose this issue, please let me know. Thanks for your help in advance!

Debugging Logs

Step that runs the express server in the background:

Running the express app as a background process like so:
node proxy_server.js &>/dev/null &

And here is the output showing that the node process is running successfully:

+ node --version
v8.12.0
+ which node
/usr/local/bin/node
+ cd e2e/mock
+ pwd
/Users/vagrant/git/e2e/mock
+ node proxy_server.js
+ ps -ef
+ grep 'node proxy_server.js'
  501  3869  3866   0  4:17PM ??         0:00.00 node proxy_server.js
  501  3871  3866   0  4:17PM ??         0:00.00 grep node proxy_server.js

^^ looks like the express server is running!?

Failing Build: https://app.bitrise.io/build/2eb7dd7a74ecf799

Let me know if you need more infomation to debug this issue.

Hy! in this log the node proxyserver.js is commented out, so I can’t really check the issue

but my concern is that if you try to start up a server like this, it will hang the terminal no matter what :thinking:

Hi @fehersanyi-bitrise! Thanks for your response.

I am not sure I understand what you mean by "node proxy_server.js is commented out, so I can’t really check the issue". It is running in the workflow and if you see the logs, that command is running. Would it help if I shared the entire proxy_server.js file with you? It’s basically a simple express app

Also, I am starting the server as a background process. So it shouldn’t hang the terminal technically. Here is how I am doing it:
node proxy_server.js &>/dev/null &

I ran this on my mac which is a unix type machine and it seems to work in the background successfully. Let me know if I can provide any more information regarding this.

Hy!

I discussed the matter with an infra engineer, and it could be that the container in which the build runs has localhost rooted out to the host machine so, could you try it either with 0.0.0.0 or 127.0.0.1 instead of localhost?

Thanks for following up @fehersanyi-bitrise! :+1:

That would make sense. Although I tried them both and neither of them worked unfortunately.

Can you please share how I can SSH into the build container and maybe I can poke around that way?

Also kindly let me know if you have any other suggestions as well or if one of the infra engineers can help me debug it on their end.

Hy there!
here is guide on ssh connecting to the vm https://gist.github.com/viktorbenei/afccc1a777de027daf64f9331c6892fc
I hope you will be able to solve the issue while in there.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.