-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Description
I was excited to see improvements to .only() in the Mocha 3.0.0 changelog. It's mostly working well, but I found a regression. Consider the following test file with nested describe()s:
var assert = require('assert');
describe('Array', function() {
describe('.push()', function() {
it('appends a value to the end of the array', function() {
var array = [1];
array.push(2);
assert.deepEqual(array, [1, 2]);
});
it('can append more than one value to the end of the array', function() {
var array = [1];
array.push(2, 3);
assert.deepEqual(array, [1, 2, 3]);
});
});
describe('.reverse()', function() {
it('reverses a non-empty array', function() {
assert.deepEqual([1, 2, 3].reverse(), [3, 2, 1]);
});
it('does nothing to an empty array', function() {
assert.deepEqual([].reverse(), []);
});
});
});
In previous versions of mocha, you could add a .only() to one of the inner describe()s and it would do what you expect. For example, if I changed that file to look like:
describe.only('.push()', function() {
It should run 2 tests. That's the way previous versions of Mocha behaved. It's a very useful behavior that my team uses every day.
In Mocha 3.0.0 it runs 0 tests.
A few other notes:
.only()on the top-mostdescribe()in a file works fine- changing
describe()tocontext()doesn't affect the behavior (same issue withcontext())
msafi, not-an-aardvark, albanv, Kuniwak, samouss and 5 more
Metadata
Metadata
Assignees
Labels
No labels