Runs jasmine with Istanbul code coverage
A Grunt task to run your Jasmine feature suite using jasmine-npm and Istanbul for code coverage reports.
The minimum supported Node.js version is 4.2.0 (LTS), and while works also in 0.10.x, no quarantees are given.
Install this grunt plugin next to your project's Gruntfile.js with:
npm install grunt-jasmine-node-coverage --save-devThen add these lines to your project's Gruntfile.js configuration file:
grunt.initConfig({ jasmine_node: { task_name: { options: { forceExit: true, coverage: { includeAllSources: true }, jasmine: { spec_dir: 'tests', spec_files: [ '**/*spec.js' ] } }, src: ['src/**/*.js'] } } }); grunt.loadNpmTasks('grunt-jasmine-node-coverage'); grunt.registerTask('default', 'jasmine_node');Grunt tasks should be configured by following the multi task configuration form, thus wrapping each configuration in an object inside the jasmine_node root object.
Type: object
Default: see below
Jasmine specific configuration. Use empty object, {} to use the defaults that are shown below.
{ spec_dir: 'spec', spec_files: ['**/*[sS]pec/.js'], helpers: [], reporters: { spec: {} } }See the jasmine docs for more information on the supported configuration.
The reporters property allows the one of the following properties:
spec: used to configure the Jasmine spec reporter.teamcityset it totruein order to use Jasmine Reporters - TeamCityReporter.
If teamcity reporter is set spec reporter will be disabled and teamcity reporter will be added to the coverage reporters as well.
Example of using teamcity reporter:
{ spec_dir: 'spec', spec_files: ['**/*[sS]pec/.js'], helpers: [], reporters: { teamcity: true } }Type: object
Default: see below
Istanbul specific configuration. Use empty object, {} to use the defaults that are shown below.
{ reportFile: 'coverage.json', relativize: true, thresholds: { statements: 0, branches: 0, lines: 0, functions: 0 }, watermarks: { statements: [50, 80], lines: [50, 80], functions: [50, 80], branches: [50, 80], }, includeAllSources: false, reportDir: 'coverage', report: [ 'lcov', 'text-summary' ], collect: [ // false to disable, paths are relative to 'reportDir' '*coverage.json' ], excludes: [] }Notes:
- The
excludeslist will automatically include'**/node_modules/**'internally. - Setting the
thresholdsvalues greater than0will cause the task to fail if the specified threshold is not met. - The
watermarksconfig changes the thresholds at which the reports are displayed in red, yellow and green. It does not affect the outcome of the task. - Setting the
reportlist will allow different types of istanbul report to be set.
Type: string
Default: process.cwd()
See http://nodejs.org/api/process.html#process_process_cwd
Type: boolean
Default: false
Exit on failure by skipping any asyncronous tasks pending.
Type: boolean
Default: false
If set to true, will log all uncaught exceptions.
Type: boolean
Default: false
When true, istanbul will print more information when running.
Help us to squash them by submitting an issue that describes how you encountered it; please be as specific as possible including operating system, node, grunt, and grunt-jasmine-node-coverage versions.
npm --versionsIf you are updating to v1.0.0, you'll need to update your Gruntfile.
The following example outlines the changes needed. It assumes the following folder structure:
app/ ├── src/ │ ├── abacus.js │ └── calculator.js └── test/ ├── helpers.js └── specs/ ├── abacus.spec.js └── calculator.spec.js // v0.5.0 config { jasmine_node: { task_name: { options: { match: '.', matchAll: true, specFolders: ['test'], extensions: 'js', specNameMatcher: 'spec', useHelpers: true } } } } // v1.0.0 config { jasmine_node: { task_name: { options: { jasmine: { spec_dir: 'test', spec_files: [ 'specs/*.spec.js' ], helpers: [ 'helpers.js' ] } } } } }Please note that the junit reporter is no longer available. If you are using this reporter and wish to update to v1, please open a new issue and we'll see if we can get it added back in. Even better, submit a PR 😄
v1.2.0(2017-04-30)- Was compatible with Grunt
0.4all the time, hence lowering the dependency requirement #60
- Was compatible with Grunt
v1.1.1(2016-08-29)- Istanbul
v0.4.5and usingdata.srcinstead offileSrcfor compatibility #59
- Istanbul
v1.1.0(2016-08-23)- Add Node.js
v0.10.0support back by usingvarinstead ofconstandlet, #55 - Teamcity reporter for Jasmine, #56
- Add Node.js
v1.0.0(2016-07-23)- Breaking changes alert! Ensure you read the migration guide before updating from previous versions
- Minimum supported Node.js version is
4.2.0(LTS), removed testing against0.10 - Migrated from
jasmine-nodetojasmine-npm#35 #48 - Support
includeAllSourcesistanbul coverage option #45 #50 - Support thresholds for passing/failing build #25
- Removed junit reporter
v0.5.0(2016-05-03)- Grunt.js version 1.0 support
- ESLint configuration migration to 2.0
- Remove bin path #29
- Update license property for todays requirements
- Do not always make
lcovoutput
v0.4.1(2015-02-27)- Reports should be collected from where they were written #42
v0.4.0(2015-02-19)- Other Grunt tasks were not ran when this failed, #40
v0.3.2(2015-02-04)- Fixes for failure cases and documentation, #33, #36, #37 and #38
v0.3.1(2014-11-21)- Installation failed
- Should fix #30
v0.3.0(2014-11-09)- Grunt usage as multi task
- Fixes #12 and #18
v0.2.0(2014-11-03)- Better Grunt API usage
- Fixes #10, #13, #14, #16, #19 and #20
v0.1.11(2014-05-15)- Task name fix for
grunt.renametaskuse case
- Task name fix for
v0.1.10(2014-04-07)- JSHint configuration and task exit fixes
v0.1.9(2014-04-02)- Configuration for
jasmine_node.options.isVerbosewas not working
- Configuration for
v0.1.8(2014-03-03)- Add captureExceptions support and quit on exception
v0.1.7(2013-12-13)- Istanbul update, threshold configuration and JUNit output
v0.1.6(2013-07-26)- Change
isVerboseoption toverbose
- Change
v0.1.5(2013-07-15)- Initial coverage with Istanbul release, originally forked from
grunt-jasmine-node
- Initial coverage with Istanbul release, originally forked from
Copyright (c) 2013 "jribble" Jarrod Ribble & contributors. Based on grunt-jasmine-node.
Copyright (c) 2012 "s9tpepper" Omar Gonzalez & contributors. Licensed under the MIT license.