0

I am using start-server-and-test but it is giving timeout error after 10 mins. I am following Cypress documentation only.

Another package that I used is npm wait-on but it is also not working

"scripts": {
    "dev": "cd ../../ && npm run start",
    "run:component": "cypress run --spec integration/component_test/*.spec.js",
    "componentTest": "npm run dev  wait-on  http://localhost:3000/ && run:component",
    
  },

I am running npm run componentTest, but it is not running NEXT_CMD command, i.e. run:component.

Abhishek
  • 19
  • 2
  • 2
    There's something seriously wrong with an app that takes 17 minutes to start. – TesterDick May 31 '22 at 11:56
  • If you can share some code, there may be ways around it. – TesterDick May 31 '22 at 11:56
  • @TesterDick Yes, Webpack configuration is taking time to build. I have given snapshot of package.json. What I want from `"componentTest": "npm run dev wait-on localhost:3000 && run:component"` **wait-on** should wait for localhost:3000 to be up and once up next_cmd command i.e. **run:component** should run. But currently next_cmd is not running. – Abhishek May 31 '22 at 12:03

2 Answers2

2

wait-on has a --httpTimeout option, maybe this will work

"componentTest": "npm run dev wait-on --httpTimeout 1020000 http://localhost:3000/ && run:component"
TesterDick
  • 3,830
  • 5
  • 18
  • I have tried this but httpTimeout is not working . 1. `npm run dev` opens the http://localhost:3000/ in the browser 2. wait-on never gets timeout and hence next_cmd doesn't get triggered. – Abhishek May 31 '22 at 13:15
  • Looks like there is some serious issue with wait-on package. If you use wait-on in the initial it will work as given below but it will not fulfill the requirement `"componentTest": "wait-on --timeout 10200 http://localhost:3000/ dev && run:component"` – Abhishek May 31 '22 at 13:29
  • Is there any way to increase the timeout period of **start-server-and-test** npm package? – Abhishek May 31 '22 at 13:33
  • I'll try it out, there must be a way since it's documented. Can't see any issues raised. – TesterDick May 31 '22 at 13:49
  • Yes, Please have a look at it. – Abhishek Jun 01 '22 at 05:32
  • @Abhishek, there is, but you must install *cross-env* and then use it beofre the *start-server-and-test* command. In the end you're writing "ci-test": "cross-env WAIT_ON_TIMEOUT=60000 start-server-and-test ...., where WAIT_ON_TIMEOUT is in milliseconds – Dan Mihalea May 08 '23 at 13:30
0

You could potentially wait multiple times and ignore the exit status of all but the last wait invocation.


However I think the main issue here is that run dev and wait-on is not propely running in paralell. Based on this gist the proper invocation should be

"scripts": {
    "dev": "cd ../../ && npm run start",
    "run:component": "cypress run --spec integration/component_test/*.spec.js",
    "componentTest": "concurrently \"npm run dev\" \"wait-on http://localhost:3000/ && npm run run:component\" --kill-others"
},

which will start both concurrently. I added a script similar to this in our project and it worked as intended.


Possibly the start-server-and-test package could be used instead of concurrently.

hlovdal
  • 26,565
  • 10
  • 94
  • 165