Optimize waiting time for starting e2e tests
Current 2e2 running process is the following instructions:
{ npm run start & sleep 180 ; } && ./node_modules/.bin/wdio run ./wdio.conf.ts
This arbitrary waiting time can lead to unexpected errors when the angular server starting is too slow and the waiting is unnecessary to long for faster machines.
I propose to use the following script to have a better management of this running process:
#!/usr/bin/env bash
# Inspired from https://stackoverflow.com/a/25042323/5300212
# How to run e2e test after serving the app
# Start the web app
(npm start &)
NG_SERVE_PID=$!
# ng serve listen at port 4200
while ! nc -z 127.0.0.1 4200; do sleep 1; done
# Run wdio
npm run e2equick
# Cleanup daemon processes
kill -9 -$NG_SERVE_PID
Please note that this requires the installation of netcat on the docker image.