Karma Settings in Angular

Learn to set up testing in Angular as well as the properties in the angular.json file and the karma.conf.js file.

Setup testing in an Angular application

From what weโ€™ve learned about Jasmine and Karma, we could set up testing within our Angular applications ourselves. All we need to do is:

  • Install Karma
  • Set the configuration file telling Karma to run
  • Continuously watch for changes to our files in order to trigger the re-running of tests.
  • Install the Jasmine framework into our application via NPM.

๐Ÿ“ Note: The Karma website has a great tutorial on how to set up Karma for a project, and you can find details on adding Jasmine from the Jasmine website.

Thankfully for us, all this has been handled through the Angular CLI. When we create a new project, the Angular CLI downloads and installs all, we need for testing our applications.

๐Ÿ“ Note: If you want to create a new Angular application without the tests and test files, you can by adding the --skipTests=true argument to the ng new command like this:

ng new MyTestFreeApp --skipTests=true

In an Angular project, there are two separate files, which manage tests. They are the angular.json file and the karma.conf.js file.

Get hands-on with 1200+ tech skills courses.