diff --git a/doc/api/test.md b/doc/api/test.md index 78565bc61b50fd..cbfc9db94bb58c 100644 --- a/doc/api/test.md +++ b/doc/api/test.md @@ -1247,9 +1247,6 @@ added: - v18.9.0 - v16.19.0 changes: - - version: REPLACEME - pr-url: https://github.com/nodejs/node/pull/54225 - description: Added the `cwd` option. - version: REPLACEME pr-url: https://github.com/nodejs/node/pull/53927 description: Added the `isolation` option. @@ -1277,9 +1274,6 @@ changes: parallel. If `false`, it would only run one test file at a time. **Default:** `false`. - * `cwd`: {string} Specifies the current working directory to be used by the test runner. - The cwd serves as the base path for resolving files according to the [test runner execution model][]. - **Default:** `process.cwd()`. * `files`: {Array} An array containing the list of files to run. **Default** matching files from [test runner execution model][]. * `forceExit`: {boolean} Configures the test runner to exit the process once diff --git a/lib/internal/test_runner/runner.js b/lib/internal/test_runner/runner.js index 00f370ae279cda..9590ef8dcf75bf 100644 --- a/lib/internal/test_runner/runner.js +++ b/lib/internal/test_runner/runner.js @@ -54,7 +54,6 @@ const { validateObject, validateOneOf, validateInteger, - validateString, } = require('internal/validators'); const { getInspectPort, isUsingInspector, isInspectorMessage } = require('internal/util/inspector'); const { isRegExp } = require('internal/util/types'); @@ -537,7 +536,6 @@ function run(options = kEmptyObject) { setup, only, globPatterns, - cwd = process.cwd(), } = options; if (files != null) { @@ -562,8 +560,6 @@ function run(options = kEmptyObject) { validateArray(globPatterns, 'options.globPatterns'); } - validateString(cwd, 'options.cwd'); - if (globPatterns?.length > 0 && files?.length > 0) { throw new ERR_INVALID_ARG_VALUE( 'options.globPatterns', globPatterns, 'is not supported when specifying \'options.files\'', @@ -629,6 +625,9 @@ function run(options = kEmptyObject) { }; const root = createTestTree(rootTestOptions, globalOptions); + // This const should be replaced by a run option in the future. + const cwd = process.cwd(); + let testFiles = files ?? createTestFileList(globPatterns, cwd); if (shard) { diff --git a/test/parallel/test-runner-run.mjs b/test/parallel/test-runner-run.mjs index 355bbaee13fcd5..7a575da9c95275 100644 --- a/test/parallel/test-runner-run.mjs +++ b/test/parallel/test-runner-run.mjs @@ -481,13 +481,6 @@ describe('require(\'node:test\').run', { concurrency: true }, () => { }); }); - it('should only allow a string in options.cwd', async () => { - [Symbol(), {}, [], () => {}, 0, 1, 0n, 1n, true, false] - .forEach((cwd) => assert.throws(() => run({ cwd }), { - code: 'ERR_INVALID_ARG_TYPE' - })); - }); - it('should only allow object as options', () => { [Symbol(), [], () => {}, 0, 1, 0n, 1n, '', '1', true, false] .forEach((options) => assert.throws(() => run(options), { @@ -520,33 +513,6 @@ describe('require(\'node:test\').run', { concurrency: true }, () => { for await (const _ of stream); assert.match(stderr, /Warning: node:test run\(\) is being called recursively/); }); - - it('should run with different cwd', async () => { - const stream = run({ - cwd: fixtures.path('test-runner', 'cwd') - }); - stream.on('test:fail', common.mustNotCall()); - stream.on('test:pass', common.mustCall(1)); - - // eslint-disable-next-line no-unused-vars - for await (const _ of stream); - }); - - it('should run with different cwd while in watch mode', async () => { - const controller = new AbortController(); - const stream = run({ - cwd: fixtures.path('test-runner', 'cwd'), - watch: true, - signal: controller.signal, - }).on('data', function({ type }) { - if (type === 'test:watch:drained') { - controller.abort(); - } - }); - - stream.on('test:fail', common.mustNotCall()); - stream.on('test:pass', common.mustCall(1)); - }); }); describe('forceExit', () => {