New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mocha.parallel

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mocha.parallel - npm Package Compare versions

Comparing version 0.7.1 to 0.8.0

fixtures/parallelSkip.js

4

fixtures/index.js

@@ -5,4 +5,4 @@ var path = require('path');

var fixtures = ['delay', 'multiple', 'hooks', 'hooksExample',
'uncaughtException', 'skip', 'only', 'parallelOnly', 'failure',
'assertionFailure', 'parentHooks', 'sync'];
'uncaughtException', 'parallelSkip', 'skip', 'only', 'parallelOnly',
'failure', 'assertionFailure', 'parentHooks', 'sync'];

@@ -9,0 +9,0 @@ fixtures.forEach(function(fixture) {

@@ -9,4 +9,5 @@ var Promise = require('bluebird');

* output. Compatible with both callbacks and promises. Supports hooks, pending
* or skipped specs, but not nested suites. parallel.only() or it.only() may
* be used to only wait on the specified specs or suites.
* or skipped specs/suites via parallel.skip() and it.skip(), but not nested
* suites. parallel.only() and it.only() may be used to only wait on the
* specified specs and suites.
*

@@ -23,6 +24,17 @@ * @example

*
* @param {string} name
* @param {function} fn
* @param {string} name Name of the function
* @param {function} fn The test suite's body
*/
function parallel(name, fn, only) {
function parallel(name, fn) {
_parallel(name, fn);
}
/**
* Private function invoked by parallel.
*
* @param {string} name Name of the function
* @param {function} fn The suite or test body
* @param {string} [key] One of 'skip' or 'only'
*/
function _parallel(name, fn, key) {
var specs = [];

@@ -48,3 +60,3 @@ var hooks = {};

run = function() {
// If spec.only() was used, only invoke that subset of specs
// If it.only() was used, only invoke that subset of specs
var onlySpecs = specs.filter(function(spec) {

@@ -77,3 +89,3 @@ return spec.only;

(only ? describe.only : describe)(name, function() {
(key ? describe[key] : describe)(name, function() {
var parentContext = this;

@@ -113,3 +125,3 @@ if (!specs.length) return;

});
};
}

@@ -123,6 +135,16 @@ /**

parallel.only = function(name, fn) {
parallel(name, fn, true);
_parallel(name, fn, 'only');
};
/**
* Wrapper for mocha's describe.skip()
*
* @param {string} name
* @param {function} fn
*/
parallel.skip = function(name, fn) {
_parallel(name, fn, 'skip');
};
/**
* Patches the global it() function used by mocha, and returns a function that

@@ -129,0 +151,0 @@ * restores the original behavior when invoked.

{
"name": "mocha.parallel",
"version": "0.7.1",
"version": "0.8.0",
"description": "Run async mocha specs in parallel",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -8,2 +8,10 @@ # mocha.parallel

## Success stories
* **[neo-async](https://github.com/suguru03/neo-async/commit/10af3dbb84c19ca2b0bb06892b188832649198d0)**:
Cut test suite running time from 20m to 7m
* **[nightmare](https://github.com/segmentio/nightmare/pull/209)**:
Cut test suite running time from 2m to 1m
* **[node-horseman](https://github.com/johntitus/node-horseman/commit/8fe00cd372ad1d9c1e794da8d61ee51149c63d6f)**
## Installation

@@ -22,4 +30,5 @@

* output. Compatible with both callbacks and promises. Supports hooks, pending
* or skipped specs, but not nested suites. parallel.only() or it.only() may
* be used to only wait on the specified specs or suites.
* or skipped specs/suites via parallel.skip() and it.skip(), but not nested
* suites. parallel.only() and it.only() may be used to only wait on the
* specified specs and suites.
*

@@ -36,12 +45,7 @@ * @example

*
* @param {string} name
* @param {function} fn
* @param {string} name Name of the function
* @param {function} fn The test suite's body
*/
```
## Success stories
* **[nightmare](https://github.com/segmentio/nightmare/pull/209)**:
Cut test suite running time from 2m to 1m
## Examples

@@ -48,0 +52,0 @@

@@ -148,3 +148,3 @@ var exec = require('child_process').exec;

it('is compatible with it.skip for pending specs', function(done) {
it('supports it.skip for pending specs', function(done) {
var cmd = './node_modules/.bin/mocha ' + fixtures.skip;

@@ -162,3 +162,17 @@ exec(cmd, function(err, stdout, stderr) {

it('is compatible with it.only for pending specs', function(done) {
it('supports parallel.skip for pending suites', function(done) {
var cmd = './node_modules/.bin/mocha ' + fixtures.parallelSkip;
exec(cmd, function(err, stdout, stderr) {
if (err) return done(err);
assert(!stderr.length);
assert(stdout.indexOf('should not be printed') === -1);
assert(stdout.indexOf('3 passing') !== -1);
assert(stdout.indexOf('1 pending') !== -1);
done();
});
});
it('supports it.only for specs', function(done) {
var cmd = './node_modules/.bin/mocha ' + fixtures.only;

@@ -176,3 +190,3 @@ exec(cmd, function(err, stdout, stderr) {

it('is compatible with parallel.only for pending specs', function(done) {
it('supports parallel.only for suites', function(done) {
var cmd = './node_modules/.bin/mocha ' + fixtures.parallelOnly;

@@ -179,0 +193,0 @@ exec(cmd, function(err, stdout, stderr) {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc