GithubHelp home page GithubHelp logo

isabella232 / grunt-loop-mocha Goto Github PK

View Code? Open in Web Editor NEW

This project forked from grawk/grunt-loop-mocha

0.0 0.0 0.0 71 KB

Run mocha command line multiple times, save pass through variables in a config file

License: MIT License

JavaScript 100.00%

grunt-loop-mocha's Introduction

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>'

grunt-loop-mocha's People

Contributors

grawk avatar seebees avatar viswanathankasi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.