Skip to content

Commit d80bde0

Browse files
committed
Added support for it.skip()
1 parent f6e0fc0 commit d80bde0

File tree

5 files changed

+48
-5
lines changed

5 files changed

+48
-5
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ npm install --save mocha.parallel
1717
/**
1818
* Generates a suite for parallel execution of individual specs. While each
1919
* spec is ran in parallel, specs resolve in series, leading to deterministic
20-
* output. Compatible with both callbacks and promises. Supports hooks, but
21-
* not nested suites.
20+
* output. Compatible with both callbacks and promises. Supports hooks, pending
21+
* or skipped specs, but not nested suites.
2222
*
2323
* @example
2424
* parallel('setTimeout', function() {

fixtures/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ var path = require('path');
22

33
var absolutePaths = {};
44
var fixtures = ['delay', 'multiple', 'hooks', 'hooksSimple',
5-
'uncaughtException'];
5+
'uncaughtException', 'skip'];
66

77
fixtures.forEach(function(fixture) {
88
absolutePaths[fixture] = path.resolve(__dirname, fixture + '.js');

fixtures/skip.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
var parallel = require('../index.js');
2+
3+
parallel('suite', function() {
4+
it('test1', function(done) {
5+
setTimeout(done, 500);
6+
});
7+
8+
it.skip('test2', function(done) {
9+
setTimeout(done, 500);
10+
});
11+
12+
it('test3', function(done) {
13+
setTimeout(done, 500);
14+
});
15+
});

index.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ var hookTypes = ['before', 'beforeEach', 'afterEach', 'after'];
55
/**
66
* Generates a suite for parallel execution of individual specs. While each
77
* spec is ran in parallel, specs resolve in series, leading to deterministic
8-
* output. Compatible with both callbacks and promises. Supports hooks, but
9-
* not nested suites.
8+
* output. Compatible with both callbacks and promises. Supports hooks, pending
9+
* or skipped specs, but not nested suites.
1010
*
1111
* @example
1212
* parallel('setTimeout', function() {
@@ -75,6 +75,10 @@ module.exports = function parallel(name, fn) {
7575
});
7676

7777
specs.forEach(function(spec) {
78+
if (spec.skip) {
79+
return it.skip(spec.name);
80+
}
81+
7882
it(spec.name, function() {
7983
if (spec.err) throw spec.err;
8084
return spec.promise.then(function() {
@@ -102,6 +106,17 @@ function patchIt(specs) {
102106
specs.push({
103107
name: name,
104108
getPromise: createWrapper(fn),
109+
skip: null,
110+
error: null,
111+
promise: null
112+
});
113+
};
114+
115+
it.skip = function skip(name, fn) {
116+
specs.push({
117+
name: name,
118+
getPromise: createWrapper(fn),
119+
skip: true,
105120
error: null,
106121
promise: null
107122
});

test.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,17 @@ describe('parallel', function() {
9292
done();
9393
});
9494
});
95+
96+
it('is compatible with it.skip for pending specs', function(done) {
97+
var cmd = './node_modules/.bin/mocha ' + fixtures.skip;
98+
exec(cmd, function(err, stdout, stderr) {
99+
if (err) return done(err);
100+
101+
assert(!stderr.length);
102+
assert(stdout.indexOf('2 passing') !== -1);
103+
assert(stdout.indexOf('1 pending') !== -1);
104+
105+
done();
106+
});
107+
});
95108
});

0 commit comments

Comments
 (0)