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-loop-mocha

v1.2.2

Published

A loop wrapper for initiating multiple mocha runs from one task target

Downloads

37

Readme

grunt-loop-mocha

A simple wrapper for running multiple mocha instances from a single grunt task target.

Abilities

  1. run mocha multiple times from a single target
  2. set stringified JSON environment variables, customized for each mocha run

I wrote this module to facilitate selenium webdriver testing. For that, each mocha run is a different browser target (specified in the iterations object of the config). My selenium test scripts use stringified JSON environment variables to configure the test runs. Perhaps you'll find it useful for this or other purposes.

Example usage

Below is the config block for this task from gruntfile.js

/* ... */
loopmocha: {
	src: ["test/*.js"],
	options: {
		mocha: {
			parallel: true,
			globals: ['should'],
			timeout: 3000,
			ui: 'bdd',
			reporter: "xunit-file",
		},
		loop: {
		    reportLocation: "test/report"
		},
		env1: {
			stringVal: "fromfile"
		},
		env2: {
			jsonVal: {
				foo: {
					bar: {
						stringVal: "baz"
					}
				}
			}
		}
		iterations: [
			{
				"description": "first",
				"env1": {
					"someKey": "some value"
				}
			},
			{
				"description": "second",
				"env2": {
					"someOtherKey": "some other value"
				}
			},
			{
				"description": "third",
				"mocha": {
					"timeout": 4000
				}
			},
			{
				"description": "fifth",
				"env1": {
					"anotherKey": "BLERG"
				},
				"env2": {
					"yetAnotherKey": 123
				}

			}
		]
	}
}
/* ... */

grunt.registerTask('test', 'loopmocha');

mocha options

any supported mocha command line argument is accepted.

loop options

  • parallel (optional: defaults to false): To engage a parallel testing ability, specify parallel.type = "file|directory". Optionally specify parallel.limit to limit the concurrent running processes
  • reportLocation (required if using xunit-file reporter): specify where xunit report files should be written. Note: if you are using "xunit-file" as your reporter, you need to add it to your package.json
  • noFail (optional: defaults to false): If true, the task will exit as zero regardless of any mocha test failures

iterations options

Array of JSON objects. mocha will loop for each item, using its properties for the mocha run

  • iterations[N].description (optional): put this within your iteration objects in order to better label your console output or xunit report file
  • iterations[N].mocha (optional): grunt-loop-mocha will merge this mocha object with the one in your root "options" namespace for this iteration's mocha run
  • iterations[N].: grunt-loop-mocha will merge this mocha object with any of the same name it finds in your root "options" namespace

mocha process environment variables

Additional sibling elements to mocha/loop/iterations will be set as environment variables of the same name as the key. If the key value is a JSON object, grunt-loop-mocha will call JSON.stringify before storing it as an

mocha_bin option (optional: defaults to null)

String, path to mocha or 'mocha compatible' executable. This option allows to override default mocha

     loopmocha.options."mocha_bin": '<custom-bin-path>'