I am trying to run a Vue.js app locally (localhost:3000) & then run Cypress tests against it.
Below are some npm scripts in my package.json
:
"dev": "nuxt",
"cypress": "npx cypress open",
"localCypress": "npm run dev && npm run cypress"
When I run the above dev
& cypress
commands on their own, they work as expected.
But when I try to run them both sequentially using localCypress
, only the app is starting, & the Cypress Explorer isn't opening (npm run cypress
part doesn't seem to be working).
Can someone please point out why this is occurring & how I can resolve it?
CodePudding user response:
The problem is that the npm run dev
spins a server and that's a long running process, that won't close until you manually stop it (or if it crashes). In both cases, it will return an exit code different than 0, so the second command after && won't run.
Take a look to this question to see how to run two npm process in parallel: How can I run multiple npm scripts in parallel?