source: trip-planner-front/node_modules/karma-coverage/README.md

Last change on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 3.7 KB
Line 
1# karma-coverage
2
3[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/karma-runner/karma-coverage)
4 [![npm version](https://img.shields.io/npm/v/karma-coverage.svg?style=flat-square)](https://www.npmjs.com/package/karma-coverage) [![npm downloads](https://img.shields.io/npm/dm/karma-coverage.svg?style=flat-square)](https://www.npmjs.com/package/karma-coverage)
5
6[![Build Status](https://img.shields.io/travis/karma-runner/karma-coverage/master.svg?style=flat-square)](https://travis-ci.org/karma-runner/karma-coverage) [![Dependency Status](https://img.shields.io/david/karma-runner/karma-coverage.svg?style=flat-square)](https://david-dm.org/karma-runner/karma-coverage) [![devDependency Status](https://img.shields.io/david/dev/karma-runner/karma-coverage.svg?style=flat-square)](https://david-dm.org/karma-runner/karma-coverage#info=devDependencies)
7
8> Generate code coverage using [Istanbul].
9
10## Installation
11
12The easiest way is to install `karma-coverage` as a `devDependency`,
13by running
14
15```bash
16npm install karma karma-coverage --save-dev
17```
18
19## Configuration
20
21For configuration details see [docs/configuration](docs/configuration.md).
22
23## Examples
24
25### Basic
26
27```javascript
28// karma.conf.js
29module.exports = function(config) {
30 config.set({
31 files: [
32 'src/**/*.js',
33 'test/**/*.js'
34 ],
35
36 // coverage reporter generates the coverage
37 reporters: ['progress', 'coverage'],
38
39 preprocessors: {
40 // source files, that you wanna generate coverage for
41 // do not include tests or libraries
42 // (these files will be instrumented by Istanbul)
43 'src/**/*.js': ['coverage']
44 },
45
46 // optionally, configure the reporter
47 coverageReporter: {
48 type : 'html',
49 dir : 'coverage/'
50 }
51 });
52};
53```
54### CoffeeScript
55
56For an example on how to use with [CoffeeScript](http://coffeescript.org/)
57see [examples/coffee](examples/coffee). For an example of how to use with
58CoffeeScript and the RequireJS module loader, see
59[examples/coffee-requirejs](examples/coffee-requirejs) (and also see
60the `useJSExtensionForCoffeeScript` option in
61[docs/configuration.md](docs/configuration.md)).
62
63### Advanced, multiple reporters
64
65```javascript
66// karma.conf.js
67module.exports = function(config) {
68 config.set({
69 files: [
70 'src/**/*.js',
71 'test/**/*.js'
72 ],
73 reporters: ['progress', 'coverage'],
74 preprocessors: {
75 'src/**/*.js': ['coverage']
76 },
77 coverageReporter: {
78 // specify a common output directory
79 dir: 'build/reports/coverage',
80 reporters: [
81 // reporters not supporting the `file` property
82 { type: 'html', subdir: 'report-html' },
83 { type: 'lcov', subdir: 'report-lcov' },
84 // reporters supporting the `file` property, use `subdir` to directly
85 // output them in the `dir` directory
86 { type: 'cobertura', subdir: '.', file: 'cobertura.txt' },
87 { type: 'lcovonly', subdir: '.', file: 'report-lcovonly.txt' },
88 { type: 'teamcity', subdir: '.', file: 'teamcity.txt' },
89 { type: 'text', subdir: '.', file: 'text.txt' },
90 { type: 'text-summary', subdir: '.', file: 'text-summary.txt' },
91 ]
92 }
93 });
94};
95```
96
97### FAQ
98
99#### Don't minify instrumenter output
100
101When using the istanbul instrumenter (default), you can disable code compaction by adding the following to your configuration.
102
103```javascript
104// karma.conf.js
105module.exports = function(config) {
106 config.set({
107 coverageReporter: {
108 instrumenterOptions: {
109 istanbul: { noCompact: true }
110 }
111 }
112 });
113};
114```
115
116----
117
118For more information on Karma see the [homepage].
119
120
121[homepage]: http://karma-runner.github.com
122[Istanbul]: https://istanbul.js.org
Note: See TracBrowser for help on using the repository browser.