start-server-and-test
start-server-and-test copied to clipboard
Timeout does not work resulting in ESOCKETTIMEDOUT using cypress
Hi,
I am using start-server-and-test (v1.9.1) in combination with cypress (v3.3.1), as described here: https://docs.cypress.io/guides/guides/continuous-integration.html#Solutions with the command
start-server-and-test start http://localhost:3000 cypressRunChrome
According to the description of the 5-Minute-Timeout utility, it should wait until the server is ready and responds. This seems not to work in my case, resulting in an ESOCKETTIMEDOUT error while running the tests. I the log file, I see that the dev server starts at 11:18:53, it is ready at 11:20:08, but the test are already starting at 11:19:14.
I am expecting that start-server-and-test start is waiting, but for some reasons, it does not.
Log snippet:
11:18:47 starting server using command "npm run start"
11:18:47 and when url "http://localhost:3000" is responding
11:18:47 running tests using command "npm run cypressRunChrome"
11:18:48
11:18:48 > [email protected] start C:\...
11:18:48 > react-scripts start
11:18:48
11:18:53 Starting the development server...
11:18:58
11:18:58 > [email protected] cypressRunChrome C:\...
11:18:58 > cypress run --browser chrome
11:19:14
11:19:14 ====================================================================================================
11:19:14
11:19:14 (Run Starting)
11:19:14
11:19:14 ┌────────────────────────────────────────────────────────────────────────────────────────────────┿
11:19:14 │ Cypress: 3.3.1 │
11:19:14 │ Browser: Chrome 71 │
11:19:14 │ Specs: 5 found (...) │
11:19:14 └────────────────────────────────────────────────────────────────────────────────────────────────┘
11:19:14
11:19:14 ────────────────────────────────────────────────────────────────────────────────────────────────────
11:19:14
11:19:14 Running: test.js... (1 of 5)
...
11:19:50 We attempted to make an http request to this URL but the request failed without a response.
11:19:50
11:19:50 We received this error at the network level:
11:19:50
11:19:50 > Error: ESOCKETTIMEDOUT
...
11:20:08 Compiled successfully!
11:20:08
11:20:08 You can now view App in the browser.
For me the fix was to change start-server http://localhost:3000
to start-server http-get://localhost:3000
in my package.json. After this, the command awaited the start of the server properly.
This is also mentioned in the documentation https://docs.cypress.io/guides/guides/continuous-integration.html#Boot-your-server Although the context mentioned there is a bit different, but it does the trick.