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

request: Start server only if it is not running. #379

Open
FDiskas opened this issue Mar 14, 2024 · 1 comment
Open

request: Start server only if it is not running. #379

FDiskas opened this issue Mar 14, 2024 · 1 comment

Comments

@FDiskas
Copy link

FDiskas commented Mar 14, 2024

If I already have running local server on port 1234
I was sure that start-server-and-test :1234 'cypress open --e2e --browser chrome' first will check if it is not running already before starting the local server.

Why this is not the case?

@benzado
Copy link

benzado commented Apr 24, 2024

How can it know if a server is already running? It could try connecting to the port, but that only confirms that something is listening... it could be a server from a different project!

I like that start-server-and-test will take ownership of the test server and terminates it when the tests are done. If it becomes too clever about using already running servers, it becomes too complex.

If your test server and development server are frequently fighting over the same port, may I suggest using a different port number for testing? You can even use a random port each time with a script like this:

#!/bin/bash

export PORT=$RANDOM
export CYPRESS_BASE_URL="http://localhost:$PORT"
npm exec -c "start-server-and-test start :$PORT 'cypress open'"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants