Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

karma-coverage

Package Overview
Dependencies
Maintainers
3
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

karma-coverage - npm Package Compare versions

Comparing version 0.4.1 to 0.4.2

docs/configuration.md

9

CHANGELOG.md

@@ -0,1 +1,10 @@

<a name"0.4.2"></a>
### 0.4.2 (2015-06-12)
#### Bug Fixes
* **preprocessor:** Use `_.contains` instead of `_.includes` to avoid braking with `lodash@2` ([411beb1f](https://github.com/karma-runner/karma-coverage/commit/411beb1f))
<a name"0.4.1"></a>

@@ -2,0 +11,0 @@ ### 0.4.1 (2015-06-09)

7

gruntfile.js

@@ -31,2 +31,7 @@ module.exports = function (grunt) {

},
karma: {
coffee: {
configFile: 'examples/coffee/karma.conf.coffee'
}
},
eslint: {

@@ -43,3 +48,3 @@ target: [

grunt.registerTask('test', ['simplemocha'])
grunt.registerTask('test', ['simplemocha', 'karma'])
grunt.registerTask('default', ['eslint', 'test'])

@@ -46,0 +51,0 @@

2

lib/preprocessor.js

@@ -53,3 +53,3 @@ // Coverage Preprocessor

// if coverage reporter is not used, do not preprocess the files
if (!_.includes(reporters, 'coverage')) {
if (!_.contains(reporters, 'coverage')) {
return function (content, _, done) {

@@ -56,0 +56,0 @@ done(content)

{
"name": "karma-coverage",
"version": "0.4.1",
"version": "0.4.2",
"description": "A Karma plugin. Generate code coverage.",

@@ -37,7 +37,13 @@ "main": "lib/index.js",

"grunt-eslint": "^14.0.0",
"grunt-karma": "^0.11.0",
"grunt-npm": "^0.0.2",
"grunt-simple-mocha": "^0.4.0",
"karma": "^0.12.0",
"ibrik": "^2.0.0",
"karma": "^0.12.36",
"karma-coffee-preprocessor": "^0.2.1",
"karma-firefox-launcher": "^0.1.6",
"karma-mocha": "^0.1.10",
"load-grunt-tasks": "^3.2.0",
"lodash": "^3.9.3",
"mocha": "^2.2.5",
"mocks": "0.0.11",

@@ -54,5 +60,12 @@ "sinon": "^1.14.1",

"Allen Bierbaum <abierbaum@gmail.com>",
"Douglas Duteil <douglasduteil@gmail.com>",
"Matt Winchester <m_winche@yahoo.com>",
"Wei Kin Huang <weikin.huang04@gmail.com>",
"Douglas Duteil <douglasduteil@gmail.com>",
"Julie <ju.ralph@gmail.com>",
"Maciej Rzepiński <maciej.rzepinski@gmail.com>",
"Joseph Connolly <joec@avinetworks.com>",
"Mark Ethan Trostler <mark@zzo.com>",
"Chris Gladd <chris.m.gladd@gmail.com>",
"Michael Stramel <m.stramel89@gmail.com>",
"Greg Varsanyi <gvarsanyi@gmail.com>",
"Nick Matantsev <nick.matantsev@gmail.com>",

@@ -65,19 +78,13 @@ "Petar Manev <petar.manev2010@gmail.com>",

"Taylor Hakes <taylor@taylorhakes.com>",
"Dmitry Petrov <dpetroff@gmail.com>",
"Timo Tijhof <krinklemail@gmail.com>",
"Tom Kirkpatrick <tom@systemseed.com>",
"Vincent Lemeunier <vincent.lemeunier+git@gmail.com>",
"Clayton Watts <cletusw@gmail.com>",
"piecyk <piecyk@gmail.com>",
"Yusuke Suzuki <utatane.tea@gmail.com>",
"aprooks <alexander.prooks@gmail.com>",
"piecyk <piecyk@gmail.com>",
"Chris Gladd <chris.m.gladd@gmail.com>",
"Dmitry Petrov <dpetroff@gmail.com>",
"Greg Varsanyi <gvarsanyi@gmail.com>",
"Joseph Connolly <joec@avinetworks.com>",
"Joshua Appelman <jappelman@xebia.com>",
"Julie <ju.ralph@gmail.com>",
"Kyle Welsby <kyle@mekyle.com>",
"Maciej Rzepiński <maciej.rzepinski@gmail.com>",
"Mark Ethan Trostler <mark@zzo.com>",
"Michael Stramel <m.stramel89@gmail.com>"
"Kyle Welsby <kyle@mekyle.com>"
]
}

@@ -21,4 +21,8 @@ # karma-coverage

The following code shows a simple usage:
For configuration details see [docs/configuration](docs/configuration.md).
## Examples
### Basic
```javascript

@@ -51,42 +55,9 @@ // karma.conf.js

```
### CoffeeScript
Example use with a CoffeeScript project:
For an example on how to use with [CoffeeScript](http://coffeescript.org/)
see [examples/coffee](examples/coffee).
```javascript
// karma.conf.js
module.exports = function(config) {
config.set({
files: [
'src/**/*.coffee',
'test/**/*.coffee'
],
### Advanced, multiple reporters
// 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 via Ibrik unless
// specified otherwise in coverageReporter.instrumenter)
'src/**/*.coffee': ['coverage'],
// note: project files will already be converted to
// JavaScript via coverage preprocessor.
// Thus, you'll have to limit the CoffeeScript preprocessor
// to uncovered files.
'test/**/*.coffee': ['coffee']
},
// optionally, configure the reporter
coverageReporter: {
type : 'html',
dir : 'coverage/'
}
});
};
```
Here is an advanced usage of karma-coverage, using severals reporters:
```javascript

@@ -124,211 +95,2 @@ // karma.conf.js

### Options
#### type
**Type:** String
**Description:** Specify a reporter type.
**Possible Values:**
* `html` (default)
* `lcov` (lcov and html)
* `lcovonly`
* `text`
* `text-summary`
* `cobertura` (xml format supported by Jenkins)
* `teamcity` (code coverage System Messages for TeamCity)
* `json` (json format supported by [`grunt-istanbul-coverage`](https://github.com/daniellmb/grunt-istanbul-coverage))
#### dir
**Type:** String
**Description:** This will be used to output coverage reports. When
you set a relative path, the directory is resolved against the `basePath`.
#### subdir
**Type:** String
**Description**: This will be used in complement of the `coverageReporter.dir`
option to generate the full output directory path. By default, the output
directory is set to `./config.dir/BROWSER_NAME/`, this option allows you to
custom the second part. You can either pass a `string` or a `function` which will be
called with the browser name passed as the only argument.
```javascript
coverageReporter: {
dir: 'coverage',
subdir: '.'
// Would output the results into: .'/coverage/'
}
```
```javascript
coverageReporter: {
dir: 'coverage',
subdir: 'report'
// Would output the results into: .'/coverage/report/'
}
```
```javascript
coverageReporter: {
dir: 'coverage',
subdir: function(browser) {
// normalization process to keep a consistent browser name accross different
// OS
return browser.toLowerCase().split(/[ /-]/)[0];
}
// Would output the results into: './coverage/firefox/'
}
```
#### file
If you choose the `cobertura`, `lcovonly`, `teamcity`, `text` or `text-summary` reporters, you may set the `file` option to specify an output file.
```javascript
coverageReporter: {
type : 'text',
dir : 'coverage/',
file : 'coverage.txt'
}
```
#### check
**Type:** Object
**Description:** This will be used to configure minimum threshold enforcement for coverage results. If the thresholds are not met, karma will return failure. Thresholds, when specified as a positive number are taken to be the minimum percentage required. When a threshold is specified as a negative number it represents the maximum number of uncovered entities allowed.
For example, `statements: 90` implies minimum statement coverage is 90%. `statements: -10` implies that no more than 10 uncovered statements are allowed.
`global` applies to all files together and `each` on a per-file basis. A list of files or patterns can be excluded from enforcement via the `exclude` property. On a per-file or pattern basis, per-file thresholds can be overridden via the `overrides` property.
```javascript
coverageReporter: {
check: {
global: {
statements: 50,
branches: 50,
functions: 50,
lines: 50,
excludes: [
'foo/bar/**/*.js'
]
},
each: {
statements: 50,
branches: 50,
functions: 50,
lines: 50,
excludes: [
'other/directory/**/*.js'
],
overrides: {
'baz/component/**/*.js': {
statements: 98
}
}
}
}
}
```
#### watermarks
**Type:** Object
**Description:** This will be used to set the coverage threshold colors. The first number is the threshold between Red and Yellow. The second number is the threshold between Yellow and Green.
```javascript
coverageReporter: {
watermarks: {
statements: [ 50, 75 ],
functions: [ 50, 75 ],
branches: [ 50, 75 ],
lines: [ 50, 75 ]
}
}
```
#### includeAllSources
**Type:** Boolean
You can opt to include all sources files, as indicated by the coverage preprocessor, in your code coverage data, even if there are no tests covering them. (Default `false`)
```javascript
coverageReporter: {
type : 'text',
dir : 'coverage/',
file : 'coverage.txt',
includeAllSources: true
}
```
#### sourceStore
**Type:** istanbul.Store
You can opt to specify a source store allowing for external coverage collectors access to the instrumented code.
```javascript
coverageReporter: {
type : 'text',
dir : 'coverage/',
file : 'coverage.txt',
sourceStore : require('istanbul').Store.create('fslookup')
}
```
#### multiple reporters
You can use multiple reporters, by providing array of options.
```javascript
coverageReporter: {
reporters:[
{type: 'html', dir:'coverage/'},
{type: 'teamcity'},
{type: 'text-summary'}
],
}
```
#### instrumenter
Karma-coverage can infers the instrumenter regarding of the file extension.
It is possible to override this behavior and point out an
instrumenter for the files matching a specific pattern.
To do so, you need to declare an object under with the keys represents the
pattern to match, and the instrumenter to apply. The matching will be done
using [minimatch](https://github.com/isaacs/minimatch).
If two patterns match, the last one will take the precedence.
For example you can use [Ibrik](https://github.com/Constellation/ibrik) (an
[Istanbul](https://github.com/gotwarlost/istanbul) analog for
CoffeeScript files) with:
```javascript
coverageReporter: {
instrumenters: { ibrik : require('ibrik') }
instrumenter: {
'**/*.coffee': 'ibrik'
},
// ...
}
```
You can pass options additional options to specific instrumenter with:
```javascript
var to5Options = { experimental: true };
// [...]
coverageReporter: {
instrumenters: { isparta : require('isparta') },
instrumenter: {
'**/*.js': 'isparta'
},
instrumenterOptions: {
isparta: { to5 : to5Options }
}
}
```
----

@@ -335,0 +97,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc