diff --git a/lib/interfaces/common.js b/lib/interfaces/common.js index 6505e05a76..f0cdd4eb1a 100644 --- a/lib/interfaces/common.js +++ b/lib/interfaces/common.js @@ -113,6 +113,8 @@ module.exports = function (suites, context, mocha) { suites.shift(); } else if (typeof opts.fn === 'undefined' && !suite.pending) { throw new Error('Suite "' + suite.fullTitle() + '" was defined but no callback was supplied. Supply a callback or explicitly skip the suite.'); + } else if (!opts.fn && suite.pending) { + suites.shift(); } return suite; diff --git a/test/integration/fixtures/pending/skip-hierarchy.fixture.js b/test/integration/fixtures/pending/skip-hierarchy.fixture.js new file mode 100644 index 0000000000..46500098b2 --- /dev/null +++ b/test/integration/fixtures/pending/skip-hierarchy.fixture.js @@ -0,0 +1,9 @@ +'use strict'; + +describe('a suite', function(){ + describe.skip('skipped suite 1'); + describe.skip('skipped suite 2'); + describe('another suite', function(){ + it('a test', function(){}) + }) +}); diff --git a/test/integration/pending.spec.js b/test/integration/pending.spec.js index 30cf61ceb2..af665accf6 100644 --- a/test/integration/pending.spec.js +++ b/test/integration/pending.spec.js @@ -32,6 +32,21 @@ describe('pending', function () { done(); }); }); + it('should keep hierarchies of suites', function (done) { + run('pending/skip-hierarchy.fixture.js', args, function (err, res) { + if (err) { + done(err); + return; + } + assert.equal(res.stats.suites, 2); + assert.equal(res.stats.pending, 0); + assert.equal(res.stats.passes, 1); + assert.equal(res.stats.failures, 0); + assert.equal(res.code, 0); + assert.equal(res.passes[0].fullTitle, 'a suite another suite a test'); + done(); + }); + }); }); describe('synchronous skip()', function () {