I'm trying to build a bash script that runs unit tests on a web server.
I wish to run a simple bash script that could be (for example) in a makefile that does the following:
- Start a web server
- Run the unit tests
- Stop the web server
Assuming that the web server is written for NodeJS, here's what it could look like:
npm start &
sleep 5
npm test
The issue with this approach is that the web server will keep on running. How do I stop it after the npm test
stage?