start-server-and-test
start-server-and-test copied to clipboard
Timeout: Tests never run
Start-server-and-test starts server and I can navigate the localhost:5000.
But the tests never run.
{
"start-server-and-test": "^1.9.1",
}
OS X 10.13.6
...
"test:cypress": "NODE_ENV=test start-server-and-test start http://localhost:5000 cy:run",
"cy:run": "cypress run",
...
starting server using command "npm run start"
and when url "http://localhost:5000" is responding
running tests using command "npm run cy:run"
tests never run results in this error
Error: Timeout
at Timeout._onTimeout (/Users/geo/Code/MyProject/node_modules/wait-on/lib/wait-on.js:110:10)
at ontimeout (timers.js:436:11)
at tryOnTimeout (timers.js:300:5)
at listOnTimeout (timers.js:263:5)
at Timer.processTimers (timers.js:223:10)
you can try change http to http-get
start-server-and-test start http-get://localhost:5000 cy:run
It might have something to do with the way wait-on works. The library is used to check whether resources are available.
"For http(s) resources wait-on will check that the requests are returning 2XX (success) to HEAD or GET requests (after following any redirects)." https://www.npmjs.com/package/wait-on
Since the endpoint http://127.0.0.1:3000 was not implemented in my application, an HTTP status code 404 was returned and start-server-and-test waited until the configured timeout. I changed start-server-and-test start http://127.0.0.1:3000 test to start-server-and-test start http://127.0.0.1:3000/authorization test so that wait-on got an HTTP status code 200. After that start-server-and-test ran the tests as expected.
Same issue here with next-js application.
yarn run v1.19.1
$ start-server-and-test dev http-get://localhost:5000 cypress:open
starting server using command "npm run dev"
and when url "[ 'http-get://localhost:5000' ]" is responding
running tests using command "npm run cypress:open"
Endpoint is returning a 200 on initial bundle request.
having a similar issue when i use the hard coded machine ip - it works but when i put it localhost or 127.0.0.1 it does not work tried using http-get, same issue "start:server-and-client": "start-test start:server http-get://localhost:3000 start:client",
I get the same problem, both locally and in CircleCI. This package seems to miss that the endpoint is available.
You can try with tcp:PORT as the url according to https://github.com/jeffbski/wait-on
with that it should start when the specified port is open for connections
As @nya1 advised, the tcp:PORT option was my solution
{
"test": "start-server-and-test 'npx http-server . -c-1 --silent -p 5555' tcp:5555 cypress:run"
}
Hello anynoe, I solved the problem by substituting http:127.0.0.1:yourport for http://localhost:yourport.
@fontcoderrrrrrr
I solved the problem by substituting http:127.0.0.1:yourport for http://localhost:yourport/.
- This is the workaround described in https://github.com/jeffbski/wait-on/issues/137