npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

grunt-nyc-mocha

v1.2.0

Published

grunt task for running tests and coverage, based on nyc and mocha.

Downloads

429

Readme

grunt-nyc-mocha

grunt task for running tests and coverage, based on nyc and mocha.

npm version License: MIT jsdoc Built with Grunt codecov Build Status dependencies

content

Changelog

getting started

This guide assumes, that you are familiar with the use of npm and 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:

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

// extract from gruntfile.js

module.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 with load-grunt-config and load-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:

// 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" ]);
}
// 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
        }
      }
    }
  }
};