2.2.1 • Published 10 months ago

karma-coverage v2.2.1

Weekly downloads
553,161
License
MIT
Repository
github
Last release
10 months ago

karma-coverage

js-standard-style npm version npm downloads

Build Status Dependency Status devDependency Status

Generate code coverage using Istanbul.

Installation

The easiest way is to install karma-coverage as a devDependency, by running

npm install karma karma-coverage --save-dev

Configuration

For configuration details see docs/configuration.

Examples

Basic

// karma.conf.js
module.exports = function(config) {
  config.set({
    files: [
      'src/**/*.js',
      'test/**/*.js'
    ],

    // coverage reporter generates the coverage
    reporters: ['progress', 'coverage'],

    preprocessors: {
      // source files, that you wanna generate coverage for
      // do not include tests or libraries
      // (these files will be instrumented by Istanbul)
      'src/**/*.js': ['coverage']
    },

    // optionally, configure the reporter
    coverageReporter: {
      type : 'html',
      dir : 'coverage/'
    }
  });
};

CoffeeScript

For an example on how to use with CoffeeScript see examples/coffee. For an example of how to use with CoffeeScript and the RequireJS module loader, see examples/coffee-requirejs (and also see the useJSExtensionForCoffeeScript option in docs/configuration.md).

Advanced, multiple reporters

// karma.conf.js
module.exports = function(config) {
  config.set({
    files: [
      'src/**/*.js',
      'test/**/*.js'
    ],
    reporters: ['progress', 'coverage'],
    preprocessors: {
      'src/**/*.js': ['coverage']
    },
    coverageReporter: {
      // specify a common output directory
      dir: 'build/reports/coverage',
      reporters: [
        // reporters not supporting the `file` property
        { type: 'html', subdir: 'report-html' },
        { type: 'lcov', subdir: 'report-lcov' },
        // reporters supporting the `file` property, use `subdir` to directly
        // output them in the `dir` directory
        { type: 'cobertura', subdir: '.', file: 'cobertura.txt' },
        { type: 'lcovonly', subdir: '.', file: 'report-lcovonly.txt' },
        { type: 'teamcity', subdir: '.', file: 'teamcity.txt' },
        { type: 'text', subdir: '.', file: 'text.txt' },
        { type: 'text-summary', subdir: '.', file: 'text-summary.txt' },
      ]
    }
  });
};

FAQ

Don't minify instrumenter output

When using the istanbul instrumenter (default), you can disable code compaction by adding the following to your configuration.

// karma.conf.js
module.exports = function(config) {
  config.set({
    coverageReporter: {
      instrumenterOptions: {
        istanbul: { noCompact: true }
      }
    }
  });
};

For more information on Karma see the homepage.

@eui/deps-baseneo-ui-template@jframe/iockarmafy@rock-kit/ui-karma-configak-gulpdialer-reportsexecutable_esm_aa_webcomponentsdebox-web-coresammenpeach-clies6-workflowangular-rx-ui@temporg/config-karma@temporg/ui-karma-config@dotedu/ivx-web-story-forgeeduihst-component-system@cvpcasada/nwbng2workspace-addon-webpack-karmavbteslint-config-helmng2-lib-projmost-dependencies@everything-registry/sub-chunk-2005plus.webclient.build@innotec/ngx-webpack-module@hasaki-ui/hsk-braum@hasaki-ui/hsk-garen@hai-ui/karma-build-scripts@holisticon/angular-common@holisticon/angularjs-common@infinitebrahmanuniverse/nolb-karma-c@mass-ui/sshell@leonardodino/builder-react-component-dev@linaj/plugin-karma@neutrinojs/karma@ngx-devtools/test@ngx-library/infrastructure@ngxvoice/ngx-voicelistner@l5769389/eleui@mediafly/create-app@mapstore/project@mcb/pipelinevui-helpers@skyrpex/starpack@treshugart/nwb@triotech/vue-core@trinitymirrordigital/karma-webpack-setup@ubiquits/toolchain@vcomply/responsibility-quickview@open-wc/testing-karma@openbfs/imis3gis@popperjs/scripts@popperjs/test@poi/plugin-karma@starpack/starpack@rubik-ui/hjl@sap/grunt-sapui5-bestpractice-test@sap/grunt-tests-webide-bestpractice@krakenjs/karma-config-grumbler@kpdecker/linoleum-webpack@kirill.konshin/nwb@ksakira10/nwb@ovos-media/builder-archetype@ovos-media/builder-ope-archetype@pigs/plugin-karma@pavilionius/webpack@s-ui/test@serengeti/serengeti-resource@xarc/opt-karma@xilution/xilution-ui-build@xilution/xilution-web-client-build@zerothstack/toolchainaegis-tools@tkdn/toolbelt-karma@tylertech/forge-cli@webank/fes-cli@youzhej/jutils@sweexui/weex-cli-service@sweet-weex/weex-cli-service@thinkeloquent/npm-build-script@wvr/core@zalastax/nolb-karma-cfarmbot-web-frontendangular-bro-appangularjs-scripts1000-packagesanp-gulp40au-isteven-angular-multiselectangular-svg-pan-zoomangular-app-automationfear-core-devangular-point-toolsangular-require-typescript-seedfekit-extension-kjtestfenglin-uploaderfeng-rc-tools@fabwcie/ckeditor5-previewangular-hint-controllers
2.2.1

10 months ago

2.2.0

2 years ago

2.1.1

2 years ago

2.1.0

2 years ago

2.0.3

4 years ago

2.0.2

4 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.1.2

6 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.0

8 years ago

0.5.5

8 years ago

0.5.4

8 years ago

0.5.3

9 years ago

0.5.2

9 years ago

0.5.1

9 years ago

0.5.0

9 years ago

0.4.2

9 years ago

0.4.1

9 years ago

0.4.0

9 years ago

0.3.1

9 years ago

0.3.0

9 years ago

0.2.7

9 years ago

0.2.6

10 years ago

0.2.5

10 years ago

0.2.4

10 years ago

0.2.3

10 years ago

0.2.2

10 years ago

0.2.1

10 years ago

0.2.0

10 years ago

0.1.5

10 years ago

0.1.4

10 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

11 years ago

0.0.5

11 years ago

0.0.4

11 years ago

0.0.3

11 years ago

0.0.2

11 years ago

0.0.1

11 years ago