Skip to content

Commit 1df502d

Browse files
rhendricnovemberborn
authored andcommitted
Match anonymous tests as if they had an empty title (#1502)
1 parent 6915dde commit 1df502d

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

lib/runner.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ class Runner extends EventEmitter {
113113
}
114114

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

119119
const validationError = validateTest(title, fn, metadata);

test/runner.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,32 @@ test('options.match overrides .only', t => {
711711
});
712712
});
713713

714+
test('options.match includes anonymous tests in negative matches', t => {
715+
t.plan(4);
716+
717+
const runner = new Runner({
718+
match: ['!*oo']
719+
});
720+
721+
runner.chain.test('foo', a => {
722+
t.fail();
723+
a.pass();
724+
});
725+
726+
runner.chain.test(a => {
727+
t.pass();
728+
a.pass();
729+
});
730+
731+
runner.run({}).then(() => {
732+
const stats = runner.buildStats();
733+
t.is(stats.skipCount, 0);
734+
t.is(stats.passCount, 1);
735+
t.is(stats.testCount, 1);
736+
t.end();
737+
});
738+
});
739+
714740
test('macros: Additional args will be spread as additional args on implementation function', t => {
715741
t.plan(3);
716742

0 commit comments

Comments
 (0)