How to watch webpack-dev-server running Jest tests at the same time?
Install npm-run-all
as a dev dependency, which allows you to run several scripts at once.
https://www.npmjs.com/package/npm-run-all
Example assuming both the following "start"
and "test"
scripts work individually:
{
"test": "jest --watch",
"start": "webpack-dev-server --progress --colors --hot --inline",
"dev": "npm-run-all test start"
}
You simply start both with npm run dev
on your terminal and ready to go.
Change your test script in package.json
from this "test": "jest"
to this "test": "jest --watch"
.
Then just use 2 terminals: In one terminal you run npm run watch
and in the other you run npm run test
.