From 3927adcf91848b70ce851fb9bb508b9cc3583301 Mon Sep 17 00:00:00 2001 From: Pietro Marchini Date: Tue, 3 Sep 2024 15:55:07 +0200 Subject: [PATCH] test: add -test.(c|m)js test cases --- .../test-runner/matching-patterns/index-test.cjs | 4 ++++ .../test-runner/matching-patterns/index-test.js | 4 ++++ .../test-runner/matching-patterns/index-test.mjs | 4 ++++ test/parallel/test-runner-cli.js | 16 ++++++++++++++++ 4 files changed, 28 insertions(+) create mode 100644 test/fixtures/test-runner/matching-patterns/index-test.cjs create mode 100644 test/fixtures/test-runner/matching-patterns/index-test.js create mode 100644 test/fixtures/test-runner/matching-patterns/index-test.mjs diff --git a/test/fixtures/test-runner/matching-patterns/index-test.cjs b/test/fixtures/test-runner/matching-patterns/index-test.cjs new file mode 100644 index 00000000000000..2a722c504b9fa5 --- /dev/null +++ b/test/fixtures/test-runner/matching-patterns/index-test.cjs @@ -0,0 +1,4 @@ +'use strict'; +const test = require('node:test'); + +test('this should pass'); diff --git a/test/fixtures/test-runner/matching-patterns/index-test.js b/test/fixtures/test-runner/matching-patterns/index-test.js new file mode 100644 index 00000000000000..2a722c504b9fa5 --- /dev/null +++ b/test/fixtures/test-runner/matching-patterns/index-test.js @@ -0,0 +1,4 @@ +'use strict'; +const test = require('node:test'); + +test('this should pass'); diff --git a/test/fixtures/test-runner/matching-patterns/index-test.mjs b/test/fixtures/test-runner/matching-patterns/index-test.mjs new file mode 100644 index 00000000000000..49290287eb348c --- /dev/null +++ b/test/fixtures/test-runner/matching-patterns/index-test.mjs @@ -0,0 +1,4 @@ +'use strict'; +import test from 'node:test'; + +test('this should pass'); diff --git a/test/parallel/test-runner-cli.js b/test/parallel/test-runner-cli.js index a1e3e2d85554e4..490893b671d9c3 100644 --- a/test/parallel/test-runner-cli.js +++ b/test/parallel/test-runner-cli.js @@ -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 = [