Reputation: 3753
I'm writing end to end tests for an express site, and I want to add a "test" command into package.js
This command needs to:
I know how to execute all those commands individually, but not all at once.
What I have now is :
npm run compile && npm run build && node ./dist/server.js --db=test && npm run test
It works to the point of: "&& npm run test" since node server is running, it won't continue on to the next command, and if it closes then tests wouldn't run.
Any help is appreciated.
Upvotes: 4
Views: 1696
Reputation: 55922
One thing that I have found to help with reliable, maintainable end-to-end tests is to separate concerns:
In CI, this could look like
npm start-e2e-test-stack --port=XXXX --db=test
npm test --port=XXXX --db=test
npm teardown-e2e-test-stack
In my experiences, having the end-to-end tests operate against any server helps to allow them to verify all environments, local, dev, qa, staging, production.
Upvotes: 1