Reputation: 947
After upgrading to Angular 6, ng e2e
doesn't run on available port.
For example, if you take the previous version of Angular (we were previously using 4), you will be having the app service in port number 4200 and when we simultaneously run ng e2e
, it used to pick a free port (like 49152) to run tests.
After Angular 6 upgrade, when I try to run the tests on similar scenario, it fails with the error message "Port 4200 is already in use".
I don't want to manually pass --port {port number}
to the command for CI purposes since hardcoding port numbers will have problems in parallel executions in CI. Something broke during the upgrade to Angular 6, should I change the configuration?
Upvotes: 6
Views: 2624
Reputation: 947
I was able to find the solution for this.
Just run ng e2e <app-name> --port 0
to run on available ports.
When this command executes, the tests will look for available ports in case of parallel execution. We don't need to explicitly hardcode or provide port numbers every time.
Upvotes: 5
Reputation: 521
I ran into a similar problem. You could try something like this: In your package.json
file, in scripts
you can enter "e2e": ng e2e --port number
from there, within the command line, you can enter npm run e2e
.
Upvotes: 1