O'Reilly logo

Jasmine JavaScript Testing - Second Edition by Paulo Ragonha

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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": ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required