Quick feedback loop
Automated testing is all about the quick feedback loop, so imagine being able to have the tests running in the console and the application refreshing on the browser after any file change. Would that be possible? The answer is yes!
Watch and run the tests
Via a simple parameter while starting Karma, we can achieve testing nirvana, as follows:
./node_modules/karma/bin/karma start karma.conf.js --auto-watch --no-single-run
Try it by yourself; run this command, change a file, and see the tests running automatically—like magic.
Once again, we don't want to remember these complicated commands, so let's add another script to the package.json
file:
"scripts": {
"test": "./node_modules/karma/bin/karma start karma.conf.js",
"watch-test": "./node_modules/karma/bin/karma start karma.conf.js --auto-watch --no-single-run",
"dev": "webpack-dev-server"
},
We can run it through the following command:
npm run watch-test
Watch and update the browser
To achieve development nirvana, we are...