Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/db-developer/grunt-nyc-mocha
run mocha tests and generate coverage reports with nyc
https://github.com/db-developer/grunt-nyc-mocha
coverage grunt javascript mocha nyc plugin testing
Last synced: about 1 month ago
JSON representation
run mocha tests and generate coverage reports with nyc
- Host: GitHub
- URL: https://github.com/db-developer/grunt-nyc-mocha
- Owner: db-developer
- License: mit
- Created: 2020-11-29T18:31:33.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2024-07-01T19:37:26.000Z (6 months ago)
- Last Synced: 2024-11-17T15:11:38.526Z (about 1 month ago)
- Topics: coverage, grunt, javascript, mocha, nyc, plugin, testing
- Language: JavaScript
- Homepage: https://www.slashlib.org/?page_id=477
- Size: 546 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: docs/contributing.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# grunt-nyc-mocha #
grunt task for running tests and coverage, based on nyc and mocha.
[![npm version](https://img.shields.io/npm/v/grunt-nyc-mocha?color=blue)](https://www.npmjs.com/package/grunt-nyc-mocha)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
[![jsdoc](https://img.shields.io/static/v1?label=jsdoc&message=%20api%20&color=blue)](https://jsdoc.app/)
[![Built with Grunt](https://cdn.gruntjs.com/builtwith.svg)](https://gruntjs.com/)
[![codecov](https://codecov.io/gh/db-developer/grunt-nyc-mocha/branch/master/graph/badge.svg)](https://codecov.io/gh/db-developer/grunt-nyc-mocha)
[![Build Status](https://travis-ci.com/db-developer/grunt-nyc-mocha.svg?branch=master)](https://travis-ci.com/db-developer/grunt-nyc-mocha)
[![dependencies](https://img.shields.io/librariesio/release/npm/grunt-nyc-mocha)](https://libraries.io/)## content ##
* Usage
* [Getting started guide (see 'getting started' below)](#getting-started)
* [Reference of all available options](docs/options.md)
* [Sourcemap support](docs/sourcemapsupport.md)* Developers
* [Testing grunt-nyc-mocha](docs/grunt.md#testing)
* [Code coverage of tests for grunt-nyc-mocha](docs/grunt.md#code-coverage)
* [Build grunt-nyc-mocha from scratch](docs/grunt.md#building)
* [Frameworks used for building and running grunt-nyc-mocha](docs/frameworks.md)
* [API of package grunt-nyc-mocha](docs/api.index.md)[Changelog](CHANGELOG.md)
## getting started ##
This guide assumes, that you are familiar with the use of [npm](https://npmjs.com "Homepage of npm") and [grunt](https://gruntjs.com "Homepage of grunt").
The plugin can be installed by the following command:
npm install grunt-nyc-mocha --save-dev
Once installed, the plugin may be loaded from within your gruntfile.
### task nyc_mocha ###
"nyc_mocha" is a grunt multitask provided by
grunt-nyc-mocha
and
can hold multiple targets. Each of the targets you may define will spawn
their very own node process.Multitask configuration generally splits into the following parts:
* [options (tasklevel, inherited by any target)](docs/options.md)
* target (0 to n)
* any other grunt configuration properties
* [options (targetlevel, will be merged into tasklevel options)](docs/options.md)Any target can extend, repeat or overwrite options previously defined by a task.
For doing so, each target can specify its own "options" property. Targetlevel
options will be merged into tasklevel options, overwriting them.### raw usage of
grunt-nyc-mocha
###```javascript
// extract from gruntfile.jsmodule.exports = function( grunt ) {
grunt.initConfig({
// among many others ...
nyc_mocha:{
options: { /*tasklevel options go here*/ }
target: {
src: "./src/test/**/*.spec.js", // test suites to run...
options: { /* targetlevel options go here */ }
}
}
});grunt.loadNpmTasks( "nyc_mocha" );
grunt.registerTask( "default", [ "nyc_mocha:target" ]);
}
```### using
grunt-nyc-mocha
withload-grunt-config
andload-grunt-tasks
###Install the following packages:
npm install load-grunt-config --save-dev
npm install load-grunt-tasks --save-dev
Now you can split gruntfile.js in multiple configuration files:
```javascript
// extract from (a much cleaner) gruntfile.js
const configPath = ...? // this is where your config files reside
const data = { /* some properties, that can be passed on */ };module.exports = function( grunt ) {
require( "load-grunt-config" )( grunt, { configPath, data });
require( "load-grunt-tasks" )( grunt );grunt.registerTask( "default", [ "nyc_mocha:target" ]);
}
``````javascript
// extract from nyc_mocha.js (has to be named tasklike!)
module.exports = function ( grunt, options ) {
return {
target: {
src: "./src/test/**/*.spec.js", // run those test files
options: {
nyc: {
coverage: { // report nyc coverage results
dir: "dist/coverage", // ... to folder
reporter: [ "html", "text-summary" ] // ... using reporters
},
excludes: [ "**/*.spec.js" ], // exclude test files from instrumentation!
requires: [ "grunt-nyc-mocha/scripts/sourcemapsupport" ]
},
mocha: {
color: true // force colored output
}
}
}
}
};
```