diff --git a/lib/internal/test_runner/runner.js b/lib/internal/test_runner/runner.js index d6976c56082f72..68f5cda30bffac 100644 --- a/lib/internal/test_runner/runner.js +++ b/lib/internal/test_runner/runner.js @@ -531,6 +531,9 @@ function run(options) { } const root = createTestTree({ __proto__: null, concurrency, timeout, signal }); + if (process.env.NODE_TEST_CONTEXT !== undefined) { + return root.reporter; + } let testFiles = files ?? createTestFileList(); if (shard) { diff --git a/test/parallel/test-runner-run.mjs b/test/parallel/test-runner-run.mjs index 35dbf359d36690..74d6d91937678c 100644 --- a/test/parallel/test-runner-run.mjs +++ b/test/parallel/test-runner-run.mjs @@ -458,4 +458,37 @@ describe('require(\'node:test\').run', { concurrency: true }, () => { assert.deepStrictEqual(executedTestFiles.sort(), [...shardsTestsFiles].sort()); }); }); + + it('should run with no files', async () => { + const stream = run({ + files: undefined + }).compose(tap); + stream.on('test:fail', common.mustNotCall()); + stream.on('test:pass', common.mustNotCall()); + + // eslint-disable-next-line no-unused-vars + for await (const _ of stream); + }); + + it('should run with no files and use spec reporter', async () => { + const stream = run({ + files: undefined + }).compose(spec); + stream.on('test:fail', common.mustNotCall()); + stream.on('test:pass', common.mustNotCall()); + + // eslint-disable-next-line no-unused-vars + for await (const _ of stream); + }); + + it('should run with no files and use dot reporter', async () => { + const stream = run({ + files: undefined + }).compose(dot); + stream.on('test:fail', common.mustNotCall()); + stream.on('test:pass', common.mustNotCall()); + + // eslint-disable-next-line no-unused-vars + for await (const _ of stream); + }); });