Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Match anonymous tests as if they had an empty title (#1502)
  • Loading branch information
rhendric authored and novemberborn committed Sep 5, 2017
1 parent 6915dde commit 1df502d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/runner.js
Expand Up @@ -113,7 +113,7 @@ class Runner extends EventEmitter {
}

if (metadata.type === 'test' && this.match.length > 0) {
metadata.exclusive = title !== null && matcher([title], this.match).length === 1;
metadata.exclusive = matcher([title || ''], this.match).length === 1;
}

const validationError = validateTest(title, fn, metadata);
Expand Down
26 changes: 26 additions & 0 deletions test/runner.js
Expand Up @@ -711,6 +711,32 @@ test('options.match overrides .only', t => {
});
});

test('options.match includes anonymous tests in negative matches', t => {
t.plan(4);

const runner = new Runner({
match: ['!*oo']
});

runner.chain.test('foo', a => {
t.fail();
a.pass();
});

runner.chain.test(a => {
t.pass();
a.pass();
});

runner.run({}).then(() => {
const stats = runner.buildStats();
t.is(stats.skipCount, 0);
t.is(stats.passCount, 1);
t.is(stats.testCount, 1);
t.end();
});
});

test('macros: Additional args will be spread as additional args on implementation function', t => {
t.plan(3);

Expand Down

0 comments on commit 1df502d

Please sign in to comment.