start-server-and-test icon indicating copy to clipboard operation
start-server-and-test copied to clipboard

Timeout: Tests never run

Open george-norris-salesforce opened this issue 6 years ago • 9 comments

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

huantaoliu avatar Jul 12 '19 21:07 huantaoliu

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.

hendrik-scholz avatar Aug 10 '19 16:08 hendrik-scholz

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.

dan-cooke avatar Dec 12 '19 14:12 dan-cooke

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",

nweiser1 avatar Jan 23 '20 14:01 nweiser1

I get the same problem, both locally and in CircleCI. This package seems to miss that the endpoint is available.

vlindhol avatar Feb 25 '20 09:02 vlindhol

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

nya1 avatar Mar 23 '20 11:03 nya1

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"
}

jeremyriverain avatar Feb 18 '21 21:02 jeremyriverain

Hello anynoe, I solved the problem by substituting http:127.0.0.1:yourport for http://localhost:yourport.

fontcoderrrrrrr avatar Apr 11 '23 10:04 fontcoderrrrrrr

@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

MikeMcC399 avatar Apr 11 '23 10:04 MikeMcC399