Skip to content

Commit 6552fdd

Browse files
pmarchiniRafaelGSS
authored andcommitted
test_runner: update kPatterns
PR-URL: #54728 Fixes: #54726 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Jake Yuesong Li <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Chemi Atlow <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Moshe Atlow <[email protected]>
1 parent 7a1d633 commit 6552fdd

File tree

7 files changed

+48
-1
lines changed

7 files changed

+48
-1
lines changed

lib/internal/test_runner/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const coverageColors = {
5151
const kMultipleCallbackInvocations = 'multipleCallbackInvocations';
5252
const kRegExpPattern = /^\/(.*)\/([a-z]*)$/;
5353

54-
const kPatterns = ['test', 'test/**/*', 'test-*', '*[.-_]test'];
54+
const kPatterns = ['test', 'test/**/*', 'test-*', '*[._-]test'];
5555
const kDefaultPattern = `**/{${ArrayPrototypeJoin(kPatterns, ',')}}.?(c|m)js`;
5656

5757

test/fixtures/test-runner/issue-54726/latest.js

Whitespace-only changes.

test/fixtures/test-runner/issue-54726/non-matching.js

Whitespace-only changes.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
'use strict';
2+
const test = require('node:test');
3+
4+
test('this should pass');
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
'use strict';
2+
const test = require('node:test');
3+
4+
test('this should pass');
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
'use strict';
2+
import test from 'node:test';
3+
4+
test('this should pass');

test/parallel/test-runner-cli.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,22 @@ for (const isolation of ['none', 'process']) {
4343
assert.match(stdout, /ok 6 - this should be executed/);
4444
}
4545

46+
{
47+
// Should match files with "-test.(c|m)js" suffix.
48+
const args = ['--test', '--test-reporter=tap',
49+
`--experimental-test-isolation=${isolation}`];
50+
const child = spawnSync(process.execPath, args, { cwd: join(testFixtures, 'matching-patterns') });
51+
52+
assert.strictEqual(child.status, 0);
53+
assert.strictEqual(child.signal, null);
54+
assert.strictEqual(child.stderr.toString(), '');
55+
const stdout = child.stdout.toString();
56+
57+
assert.match(stdout, /ok 1 - this should pass/);
58+
assert.match(stdout, /ok 2 - this should pass/);
59+
assert.match(stdout, /ok 3 - this should pass/);
60+
}
61+
4662
{
4763
// Same but with a prototype mutation in require scripts.
4864
const args = [
@@ -361,3 +377,22 @@ for (const isolation of ['none', 'process']) {
361377
assert.match(stdout, /# fail 0/);
362378
assert.match(stdout, /# skipped 0/);
363379
}
380+
381+
{
382+
// Should not match files like latest.js
383+
const args = ['--test', '--test-reporter=tap'];
384+
const child = spawnSync(process.execPath, args, { cwd: join(testFixtures, 'issue-54726') });
385+
386+
assert.strictEqual(child.status, 0);
387+
assert.strictEqual(child.signal, null);
388+
assert.strictEqual(child.stderr.toString(), '');
389+
const stdout = child.stdout.toString();
390+
391+
assert.match(stdout, /tests 0/);
392+
assert.match(stdout, /suites 0/);
393+
assert.match(stdout, /pass 0/);
394+
assert.match(stdout, /fail 0/);
395+
assert.match(stdout, /cancelled 0/);
396+
assert.match(stdout, /skipped 0/);
397+
assert.match(stdout, /todo 0/);
398+
}

0 commit comments

Comments
 (0)