Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/internal/test_runner/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const coverageColors = {
const kMultipleCallbackInvocations = 'multipleCallbackInvocations';
const kRegExpPattern = /^\/(.*)\/([a-z]*)$/;

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


Expand Down
Empty file.
Empty file.
4 changes: 4 additions & 0 deletions test/fixtures/test-runner/matching-patterns/index-test.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'use strict';
const test = require('node:test');

test('this should pass');
4 changes: 4 additions & 0 deletions test/fixtures/test-runner/matching-patterns/index-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'use strict';
const test = require('node:test');

test('this should pass');
4 changes: 4 additions & 0 deletions test/fixtures/test-runner/matching-patterns/index-test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'use strict';
import test from 'node:test';

test('this should pass');
35 changes: 35 additions & 0 deletions test/parallel/test-runner-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,22 @@ for (const isolation of ['none', 'process']) {
assert.match(stdout, /ok 6 - this should be executed/);
}

{
// Should match files with "-test.(c|m)js" suffix.
const args = ['--test', '--test-reporter=tap',
`--experimental-test-isolation=${isolation}`];
const child = spawnSync(process.execPath, args, { cwd: join(testFixtures, 'matching-patterns') });

assert.strictEqual(child.status, 0);
assert.strictEqual(child.signal, null);
assert.strictEqual(child.stderr.toString(), '');
const stdout = child.stdout.toString();

assert.match(stdout, /ok 1 - this should pass/);
assert.match(stdout, /ok 2 - this should pass/);
assert.match(stdout, /ok 3 - this should pass/);
}

{
// Same but with a prototype mutation in require scripts.
const args = [
Expand Down Expand Up @@ -361,3 +377,22 @@ for (const isolation of ['none', 'process']) {
assert.match(stdout, /# fail 0/);
assert.match(stdout, /# skipped 0/);
}

{
// Should not match files like latest.js
const args = ['--test', '--test-reporter=tap'];
const child = spawnSync(process.execPath, args, { cwd: join(testFixtures, 'issue-54726') });

assert.strictEqual(child.status, 0);
assert.strictEqual(child.signal, null);
assert.strictEqual(child.stderr.toString(), '');
const stdout = child.stdout.toString();

assert.match(stdout, /tests 0/);
assert.match(stdout, /suites 0/);
assert.match(stdout, /pass 0/);
assert.match(stdout, /fail 0/);
assert.match(stdout, /cancelled 0/);
assert.match(stdout, /skipped 0/);
assert.match(stdout, /todo 0/);
}