0 votes
in AngularJS Packaging and Testing by
What is Karma? What is the use in Angular?

1 Answer

0 votes
by
Karma is a tool for executing source code against test code inside a browser environment. It supports the running of tests in each browser it’s configured for. Results are displayed on both the command line and on the browser for the developer to inspect which tests have passed or failed. Karma also watches the files and can trigger a test rerun whenever a file changes. At the root of the Angular project, we have the file karma.conf that’s used to configure Karma.

The contents should look something like this:

module.exports = function (config) {

  config.set({

    basePath: '',

    frameworks: ['jasmine', '@angular/cli'],

    plugins: [

      require('karma-jasmine'),

      require('karma-chrome-launcher'),

      require('karma-jasmine-html-reporter'),

      require('karma-coverage-istanbul-reporter'),

      require('@angular/cli/plugins/karma')

    ],

    client:{

      clearContext: false // leave Jasmine Spec Runner output visible in browser

    },

    coverageIstanbulReporter: {

      reports: [ 'html', 'lcovonly' ],

      fixWebpackSourcePaths: true

    },

    angularCli: {

      environment: 'dev'

    },

    reporters: ['progress', 'kjhtml'],

    port: 9876,

    colors: true,

    logLevel: config.LOG_INFO,

    autoWatch: true,

    browsers: ['Chrome'],

    singleRun: false

  });

};

Related questions

0 votes
asked Aug 20, 2021 in AngularJS Packaging and Testing by SakshiSharma
0 votes
asked May 21, 2022 in AngularJS Packaging and Testing by sharadyadav1986
...