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()
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Metadata
Assignees
Labels
No labels