bahmutov / start-server-and-test

Starts server, waits for URL, then runs test command; when the tests end, shuts down server
MIT License
1.53k stars 93 forks source link

issue terminating nodemon? #266

Open mstruensee opened 4 years ago

mstruensee commented 4 years ago

edit: i think i have some progress ... when i run process.kill in node, my app sits there with this message (even tough it returns true)

> process.kill("###") true [nodemon] app crashed - waiting for file changes before starting... ^^ the 143 error should go away when this doesnt happen?

I am spinning up a mock api express server, then the actual express app. Everything waits correctly, all tests pass!, but the task fails due to both nodemon instances exiting with code 143. I am not sure if this is due to 2 nodemon's running/being terminated or what ...

edit: i updated test to exit 0, and only start 1 of the servers, and same issue ...

Everything else seems fine, but I can't get past the 143 ... ¯_(ツ)_/¯ ... hoping for some ideas for a possible solution

here are my commands start-test start:mock-server 'http://localhost:1234/heartbeat' start 'http://localhost:5678/heartbeat' test "start": "nodemon src/server" "start:mock-server": "nodemon mock/server" "test":cypress run

output:



       Spec                                              Tests  Passing  Failing  Pending  Skipped  
  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ ✔  1.feature                 914ms        1        1        -        -        - │
  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
  │ ✔  2.feature                     163ms        3        3        -        -        - │
  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
  │ ✔  3.feature                           250ms        1        1        -        -        - │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘
    ✔  All specs passed!                        00:01        5        5        -        -        -  

  start-server-and-test getting child processes +23s
  start-server-and-test stopping child processes +59ms
  start-server-and-test stopping server +1ms
  start-server-and-test getting child processes +0ms
npm ERR! code ELIFECYCLE
npm ERR! errno 143
npm ERR! xxxxx@##.##.## start: `nodemon src/server`
npm ERR! Exit status 143
npm ERR! 
npm ERR! Failed at the xxxxx@20.26.3 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/xxxxx/.npm/_logs/2020-06-23T20_24_42_019Z-debug.log
  start-server-and-test stopping child processes +63ms
  start-server-and-test stopping server +1ms
npm ERR! code ELIFECYCLE
npm ERR! errno 143
npm ERR! xxxxx@##.##.## start:mock-server: `nodemon mock/server`
npm ERR! Exit status 143
npm ERR! 
npm ERR! Failed at the xxxxx@20.26.3 start:mock-server script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/xxxxx/.npm/_logs/2020-06-23T20_24_42_096Z-debug.log```
mstruensee commented 4 years ago

as a workaround (or solution) i updated the script to use node and point to the dist (built) artifacts ... works great!