From c21b6c7919d2fa845205c9345249e25e4cb8f05b Mon Sep 17 00:00:00 2001 From: y-okt Date: Sat, 22 Nov 2025 23:16:45 +0900 Subject: [PATCH 1/9] test: skip failing tests when compiled without amaro When compiled without amaro, this conflicts with --experimental-strip-types defaulting to true. To avoid that, we need to skip relevant failing tests. Fixes: https://github.com/nodejs/node/issues/60640 --- test/es-module/test-esm-detect-ambiguous.mjs | 7 ++++++- test/es-module/test-esm-import-meta-main-eval.mjs | 7 ++++++- ...esm-tla-syntax-errors-not-recognized-as-tla-error.mjs | 7 ++++++- test/parallel/test-compile-cache-typescript-commonjs.js | 6 +++++- test/parallel/test-compile-cache-typescript-esm.js | 6 +++++- .../parallel/test-compile-cache-typescript-strip-miss.js | 6 +++++- .../test-compile-cache-typescript-strip-sourcemaps.js | 6 +++++- test/parallel/test-compile-cache-typescript-transform.js | 6 +++++- test/parallel/test-config-file.js | 9 +++++++-- test/parallel/test-node-output-eval.mjs | 6 +++++- test/parallel/test-node-output-sourcemaps.mjs | 6 +++++- test/parallel/test-runner-coverage-default-exclusion.mjs | 6 +++++- test/parallel/test-runner-global-setup-teardown.mjs | 6 +++++- test/parallel/test-runner-run-global-hooks.mjs | 6 +++++- test/parallel/test-util-getcallsites.js | 6 ++++-- test/parallel/test-worker-cli-options.js | 4 ++++ test/parallel/test-worker-eval-typescript.js | 6 +++++- ...test-worker-load-file-with-extension-other-than-js.js | 5 ++++- test/parallel/test-worker-syntax-error.js | 4 ++++ test/test-runner/test-output-typescript-coverage.mjs | 4 ++++ 20 files changed, 100 insertions(+), 19 deletions(-) diff --git a/test/es-module/test-esm-detect-ambiguous.mjs b/test/es-module/test-esm-detect-ambiguous.mjs index 234e27a947a13f..16495425ad96a3 100644 --- a/test/es-module/test-esm-detect-ambiguous.mjs +++ b/test/es-module/test-esm-detect-ambiguous.mjs @@ -1,9 +1,14 @@ -import { spawnPromisified } from '../common/index.mjs'; +import * as common from '../common/index.mjs'; import * as fixtures from '../common/fixtures.mjs'; import { spawn } from 'node:child_process'; import { describe, it } from 'node:test'; import assert from 'node:assert'; +if (!process.config.variables.node_use_amaro) { + common.skip('Requires Amaro'); +} +const { spawnPromisified } = common; + describe('Module syntax detection', { concurrency: !process.env.TEST_PARALLEL }, () => { describe('string input', { concurrency: !process.env.TEST_PARALLEL }, () => { it('permits ESM syntax in --eval input without requiring --input-type=module', async () => { diff --git a/test/es-module/test-esm-import-meta-main-eval.mjs b/test/es-module/test-esm-import-meta-main-eval.mjs index cf4642eac89d6e..ecc25aa1b94443 100644 --- a/test/es-module/test-esm-import-meta-main-eval.mjs +++ b/test/es-module/test-esm-import-meta-main-eval.mjs @@ -1,8 +1,13 @@ -import { spawnPromisified } from '../common/index.mjs'; +import * as common from '../common/index.mjs'; import * as fixtures from '../common/fixtures.js'; import assert from 'node:assert/strict'; import { describe, it } from 'node:test'; +if (!process.config.variables.node_use_amaro) { + common.skip('Requires Amaro'); +} +const { spawnPromisified } = common; + function wrapScriptInEvalWorker(script) { return ` import { Worker } from 'node:worker_threads'; diff --git a/test/es-module/test-esm-tla-syntax-errors-not-recognized-as-tla-error.mjs b/test/es-module/test-esm-tla-syntax-errors-not-recognized-as-tla-error.mjs index ed6d3e44f8f14b..548a4a92bffa25 100644 --- a/test/es-module/test-esm-tla-syntax-errors-not-recognized-as-tla-error.mjs +++ b/test/es-module/test-esm-tla-syntax-errors-not-recognized-as-tla-error.mjs @@ -1,7 +1,12 @@ -import { spawnPromisified } from '../common/index.mjs'; +import * as common from '../common/index.mjs'; import { describe, it } from 'node:test'; import assert from 'node:assert'; +if (!process.config.variables.node_use_amaro) { + common.skip('Requires Amaro'); +} +const { spawnPromisified } = common; + describe('unusual top-level await syntax errors', () => { const expressions = [ // string diff --git a/test/parallel/test-compile-cache-typescript-commonjs.js b/test/parallel/test-compile-cache-typescript-commonjs.js index b6c4581ed47be3..480791f834190c 100644 --- a/test/parallel/test-compile-cache-typescript-commonjs.js +++ b/test/parallel/test-compile-cache-typescript-commonjs.js @@ -2,12 +2,16 @@ // This tests NODE_COMPILE_CACHE works for CommonJS with types. -require('../common'); +const common = require('../common'); const { spawnSyncAndAssert } = require('../common/child_process'); const assert = require('assert'); const tmpdir = require('../common/tmpdir'); const fixtures = require('../common/fixtures'); +if (!process.config.variables.node_use_amaro) { + common.skip('Requires Amaro'); +} + // Check cache for .ts files that would be run as CommonJS. { tmpdir.refresh(); diff --git a/test/parallel/test-compile-cache-typescript-esm.js b/test/parallel/test-compile-cache-typescript-esm.js index cec7b814da6679..eecb33348a2d8a 100644 --- a/test/parallel/test-compile-cache-typescript-esm.js +++ b/test/parallel/test-compile-cache-typescript-esm.js @@ -2,12 +2,16 @@ // This tests NODE_COMPILE_CACHE works for ESM with types. -require('../common'); +const common = require('../common'); const { spawnSyncAndAssert } = require('../common/child_process'); const assert = require('assert'); const tmpdir = require('../common/tmpdir'); const fixtures = require('../common/fixtures'); +if (!process.config.variables.node_use_amaro) { + common.skip('Requires Amaro'); +} + // Check cache for .ts files that would be run as ESM. { tmpdir.refresh(); diff --git a/test/parallel/test-compile-cache-typescript-strip-miss.js b/test/parallel/test-compile-cache-typescript-strip-miss.js index 5d37a377f002e4..5dd26bf6c042e0 100644 --- a/test/parallel/test-compile-cache-typescript-strip-miss.js +++ b/test/parallel/test-compile-cache-typescript-strip-miss.js @@ -3,12 +3,16 @@ // This tests NODE_COMPILE_CACHE can handle cache invalidation // between strip-only TypeScript and transformed TypeScript. -require('../common'); +const common = require('../common'); const { spawnSyncAndAssert } = require('../common/child_process'); const assert = require('assert'); const tmpdir = require('../common/tmpdir'); const fixtures = require('../common/fixtures'); +if (!process.config.variables.node_use_amaro) { + common.skip('Requires Amaro'); +} + tmpdir.refresh(); const dir = tmpdir.resolve('.compile_cache_dir'); const script = fixtures.path('typescript', 'ts', 'test-typescript.ts'); diff --git a/test/parallel/test-compile-cache-typescript-strip-sourcemaps.js b/test/parallel/test-compile-cache-typescript-strip-sourcemaps.js index da5e350496f005..d2a1047ff63d24 100644 --- a/test/parallel/test-compile-cache-typescript-strip-sourcemaps.js +++ b/test/parallel/test-compile-cache-typescript-strip-sourcemaps.js @@ -3,12 +3,16 @@ // This tests NODE_COMPILE_CACHE can be used for type stripping and ignores // --enable-source-maps as there's no difference in the code generated. -require('../common'); +const common = require('../common'); const { spawnSyncAndAssert } = require('../common/child_process'); const assert = require('assert'); const tmpdir = require('../common/tmpdir'); const fixtures = require('../common/fixtures'); +if (!process.config.variables.node_use_amaro) { + common.skip('Requires Amaro'); +} + tmpdir.refresh(); const dir = tmpdir.resolve('.compile_cache_dir'); const script = fixtures.path('typescript', 'ts', 'test-typescript.ts'); diff --git a/test/parallel/test-compile-cache-typescript-transform.js b/test/parallel/test-compile-cache-typescript-transform.js index 41eb67b203baa1..4dd2a2c67fdb34 100644 --- a/test/parallel/test-compile-cache-typescript-transform.js +++ b/test/parallel/test-compile-cache-typescript-transform.js @@ -2,12 +2,16 @@ // This tests NODE_COMPILE_CACHE works with --experimental-transform-types. -require('../common'); +const common = require('../common'); const { spawnSyncAndAssert } = require('../common/child_process'); const assert = require('assert'); const tmpdir = require('../common/tmpdir'); const fixtures = require('../common/fixtures'); +if (!process.config.variables.node_use_amaro) { + common.skip('Requires Amaro'); +} + tmpdir.refresh(); const dir = tmpdir.resolve('.compile_cache_dir'); diff --git a/test/parallel/test-config-file.js b/test/parallel/test-config-file.js index 438a138f6ba227..663b6b401b7894 100644 --- a/test/parallel/test-config-file.js +++ b/test/parallel/test-config-file.js @@ -1,11 +1,11 @@ 'use strict'; +const common = require('../common'); const { isWindows, spawnPromisified, skipIfSQLiteMissing, -} = require('../common'); -skipIfSQLiteMissing(); +} = common; const fixtures = require('../common/fixtures'); const tmpdir = require('../common/tmpdir'); const assert = require('node:assert'); @@ -13,6 +13,11 @@ const { test, it, describe } = require('node:test'); const { chmodSync, writeFileSync, constants } = require('node:fs'); const { join } = require('node:path'); +if (!process.config.variables.node_use_amaro) { + common.skip('Requires Amaro'); +} +skipIfSQLiteMissing(); + test('should handle non existing json', async () => { const result = await spawnPromisified(process.execPath, [ '--experimental-config-file', diff --git a/test/parallel/test-node-output-eval.mjs b/test/parallel/test-node-output-eval.mjs index 8a3cc595742067..59d94f2b276efb 100644 --- a/test/parallel/test-node-output-eval.mjs +++ b/test/parallel/test-node-output-eval.mjs @@ -1,9 +1,13 @@ -import '../common/index.mjs'; +import * as common from '../common/index.mjs'; import * as fixtures from '../common/fixtures.mjs'; import * as snapshot from '../common/assertSnapshot.js'; import { basename } from 'node:path'; import { describe, it } from 'node:test'; +if (!process.config.variables.node_use_amaro) { + common.skip('Requires Amaro'); +} + describe('eval output', { concurrency: true }, () => { function normalize(str) { return str.replaceAll(snapshot.replaceWindowsPaths(process.cwd()), '') diff --git a/test/parallel/test-node-output-sourcemaps.mjs b/test/parallel/test-node-output-sourcemaps.mjs index 2d0e784e206b0b..00a9d78cbe0bd3 100644 --- a/test/parallel/test-node-output-sourcemaps.mjs +++ b/test/parallel/test-node-output-sourcemaps.mjs @@ -1,8 +1,12 @@ -import '../common/index.mjs'; +import * as common from '../common/index.mjs'; import * as fixtures from '../common/fixtures.mjs'; import * as snapshot from '../common/assertSnapshot.js'; import { describe, it } from 'node:test'; +if (!process.config.variables.node_use_amaro) { + common.skip('Requires Amaro'); +} + describe('sourcemaps output', { concurrency: !process.env.TEST_PARALLEL }, () => { const defaultTransform = snapshot .transform( diff --git a/test/parallel/test-runner-coverage-default-exclusion.mjs b/test/parallel/test-runner-coverage-default-exclusion.mjs index 44e5f7600d3270..32cfc2e249ad98 100644 --- a/test/parallel/test-runner-coverage-default-exclusion.mjs +++ b/test/parallel/test-runner-coverage-default-exclusion.mjs @@ -1,10 +1,14 @@ -import '../common/index.mjs'; +import * as common from '../common/index.mjs'; import { before, describe, it } from 'node:test'; import assert from 'node:assert'; import { spawnSync } from 'node:child_process'; import { cp } from 'node:fs/promises'; import tmpdir from '../common/tmpdir.js'; import fixtures from '../common/fixtures.js'; + +if (!process.config.variables.node_use_amaro) { + common.skip('Requires Amaro'); +} const skipIfNoInspector = { skip: !process.features.inspector ? 'inspector disabled' : false }; diff --git a/test/parallel/test-runner-global-setup-teardown.mjs b/test/parallel/test-runner-global-setup-teardown.mjs index 9498efbc73fc5b..0def3a96285594 100644 --- a/test/parallel/test-runner-global-setup-teardown.mjs +++ b/test/parallel/test-runner-global-setup-teardown.mjs @@ -1,4 +1,4 @@ -import '../common/index.mjs'; +import * as common from '../common/index.mjs'; import * as fixtures from '../common/fixtures.mjs'; import { describe, it, beforeEach } from 'node:test'; import assert from 'node:assert'; @@ -8,6 +8,10 @@ import tmpdir from '../common/tmpdir.js'; import { once } from 'node:events'; import { join } from 'node:path'; +if (!process.config.variables.node_use_amaro) { + common.skip('Requires Amaro'); +} + const testFixtures = fixtures.path('test-runner'); async function runTest( diff --git a/test/parallel/test-runner-run-global-hooks.mjs b/test/parallel/test-runner-run-global-hooks.mjs index d63f98af9d5f3b..0072a47a5919cc 100644 --- a/test/parallel/test-runner-run-global-hooks.mjs +++ b/test/parallel/test-runner-run-global-hooks.mjs @@ -1,4 +1,4 @@ -import { mustCall, mustCallAtLeast } from '../common/index.mjs'; +import { mustCall, mustCallAtLeast, skip } from '../common/index.mjs'; import * as fixtures from '../common/fixtures.mjs'; import { describe, it, beforeEach, run } from 'node:test'; import assert from 'node:assert'; @@ -8,6 +8,10 @@ import path from 'node:path'; import { spawn } from 'node:child_process'; import { once } from 'node:events'; +if (!process.config.variables.node_use_amaro) { + skip('Requires Amaro'); +} + const testFixtures = fixtures.path('test-runner', 'global-setup-teardown'); const runnerFixture = fixtures.path('test-runner', 'test-runner-global-hooks.mjs'); diff --git a/test/parallel/test-util-getcallsites.js b/test/parallel/test-util-getcallsites.js index 1219e097378fe8..9654ac17a32552 100644 --- a/test/parallel/test-util-getcallsites.js +++ b/test/parallel/test-util-getcallsites.js @@ -1,14 +1,16 @@ 'use strict'; const common = require('../common'); - const fixtures = require('../common/fixtures'); const file = fixtures.path('get-call-sites.js'); - const { getCallSites } = require('node:util'); const { spawnSync } = require('node:child_process'); const assert = require('node:assert'); +if (!process.config.variables.node_use_amaro) { + common.skip('Requires Amaro'); +} + { const callSites = getCallSites(); assert.ok(callSites.length > 1); diff --git a/test/parallel/test-worker-cli-options.js b/test/parallel/test-worker-cli-options.js index 3e6ab46db6ea74..04b6db5a261ebd 100644 --- a/test/parallel/test-worker-cli-options.js +++ b/test/parallel/test-worker-cli-options.js @@ -4,6 +4,10 @@ const common = require('../common'); const { Worker } = require('worker_threads'); const assert = require('assert'); +if (!process.config.variables.node_use_amaro) { + common.skip('Requires Amaro'); +} + const CODE = ` // If the --expose-internals flag does not pass to worker // require function will throw an error diff --git a/test/parallel/test-worker-eval-typescript.js b/test/parallel/test-worker-eval-typescript.js index 6998bc031a3cba..186816f86540f5 100644 --- a/test/parallel/test-worker-eval-typescript.js +++ b/test/parallel/test-worker-eval-typescript.js @@ -1,10 +1,14 @@ 'use strict'; -require('../common'); +const common = require('../common'); const assert = require('assert'); const { Worker } = require('worker_threads'); const { test } = require('node:test'); const { once } = require('events'); +if (!process.config.variables.node_use_amaro) { + common.skip('Requires Amaro'); +} + const esmHelloWorld = ` import worker from 'worker_threads'; const foo: string = 'Hello, World!'; diff --git a/test/parallel/test-worker-load-file-with-extension-other-than-js.js b/test/parallel/test-worker-load-file-with-extension-other-than-js.js index 5dca297576b978..05b22ff1188c94 100644 --- a/test/parallel/test-worker-load-file-with-extension-other-than-js.js +++ b/test/parallel/test-worker-load-file-with-extension-other-than-js.js @@ -1,9 +1,12 @@ 'use strict'; const common = require('../common'); const fixtures = require('../common/fixtures'); - const { Worker } = require('worker_threads'); +if (!process.config.variables.node_use_amaro) { + common.skip('Requires Amaro'); +} + (common.mustCall(() => { new Worker(fixtures.path('worker-script.ts')); }))(); diff --git a/test/parallel/test-worker-syntax-error.js b/test/parallel/test-worker-syntax-error.js index 99ebf26a9fa714..611fd2720c3eaa 100644 --- a/test/parallel/test-worker-syntax-error.js +++ b/test/parallel/test-worker-syntax-error.js @@ -3,6 +3,10 @@ const common = require('../common'); const assert = require('assert'); const { Worker } = require('worker_threads'); +if (!process.config.variables.node_use_amaro) { + common.skip('Requires Amaro'); +} + const w = new Worker('abc)', { eval: true }); w.on('message', common.mustNotCall()); w.on('error', common.mustCall((err) => { diff --git a/test/test-runner/test-output-typescript-coverage.mjs b/test/test-runner/test-output-typescript-coverage.mjs index 41aa97d194cc20..577e88b2774a51 100644 --- a/test/test-runner/test-output-typescript-coverage.mjs +++ b/test/test-runner/test-output-typescript-coverage.mjs @@ -4,6 +4,10 @@ import * as common from '../common/index.mjs'; import * as fixtures from '../common/fixtures.mjs'; import { spawnAndAssert, defaultTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; +if (!process.config.variables.node_use_amaro) { + common.skip('Requires Amaro'); +} + if (!process.features.inspector) { common.skip('inspector support required'); } From 6caaf5f51d44128d80c048518f8d57ff5d2bc150 Mon Sep 17 00:00:00 2001 From: y-okt Date: Sat, 22 Nov 2025 23:42:56 +0900 Subject: [PATCH 2/9] src: make --strip-types option false when compiled without amaro stripe-types option's default value is true, but we need to ensure that when compiled without amaro, the default vaue is false. Fixes: https://github.com/nodejs/node/issues/60640 --- src/node_options.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/node_options.cc b/src/node_options.cc index baa3936075cd05..49e0563b5571a0 100644 --- a/src/node_options.cc +++ b/src/node_options.cc @@ -1092,7 +1092,12 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() { "Type-stripping for TypeScript files.", &EnvironmentOptions::strip_types, kAllowedInEnvvar, - true); +#if HAVE_AMARO + true +#else + false +#endif // HAVE_AMARO +); AddAlias("--experimental-strip-types", "--strip-types"); AddOption("--experimental-transform-types", "enable transformation of TypeScript-only" From 2d43230c4e6fc5546ff8fc356e347ed82e9149af Mon Sep 17 00:00:00 2001 From: y-okt Date: Sun, 23 Nov 2025 22:38:05 +0900 Subject: [PATCH 3/9] test: move amaro checks after common import Move the amaro availability check immediately after importing common module in test files, as requested in PR feedback. Changes: - Place amaro check after common import but before other imports - Update test-node-output-sourcemaps.mjs to dynamically skip .ts tests based on file extension - Add individual skip conditions for TypeScript-specific tests - Fix linting errors (missing semicolon, line length issues) Refs: https://github.com/nodejs/node/pull/60815 --- src/node_options.cc | 7 +- test/es-module/test-esm-detect-ambiguous.mjs | 53 ++++++------ .../test-esm-import-meta-main-eval.mjs | 75 +++++++++-------- ...tax-errors-not-recognized-as-tla-error.mjs | 55 ++++++------- .../test-compile-cache-typescript-commonjs.js | 7 +- .../test-compile-cache-typescript-esm.js | 7 +- ...est-compile-cache-typescript-strip-miss.js | 7 +- ...mpile-cache-typescript-strip-sourcemaps.js | 7 +- ...test-compile-cache-typescript-transform.js | 7 +- test/parallel/test-config-file.js | 17 ++-- test/parallel/test-node-output-eval.mjs | 7 +- test/parallel/test-node-output-sourcemaps.mjs | 9 +- ...test-runner-coverage-default-exclusion.mjs | 8 +- .../test-runner-global-setup-teardown.mjs | 62 +++++++------- .../parallel/test-runner-run-global-hooks.mjs | 48 +++++------ test/parallel/test-util-getcallsites.js | 7 +- test/parallel/test-worker-cli-options.js | 5 +- test/parallel/test-worker-eval-typescript.js | 82 ++++++++++--------- ...-load-file-with-extension-other-than-js.js | 5 +- test/parallel/test-worker-syntax-error.js | 5 +- .../test-output-typescript-coverage.mjs | 5 +- 21 files changed, 230 insertions(+), 255 deletions(-) diff --git a/src/node_options.cc b/src/node_options.cc index 49e0563b5571a0..07a466e299dac4 100644 --- a/src/node_options.cc +++ b/src/node_options.cc @@ -1092,12 +1092,7 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() { "Type-stripping for TypeScript files.", &EnvironmentOptions::strip_types, kAllowedInEnvvar, -#if HAVE_AMARO - true -#else - false -#endif // HAVE_AMARO -); + HAVE_AMARO); AddAlias("--experimental-strip-types", "--strip-types"); AddOption("--experimental-transform-types", "enable transformation of TypeScript-only" diff --git a/test/es-module/test-esm-detect-ambiguous.mjs b/test/es-module/test-esm-detect-ambiguous.mjs index 16495425ad96a3..f80e67b0788804 100644 --- a/test/es-module/test-esm-detect-ambiguous.mjs +++ b/test/es-module/test-esm-detect-ambiguous.mjs @@ -1,14 +1,9 @@ -import * as common from '../common/index.mjs'; +import { spawnPromisified } from '../common/index.mjs'; import * as fixtures from '../common/fixtures.mjs'; import { spawn } from 'node:child_process'; import { describe, it } from 'node:test'; import assert from 'node:assert'; -if (!process.config.variables.node_use_amaro) { - common.skip('Requires Amaro'); -} -const { spawnPromisified } = common; - describe('Module syntax detection', { concurrency: !process.env.TEST_PARALLEL }, () => { describe('string input', { concurrency: !process.env.TEST_PARALLEL }, () => { it('permits ESM syntax in --eval input without requiring --input-type=module', async () => { @@ -268,17 +263,19 @@ describe('Module syntax detection', { concurrency: !process.env.TEST_PARALLEL }, assert.strictEqual(signal, null); }); - it('still throws on `await` in an ordinary sync function', async () => { - const { stdout, stderr, code, signal } = await spawnPromisified(process.execPath, [ - '--eval', - 'function fn() { await Promise.resolve(); } fn();', - ]); + it('still throws on `await` in an ordinary sync function', + { skip: !process.config.variables.node_use_amaro }, + async () => { + const { stdout, stderr, code, signal } = await spawnPromisified(process.execPath, [ + '--eval', + 'function fn() { await Promise.resolve(); } fn();', + ]); - assert.match(stderr, /SyntaxError: await is only valid in async function/); - assert.strictEqual(stdout, ''); - assert.strictEqual(code, 1); - assert.strictEqual(signal, null); - }); + assert.match(stderr, /SyntaxError: await is only valid in async function/); + assert.strictEqual(stdout, ''); + assert.strictEqual(code, 1); + assert.strictEqual(signal, null); + }); it('throws on undefined `require` when top-level `await` triggers ESM parsing', async () => { const { stdout, stderr, code, signal } = await spawnPromisified(process.execPath, [ @@ -319,17 +316,19 @@ describe('Module syntax detection', { concurrency: !process.env.TEST_PARALLEL }, assert.strictEqual(signal, null); }); - it('still throws on double `const` declaration not at the top level', async () => { - const { stdout, stderr, code, signal } = await spawnPromisified(process.execPath, [ - '--eval', - 'function fn() { const require = 1; const require = 2; } fn();', - ]); - - assert.match(stderr, /SyntaxError: Identifier 'require' has already been declared/); - assert.strictEqual(stdout, ''); - assert.strictEqual(code, 1); - assert.strictEqual(signal, null); - }); + it('still throws on double `const` declaration not at the top level', + { skip: !process.config.variables.node_use_amaro }, + async () => { + const { stdout, stderr, code, signal } = await spawnPromisified(process.execPath, [ + '--eval', + 'function fn() { const require = 1; const require = 2; } fn();', + ]); + + assert.match(stderr, /SyntaxError: Identifier 'require' has already been declared/); + assert.strictEqual(stdout, ''); + assert.strictEqual(code, 1); + assert.strictEqual(signal, null); + }); }); describe('warn about typeless packages for .js files with ESM syntax', { concurrency: true }, () => { diff --git a/test/es-module/test-esm-import-meta-main-eval.mjs b/test/es-module/test-esm-import-meta-main-eval.mjs index ecc25aa1b94443..ada52b06bae854 100644 --- a/test/es-module/test-esm-import-meta-main-eval.mjs +++ b/test/es-module/test-esm-import-meta-main-eval.mjs @@ -1,13 +1,8 @@ -import * as common from '../common/index.mjs'; +import { spawnPromisified } from '../common/index.mjs'; import * as fixtures from '../common/fixtures.js'; import assert from 'node:assert/strict'; import { describe, it } from 'node:test'; -if (!process.config.variables.node_use_amaro) { - common.skip('Requires Amaro'); -} -const { spawnPromisified } = common; - function wrapScriptInEvalWorker(script) { return ` import { Worker } from 'node:worker_threads'; @@ -38,7 +33,7 @@ const { isMain: importedModuleIsMain } = await import( assert.strictEqual(importedModuleIsMain, false, 'import.meta.main should evaluate false in imported module'); `; - it('should evaluate true in evaluated script', async () => { + it('should evaluate true in evaluated script', { skip: !process.config.variables.node_use_amaro }, async () => { const result = await spawnPromisified( process.execPath, ['--input-type=module', '--eval', importMetaMainScript], @@ -103,35 +98,39 @@ assert.strictEqual(importedModuleIsMain, false, 'import.meta.main should evaluat }); }); - it('should evaluate true in worker instantiated with module source by evaluated script', async () => { - const result = await spawnPromisified( - process.execPath, - ['--input-type=module-typescript', - '--disable-warning=ExperimentalWarning', - '--eval', - wrapScriptInEvalWorker(importMetaMainTSScript)], - ); - assert.deepStrictEqual(result, { - stderr: '', - stdout: '', - code: 0, - signal: null, - }); - }); - - it('should evaluate true in worker instantiated with `data:` URL by evaluated script', async () => { - const result = await spawnPromisified( - process.execPath, - ['--input-type=module', - '--input-type=module-typescript', - '--disable-warning=ExperimentalWarning', - '--eval', wrapScriptInUrlWorker(importMetaMainTSScript)], - ); - assert.deepStrictEqual(result, { - stderr: '', - stdout: '', - code: 0, - signal: null, - }); - }); + it('should evaluate true in worker instantiated with module source by evaluated script', + { skip: !process.config.variables.node_use_amaro }, + async () => { + const result = await spawnPromisified( + process.execPath, + ['--input-type=module-typescript', + '--disable-warning=ExperimentalWarning', + '--eval', + wrapScriptInEvalWorker(importMetaMainTSScript)], + ); + assert.deepStrictEqual(result, { + stderr: '', + stdout: '', + code: 0, + signal: null, + }); + }); + + it('should evaluate true in worker instantiated with `data:` URL by evaluated script', + { skip: !process.config.variables.node_use_amaro }, + async () => { + const result = await spawnPromisified( + process.execPath, + ['--input-type=module', + '--input-type=module-typescript', + '--disable-warning=ExperimentalWarning', + '--eval', wrapScriptInUrlWorker(importMetaMainTSScript)], + ); + assert.deepStrictEqual(result, { + stderr: '', + stdout: '', + code: 0, + signal: null, + }); + }); }); diff --git a/test/es-module/test-esm-tla-syntax-errors-not-recognized-as-tla-error.mjs b/test/es-module/test-esm-tla-syntax-errors-not-recognized-as-tla-error.mjs index 548a4a92bffa25..93465c4500a081 100644 --- a/test/es-module/test-esm-tla-syntax-errors-not-recognized-as-tla-error.mjs +++ b/test/es-module/test-esm-tla-syntax-errors-not-recognized-as-tla-error.mjs @@ -1,12 +1,7 @@ -import * as common from '../common/index.mjs'; +import { spawnPromisified } from '../common/index.mjs'; import { describe, it } from 'node:test'; import assert from 'node:assert'; -if (!process.config.variables.node_use_amaro) { - common.skip('Requires Amaro'); -} -const { spawnPromisified } = common; - describe('unusual top-level await syntax errors', () => { const expressions = [ // string @@ -54,30 +49,32 @@ describe('unusual top-level await syntax errors', () => { } }); - it('should throw the error for unrelated syntax errors', async () => { - const expression = 'foo bar'; - const wrapperExpressions = [ - [`function callSyntaxError() {}; callSyntaxError(${expression});`, /missing \) after argument list/], - [`if (${expression}) {}`, /Unexpected identifier/], - [`{ key: ${expression} }`, /Unexpected identifier/], - [`[${expression}]`, /Unexpected identifier/], - [`(${expression})`, /Unexpected identifier/], - [`const ${expression} = 1;`, /Missing initializer in const declaration/], - [`console.log('PI: ' Math.PI);`, /missing \) after argument list/], - [`callAwait(await "" "");`, /missing \) after argument list/], - ]; + it('should throw the error for unrelated syntax errors', + { skip: !process.config.variables.node_use_amaro }, + async () => { + const expression = 'foo bar'; + const wrapperExpressions = [ + [`function callSyntaxError() {}; callSyntaxError(${expression});`, /missing \) after argument list/], + [`if (${expression}) {}`, /Unexpected identifier/], + [`{ key: ${expression} }`, /Unexpected identifier/], + [`[${expression}]`, /Unexpected identifier/], + [`(${expression})`, /Unexpected identifier/], + [`const ${expression} = 1;`, /Missing initializer in const declaration/], + [`console.log('PI: ' Math.PI);`, /missing \) after argument list/], + [`callAwait(await "" "");`, /missing \) after argument list/], + ]; - for (const [wrapperExpression, error] of wrapperExpressions) { - const { code, signal, stdout, stderr } = await spawnPromisified(process.execPath, [ - '--eval', - ` + for (const [wrapperExpression, error] of wrapperExpressions) { + const { code, signal, stdout, stderr } = await spawnPromisified(process.execPath, [ + '--eval', + ` ${wrapperExpression} `, - ]); - assert.match(stderr, error); - assert.strictEqual(stdout, ''); - assert.strictEqual(code, 1); - assert.strictEqual(signal, null); - } - }); + ]); + assert.match(stderr, error); + assert.strictEqual(stdout, ''); + assert.strictEqual(code, 1); + assert.strictEqual(signal, null); + } + }); }); diff --git a/test/parallel/test-compile-cache-typescript-commonjs.js b/test/parallel/test-compile-cache-typescript-commonjs.js index 480791f834190c..60e86c3c0f9d5d 100644 --- a/test/parallel/test-compile-cache-typescript-commonjs.js +++ b/test/parallel/test-compile-cache-typescript-commonjs.js @@ -3,15 +3,14 @@ // This tests NODE_COMPILE_CACHE works for CommonJS with types. const common = require('../common'); +if (!process.config.variables.node_use_amaro) { + common.skip('Requires Amaro'); +} const { spawnSyncAndAssert } = require('../common/child_process'); const assert = require('assert'); const tmpdir = require('../common/tmpdir'); const fixtures = require('../common/fixtures'); -if (!process.config.variables.node_use_amaro) { - common.skip('Requires Amaro'); -} - // Check cache for .ts files that would be run as CommonJS. { tmpdir.refresh(); diff --git a/test/parallel/test-compile-cache-typescript-esm.js b/test/parallel/test-compile-cache-typescript-esm.js index eecb33348a2d8a..98473dbb2a5b64 100644 --- a/test/parallel/test-compile-cache-typescript-esm.js +++ b/test/parallel/test-compile-cache-typescript-esm.js @@ -3,15 +3,14 @@ // This tests NODE_COMPILE_CACHE works for ESM with types. const common = require('../common'); +if (!process.config.variables.node_use_amaro) { + common.skip('Requires Amaro'); +} const { spawnSyncAndAssert } = require('../common/child_process'); const assert = require('assert'); const tmpdir = require('../common/tmpdir'); const fixtures = require('../common/fixtures'); -if (!process.config.variables.node_use_amaro) { - common.skip('Requires Amaro'); -} - // Check cache for .ts files that would be run as ESM. { tmpdir.refresh(); diff --git a/test/parallel/test-compile-cache-typescript-strip-miss.js b/test/parallel/test-compile-cache-typescript-strip-miss.js index 5dd26bf6c042e0..e3accd6f534fec 100644 --- a/test/parallel/test-compile-cache-typescript-strip-miss.js +++ b/test/parallel/test-compile-cache-typescript-strip-miss.js @@ -4,15 +4,14 @@ // between strip-only TypeScript and transformed TypeScript. const common = require('../common'); +if (!process.config.variables.node_use_amaro) { + common.skip('Requires Amaro'); +} const { spawnSyncAndAssert } = require('../common/child_process'); const assert = require('assert'); const tmpdir = require('../common/tmpdir'); const fixtures = require('../common/fixtures'); -if (!process.config.variables.node_use_amaro) { - common.skip('Requires Amaro'); -} - tmpdir.refresh(); const dir = tmpdir.resolve('.compile_cache_dir'); const script = fixtures.path('typescript', 'ts', 'test-typescript.ts'); diff --git a/test/parallel/test-compile-cache-typescript-strip-sourcemaps.js b/test/parallel/test-compile-cache-typescript-strip-sourcemaps.js index d2a1047ff63d24..a6c95e432b7833 100644 --- a/test/parallel/test-compile-cache-typescript-strip-sourcemaps.js +++ b/test/parallel/test-compile-cache-typescript-strip-sourcemaps.js @@ -4,15 +4,14 @@ // --enable-source-maps as there's no difference in the code generated. const common = require('../common'); +if (!process.config.variables.node_use_amaro) { + common.skip('Requires Amaro'); +} const { spawnSyncAndAssert } = require('../common/child_process'); const assert = require('assert'); const tmpdir = require('../common/tmpdir'); const fixtures = require('../common/fixtures'); -if (!process.config.variables.node_use_amaro) { - common.skip('Requires Amaro'); -} - tmpdir.refresh(); const dir = tmpdir.resolve('.compile_cache_dir'); const script = fixtures.path('typescript', 'ts', 'test-typescript.ts'); diff --git a/test/parallel/test-compile-cache-typescript-transform.js b/test/parallel/test-compile-cache-typescript-transform.js index 4dd2a2c67fdb34..8432d189a501c0 100644 --- a/test/parallel/test-compile-cache-typescript-transform.js +++ b/test/parallel/test-compile-cache-typescript-transform.js @@ -3,15 +3,14 @@ // This tests NODE_COMPILE_CACHE works with --experimental-transform-types. const common = require('../common'); +if (!process.config.variables.node_use_amaro) { + common.skip('Requires Amaro'); +} const { spawnSyncAndAssert } = require('../common/child_process'); const assert = require('assert'); const tmpdir = require('../common/tmpdir'); const fixtures = require('../common/fixtures'); -if (!process.config.variables.node_use_amaro) { - common.skip('Requires Amaro'); -} - tmpdir.refresh(); const dir = tmpdir.resolve('.compile_cache_dir'); diff --git a/test/parallel/test-config-file.js b/test/parallel/test-config-file.js index 663b6b401b7894..a3e1d8defdb4e5 100644 --- a/test/parallel/test-config-file.js +++ b/test/parallel/test-config-file.js @@ -1,11 +1,11 @@ 'use strict'; -const common = require('../common'); const { isWindows, spawnPromisified, skipIfSQLiteMissing, -} = common; +} = require('../common'); +skipIfSQLiteMissing(); const fixtures = require('../common/fixtures'); const tmpdir = require('../common/tmpdir'); const assert = require('node:assert'); @@ -13,11 +13,6 @@ const { test, it, describe } = require('node:test'); const { chmodSync, writeFileSync, constants } = require('node:fs'); const { join } = require('node:path'); -if (!process.config.variables.node_use_amaro) { - common.skip('Requires Amaro'); -} -skipIfSQLiteMissing(); - test('should handle non existing json', async () => { const result = await spawnPromisified(process.execPath, [ '--experimental-config-file', @@ -54,7 +49,7 @@ test('should handle empty object json', async () => { assert.strictEqual(result.code, 0); }); -test('should parse boolean flag', async () => { +test('should parse boolean flag', { skip: !process.config.variables.node_use_amaro }, async () => { const result = await spawnPromisified(process.execPath, [ '--experimental-config-file', fixtures.path('rc/transform-types.json'), @@ -89,7 +84,7 @@ test('should throw an error when a flag is declared twice', async () => { }); -test('should override env-file', async () => { +test('should override env-file', { skip: !process.config.variables.node_use_amaro }, async () => { const result = await spawnPromisified(process.execPath, [ '--no-warnings', '--experimental-config-file', @@ -102,7 +97,7 @@ test('should override env-file', async () => { assert.strictEqual(result.code, 0); }); -test('should not override NODE_OPTIONS', async () => { +test('should not override NODE_OPTIONS', { skip: !process.config.variables.node_use_amaro }, async () => { const result = await spawnPromisified(process.execPath, [ '--no-warnings', '--experimental-config-file', @@ -119,7 +114,7 @@ test('should not override NODE_OPTIONS', async () => { assert.strictEqual(result.code, 1); }); -test('should not override CLI flags', async () => { +test('should not override CLI flags', { skip: !process.config.variables.node_use_amaro }, async () => { const result = await spawnPromisified(process.execPath, [ '--no-warnings', '--no-experimental-transform-types', diff --git a/test/parallel/test-node-output-eval.mjs b/test/parallel/test-node-output-eval.mjs index 59d94f2b276efb..56a880c8adfee1 100644 --- a/test/parallel/test-node-output-eval.mjs +++ b/test/parallel/test-node-output-eval.mjs @@ -1,13 +1,12 @@ import * as common from '../common/index.mjs'; +if (!process.config.variables.node_use_amaro) { + common.skip('Requires Amaro'); +} import * as fixtures from '../common/fixtures.mjs'; import * as snapshot from '../common/assertSnapshot.js'; import { basename } from 'node:path'; import { describe, it } from 'node:test'; -if (!process.config.variables.node_use_amaro) { - common.skip('Requires Amaro'); -} - describe('eval output', { concurrency: true }, () => { function normalize(str) { return str.replaceAll(snapshot.replaceWindowsPaths(process.cwd()), '') diff --git a/test/parallel/test-node-output-sourcemaps.mjs b/test/parallel/test-node-output-sourcemaps.mjs index 00a9d78cbe0bd3..e883ff2c57a791 100644 --- a/test/parallel/test-node-output-sourcemaps.mjs +++ b/test/parallel/test-node-output-sourcemaps.mjs @@ -1,12 +1,8 @@ -import * as common from '../common/index.mjs'; +import '../common/index.mjs'; import * as fixtures from '../common/fixtures.mjs'; import * as snapshot from '../common/assertSnapshot.js'; import { describe, it } from 'node:test'; -if (!process.config.variables.node_use_amaro) { - common.skip('Requires Amaro'); -} - describe('sourcemaps output', { concurrency: !process.env.TEST_PARALLEL }, () => { const defaultTransform = snapshot .transform( @@ -39,7 +35,8 @@ describe('sourcemaps output', { concurrency: !process.env.TEST_PARALLEL }, () => { name: 'source-map/output/source_map_throw_set_immediate.js' }, ]; for (const { name, transform } of tests) { - it(name, async () => { + const skip = name.endsWith('.ts') && !process.config.variables.node_use_amaro; + it(name, { skip }, async () => { await snapshot.spawnAndAssert(fixtures.path(name), transform ?? defaultTransform); }); } diff --git a/test/parallel/test-runner-coverage-default-exclusion.mjs b/test/parallel/test-runner-coverage-default-exclusion.mjs index 32cfc2e249ad98..dfe3fd156c4c0c 100644 --- a/test/parallel/test-runner-coverage-default-exclusion.mjs +++ b/test/parallel/test-runner-coverage-default-exclusion.mjs @@ -1,14 +1,10 @@ -import * as common from '../common/index.mjs'; +import '../common/index.mjs'; import { before, describe, it } from 'node:test'; import assert from 'node:assert'; import { spawnSync } from 'node:child_process'; import { cp } from 'node:fs/promises'; import tmpdir from '../common/tmpdir.js'; import fixtures from '../common/fixtures.js'; - -if (!process.config.variables.node_use_amaro) { - common.skip('Requires Amaro'); -} const skipIfNoInspector = { skip: !process.features.inspector ? 'inspector disabled' : false }; @@ -90,7 +86,7 @@ describe('test runner coverage default exclusion', skipIfNoInspector, () => { assert.strictEqual(result.status, 0); }); - it('should exclude ts test files', async () => { + it('should exclude ts test files', { skip: !process.config.variables.node_use_amaro }, async () => { const report = [ '# start of coverage report', '# --------------------------------------------------------------', diff --git a/test/parallel/test-runner-global-setup-teardown.mjs b/test/parallel/test-runner-global-setup-teardown.mjs index 0def3a96285594..a039c8274f5a9d 100644 --- a/test/parallel/test-runner-global-setup-teardown.mjs +++ b/test/parallel/test-runner-global-setup-teardown.mjs @@ -1,4 +1,4 @@ -import * as common from '../common/index.mjs'; +import '../common/index.mjs'; import * as fixtures from '../common/fixtures.mjs'; import { describe, it, beforeEach } from 'node:test'; import assert from 'node:assert'; @@ -8,10 +8,6 @@ import tmpdir from '../common/tmpdir.js'; import { once } from 'node:events'; import { join } from 'node:path'; -if (!process.config.variables.node_use_amaro) { - common.skip('Requires Amaro'); -} - const testFixtures = fixtures.path('test-runner'); async function runTest( @@ -260,35 +256,37 @@ async function runTest( 'Teardown should not run after setup fails'); }); - it('should run TypeScript globalSetup and globalTeardown functions', async () => { - const setupFlagPath = tmpdir.resolve('setup-executed-ts.tmp'); - const teardownFlagPath = tmpdir.resolve('teardown-executed-ts.tmp'); - - const { stdout, stderr } = await runTest({ - isolation, - globalSetupFile: 'basic-setup-teardown.ts', - env: { - SETUP_FLAG_PATH: setupFlagPath, - TEARDOWN_FLAG_PATH: teardownFlagPath - }, - additionalFlags: ['--no-warnings'], - runnerEnabled - }); - - assert.match(stdout, /pass 2/); - assert.match(stdout, /fail 0/); - assert.match(stdout, /Global setup executed/); - assert.match(stdout, /Global teardown executed/); - assert.strictEqual(stderr.length, 0); + it('should run TypeScript globalSetup and globalTeardown functions', + { skip: !process.config.variables.node_use_amaro }, + async () => { + const setupFlagPath = tmpdir.resolve('setup-executed-ts.tmp'); + const teardownFlagPath = tmpdir.resolve('teardown-executed-ts.tmp'); - // After all tests complete, the teardown should have run - assert.ok(fs.existsSync(teardownFlagPath), 'Teardown flag file should exist'); - const content = fs.readFileSync(teardownFlagPath, 'utf8'); - assert.strictEqual(content, 'Teardown was executed'); + const { stdout, stderr } = await runTest({ + isolation, + globalSetupFile: 'basic-setup-teardown.ts', + env: { + SETUP_FLAG_PATH: setupFlagPath, + TEARDOWN_FLAG_PATH: teardownFlagPath + }, + additionalFlags: ['--no-warnings'], + runnerEnabled + }); - // Setup flag should have been removed by teardown - assert.ok(!fs.existsSync(setupFlagPath), 'Setup flag file should have been removed'); - }); + assert.match(stdout, /pass 2/); + assert.match(stdout, /fail 0/); + assert.match(stdout, /Global setup executed/); + assert.match(stdout, /Global teardown executed/); + assert.strictEqual(stderr.length, 0); + + // After all tests complete, the teardown should have run + assert.ok(fs.existsSync(teardownFlagPath), 'Teardown flag file should exist'); + const content = fs.readFileSync(teardownFlagPath, 'utf8'); + assert.strictEqual(content, 'Teardown was executed'); + + // Setup flag should have been removed by teardown + assert.ok(!fs.existsSync(setupFlagPath), 'Setup flag file should have been removed'); + }); it('should run ESM globalSetup and globalTeardown functions', async () => { const setupFlagPath = tmpdir.resolve('setup-executed-esm.tmp'); diff --git a/test/parallel/test-runner-run-global-hooks.mjs b/test/parallel/test-runner-run-global-hooks.mjs index 0072a47a5919cc..23ede568e9e88a 100644 --- a/test/parallel/test-runner-run-global-hooks.mjs +++ b/test/parallel/test-runner-run-global-hooks.mjs @@ -166,29 +166,31 @@ describe('require(\'node:test\').run with global hooks', { concurrency: false }, assert.strictEqual(content, 'Setup part, Teardown part'); }); - it('should run TypeScript globalSetup and globalTeardown functions', async () => { - const setupFlagPath = tmpdir.resolve('setup-executed-ts.tmp'); - const teardownFlagPath = tmpdir.resolve('teardown-executed-ts.tmp'); - - const { results } = await runTestWithGlobalHooks({ - globalSetupFile: 'basic-setup-teardown.ts', - runnerEnv: { - SETUP_FLAG_PATH: setupFlagPath, - TEARDOWN_FLAG_PATH: teardownFlagPath - }, - isolation - }); - - assert.strictEqual(results.passed, 2); - assert.strictEqual(results.failed, 0); - // After all tests complete, the teardown should have run - assert.ok(fs.existsSync(teardownFlagPath), 'Teardown flag file should exist'); - const content = fs.readFileSync(teardownFlagPath, 'utf8'); - assert.strictEqual(content, 'Teardown was executed'); - - // Setup flag should have been removed by teardown - assert.ok(!fs.existsSync(setupFlagPath), 'Setup flag file should have been removed'); - }); + it('should run TypeScript globalSetup and globalTeardown functions', + { skip: !process.config.variables.node_use_amaro }, + async () => { + const setupFlagPath = tmpdir.resolve('setup-executed-ts.tmp'); + const teardownFlagPath = tmpdir.resolve('teardown-executed-ts.tmp'); + + const { results } = await runTestWithGlobalHooks({ + globalSetupFile: 'basic-setup-teardown.ts', + runnerEnv: { + SETUP_FLAG_PATH: setupFlagPath, + TEARDOWN_FLAG_PATH: teardownFlagPath + }, + isolation + }); + + assert.strictEqual(results.passed, 2); + assert.strictEqual(results.failed, 0); + // After all tests complete, the teardown should have run + assert.ok(fs.existsSync(teardownFlagPath), 'Teardown flag file should exist'); + const content = fs.readFileSync(teardownFlagPath, 'utf8'); + assert.strictEqual(content, 'Teardown was executed'); + + // Setup flag should have been removed by teardown + assert.ok(!fs.existsSync(setupFlagPath), 'Setup flag file should have been removed'); + }); it('should run ESM globalSetup and globalTeardown functions', async () => { const setupFlagPath = tmpdir.resolve('setup-executed-esm.tmp'); diff --git a/test/parallel/test-util-getcallsites.js b/test/parallel/test-util-getcallsites.js index 9654ac17a32552..2054b8d2b017cb 100644 --- a/test/parallel/test-util-getcallsites.js +++ b/test/parallel/test-util-getcallsites.js @@ -1,16 +1,15 @@ 'use strict'; const common = require('../common'); +if (!process.config.variables.node_use_amaro) { + common.skip('Requires Amaro'); +} const fixtures = require('../common/fixtures'); const file = fixtures.path('get-call-sites.js'); const { getCallSites } = require('node:util'); const { spawnSync } = require('node:child_process'); const assert = require('node:assert'); -if (!process.config.variables.node_use_amaro) { - common.skip('Requires Amaro'); -} - { const callSites = getCallSites(); assert.ok(callSites.length > 1); diff --git a/test/parallel/test-worker-cli-options.js b/test/parallel/test-worker-cli-options.js index 04b6db5a261ebd..fbd899356dfd0e 100644 --- a/test/parallel/test-worker-cli-options.js +++ b/test/parallel/test-worker-cli-options.js @@ -1,12 +1,11 @@ // Flags: --expose-internals --expose-gc 'use strict'; const common = require('../common'); -const { Worker } = require('worker_threads'); -const assert = require('assert'); - if (!process.config.variables.node_use_amaro) { common.skip('Requires Amaro'); } +const { Worker } = require('worker_threads'); +const assert = require('assert'); const CODE = ` // If the --expose-internals flag does not pass to worker diff --git a/test/parallel/test-worker-eval-typescript.js b/test/parallel/test-worker-eval-typescript.js index 186816f86540f5..47bd25a4c80f54 100644 --- a/test/parallel/test-worker-eval-typescript.js +++ b/test/parallel/test-worker-eval-typescript.js @@ -1,14 +1,10 @@ 'use strict'; -const common = require('../common'); +require('../common'); const assert = require('assert'); const { Worker } = require('worker_threads'); const { test } = require('node:test'); const { once } = require('events'); -if (!process.config.variables.node_use_amaro) { - common.skip('Requires Amaro'); -} - const esmHelloWorld = ` import worker from 'worker_threads'; const foo: string = 'Hello, World!'; @@ -23,25 +19,31 @@ const cjsHelloWorld = ` const disableTypeScriptWarningFlag = '--disable-warning=ExperimentalWarning'; -test('Worker eval module typescript without input-type', async () => { - const w = new Worker(esmHelloWorld, { eval: true, execArgv: [disableTypeScriptWarningFlag] }); - assert.deepStrictEqual(await once(w, 'message'), ['Hello, World!']); -}); +test('Worker eval module typescript without input-type', + { skip: !process.config.variables.node_use_amaro }, + async () => { + const w = new Worker(esmHelloWorld, { eval: true, execArgv: [disableTypeScriptWarningFlag] }); + assert.deepStrictEqual(await once(w, 'message'), ['Hello, World!']); + }); -test('Worker eval module typescript with --input-type=module-typescript', async () => { - const w = new Worker(esmHelloWorld, { eval: true, execArgv: ['--input-type=module-typescript', - disableTypeScriptWarningFlag] }); - assert.deepStrictEqual(await once(w, 'message'), ['Hello, World!']); -}); +test('Worker eval module typescript with --input-type=module-typescript', + { skip: !process.config.variables.node_use_amaro }, + async () => { + const w = new Worker(esmHelloWorld, { eval: true, execArgv: ['--input-type=module-typescript', + disableTypeScriptWarningFlag] }); + assert.deepStrictEqual(await once(w, 'message'), ['Hello, World!']); + }); -test('Worker eval module typescript with --input-type=commonjs-typescript', async () => { - const w = new Worker(esmHelloWorld, { eval: true, execArgv: ['--input-type=commonjs-typescript', - disableTypeScriptWarningFlag] }); +test('Worker eval module typescript with --input-type=commonjs-typescript', + { skip: !process.config.variables.node_use_amaro }, + async () => { + const w = new Worker(esmHelloWorld, { eval: true, execArgv: ['--input-type=commonjs-typescript', + disableTypeScriptWarningFlag] }); - const [err] = await once(w, 'error'); - assert.strictEqual(err.name, 'SyntaxError'); - assert.match(err.message, /Cannot use import statement outside a module/); -}); + const [err] = await once(w, 'error'); + assert.strictEqual(err.name, 'SyntaxError'); + assert.match(err.message, /Cannot use import statement outside a module/); + }); test('Worker eval module typescript with --input-type=module', async () => { const w = new Worker(esmHelloWorld, { eval: true, execArgv: ['--input-type=module', @@ -51,21 +53,27 @@ test('Worker eval module typescript with --input-type=module', async () => { assert.match(err.message, /Missing initializer in const declaration/); }); -test('Worker eval commonjs typescript without input-type', async () => { - const w = new Worker(cjsHelloWorld, { eval: true, execArgv: [disableTypeScriptWarningFlag] }); - assert.deepStrictEqual(await once(w, 'message'), ['Hello, World!']); -}); +test('Worker eval commonjs typescript without input-type', + { skip: !process.config.variables.node_use_amaro }, + async () => { + const w = new Worker(cjsHelloWorld, { eval: true, execArgv: [disableTypeScriptWarningFlag] }); + assert.deepStrictEqual(await once(w, 'message'), ['Hello, World!']); + }); -test('Worker eval commonjs typescript with --input-type=commonjs-typescript', async () => { - const w = new Worker(cjsHelloWorld, { eval: true, execArgv: ['--input-type=commonjs-typescript', - disableTypeScriptWarningFlag] }); - assert.deepStrictEqual(await once(w, 'message'), ['Hello, World!']); -}); +test('Worker eval commonjs typescript with --input-type=commonjs-typescript', + { skip: !process.config.variables.node_use_amaro }, + async () => { + const w = new Worker(cjsHelloWorld, { eval: true, execArgv: ['--input-type=commonjs-typescript', + disableTypeScriptWarningFlag] }); + assert.deepStrictEqual(await once(w, 'message'), ['Hello, World!']); + }); -test('Worker eval commonjs typescript with --input-type=module-typescript', async () => { - const w = new Worker(cjsHelloWorld, { eval: true, execArgv: ['--input-type=module-typescript', - disableTypeScriptWarningFlag] }); - const [err] = await once(w, 'error'); - assert.strictEqual(err.name, 'ReferenceError'); - assert.match(err.message, /require is not defined in ES module scope, you can use import instead/); -}); +test('Worker eval commonjs typescript with --input-type=module-typescript', + { skip: !process.config.variables.node_use_amaro }, + async () => { + const w = new Worker(cjsHelloWorld, { eval: true, execArgv: ['--input-type=module-typescript', + disableTypeScriptWarningFlag] }); + const [err] = await once(w, 'error'); + assert.strictEqual(err.name, 'ReferenceError'); + assert.match(err.message, /require is not defined in ES module scope, you can use import instead/); + }); diff --git a/test/parallel/test-worker-load-file-with-extension-other-than-js.js b/test/parallel/test-worker-load-file-with-extension-other-than-js.js index 05b22ff1188c94..4443d7a07cbbf1 100644 --- a/test/parallel/test-worker-load-file-with-extension-other-than-js.js +++ b/test/parallel/test-worker-load-file-with-extension-other-than-js.js @@ -1,11 +1,10 @@ 'use strict'; const common = require('../common'); -const fixtures = require('../common/fixtures'); -const { Worker } = require('worker_threads'); - if (!process.config.variables.node_use_amaro) { common.skip('Requires Amaro'); } +const fixtures = require('../common/fixtures'); +const { Worker } = require('worker_threads'); (common.mustCall(() => { new Worker(fixtures.path('worker-script.ts')); diff --git a/test/parallel/test-worker-syntax-error.js b/test/parallel/test-worker-syntax-error.js index 611fd2720c3eaa..9d620a2a49c0bc 100644 --- a/test/parallel/test-worker-syntax-error.js +++ b/test/parallel/test-worker-syntax-error.js @@ -1,11 +1,10 @@ 'use strict'; const common = require('../common'); -const assert = require('assert'); -const { Worker } = require('worker_threads'); - if (!process.config.variables.node_use_amaro) { common.skip('Requires Amaro'); } +const assert = require('assert'); +const { Worker } = require('worker_threads'); const w = new Worker('abc)', { eval: true }); w.on('message', common.mustNotCall()); diff --git a/test/test-runner/test-output-typescript-coverage.mjs b/test/test-runner/test-output-typescript-coverage.mjs index 577e88b2774a51..50892f230cc2e8 100644 --- a/test/test-runner/test-output-typescript-coverage.mjs +++ b/test/test-runner/test-output-typescript-coverage.mjs @@ -1,12 +1,11 @@ // Test that the output of test-runner/output/typescript-coverage.mts matches // test-runner/output/typescript-coverage.snapshot import * as common from '../common/index.mjs'; -import * as fixtures from '../common/fixtures.mjs'; -import { spawnAndAssert, defaultTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; - if (!process.config.variables.node_use_amaro) { common.skip('Requires Amaro'); } +import * as fixtures from '../common/fixtures.mjs'; +import { spawnAndAssert, defaultTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js'; if (!process.features.inspector) { common.skip('inspector support required'); From b192c6b93332563ab5b86494e9e52f509ac8ba8b Mon Sep 17 00:00:00 2001 From: y-okt Date: Sun, 23 Nov 2025 23:22:55 +0900 Subject: [PATCH 4/9] test: add workaround for the node-options-doc test to make the pipeline pass fixed the test failure due to its changeable default value. Fixes: https://github.com/nodejs/node/issues/60640 --- test/es-module/test-esm-import-meta-main-eval.mjs | 4 ++-- test/parallel/test-cli-node-options-docs.js | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/test/es-module/test-esm-import-meta-main-eval.mjs b/test/es-module/test-esm-import-meta-main-eval.mjs index ada52b06bae854..336b06ff065805 100644 --- a/test/es-module/test-esm-import-meta-main-eval.mjs +++ b/test/es-module/test-esm-import-meta-main-eval.mjs @@ -33,7 +33,7 @@ const { isMain: importedModuleIsMain } = await import( assert.strictEqual(importedModuleIsMain, false, 'import.meta.main should evaluate false in imported module'); `; - it('should evaluate true in evaluated script', { skip: !process.config.variables.node_use_amaro }, async () => { + it('should evaluate true in evaluated script', async () => { const result = await spawnPromisified( process.execPath, ['--input-type=module', '--eval', importMetaMainScript], @@ -85,7 +85,7 @@ const { isMain: importedModuleIsMain } = await import( assert.strictEqual(importedModuleIsMain, false, 'import.meta.main should evaluate false in imported module'); `; - it('should evaluate true in evaluated script', async () => { + it('should evaluate true in evaluated script', { skip: !process.config.variables.node_use_amaro }, async () => { const result = await spawnPromisified( process.execPath, ['--input-type=module-typescript', '--disable-warning=ExperimentalWarning', '--eval', importMetaMainTSScript], diff --git a/test/parallel/test-cli-node-options-docs.js b/test/parallel/test-cli-node-options-docs.js index f3034ef64bc5a9..1be5ede13ce21b 100644 --- a/test/parallel/test-cli-node-options-docs.js +++ b/test/parallel/test-cli-node-options-docs.js @@ -63,6 +63,11 @@ for (const [, envVar, config] of nodeOptionsCC.matchAll(addOptionRE)) { hasTrueAsDefaultValue = true; } + // Exception for HAVE_AMARO conditional default (defaults to true when Amaro is available) + if (config.includes('HAVE_AMARO')) { + hasTrueAsDefaultValue = true; + } + if ( envVar.startsWith('[') || deprecated.includes(envVar) || From 339fc203063590d7d307f4b6e7e0c838542f14b1 Mon Sep 17 00:00:00 2001 From: y-okt Date: Tue, 25 Nov 2025 14:36:42 +0900 Subject: [PATCH 5/9] src: make the default value of strip_types AMARO the default value of strip_types is controlled by node_options.h and we need to change the default value there Fixes: https://github.com/nodejs/node/pull/60815 --- src/node_options.h | 2 +- test/es-module/test-esm-detect-ambiguous.mjs | 6 ++++-- test/es-module/test-esm-import-meta-main-eval.mjs | 8 +++++--- test/es-module/test-esm-loader-entry-url.mjs | 4 +++- ...a-syntax-errors-not-recognized-as-tla-error.mjs | 4 +++- test/parallel/test-cli-node-options-docs.js | 2 +- test/parallel/test-config-file.js | 10 ++++++---- .../test-runner-coverage-default-exclusion.mjs | 4 +++- .../parallel/test-runner-global-setup-teardown.mjs | 4 +++- test/parallel/test-runner-run-global-hooks.mjs | 2 +- test/parallel/test-worker-eval-typescript.js | 14 ++++++++------ 11 files changed, 38 insertions(+), 22 deletions(-) diff --git a/src/node_options.h b/src/node_options.h index dd782b460aef79..2d30c115dcb27e 100644 --- a/src/node_options.h +++ b/src/node_options.h @@ -259,7 +259,7 @@ class EnvironmentOptions : public Options { std::vector preload_esm_modules; - bool strip_types = true; + bool strip_types = HAVE_AMARO; bool experimental_transform_types = false; std::vector user_argv; diff --git a/test/es-module/test-esm-detect-ambiguous.mjs b/test/es-module/test-esm-detect-ambiguous.mjs index f80e67b0788804..4bd94a9a0ea846 100644 --- a/test/es-module/test-esm-detect-ambiguous.mjs +++ b/test/es-module/test-esm-detect-ambiguous.mjs @@ -4,6 +4,8 @@ import { spawn } from 'node:child_process'; import { describe, it } from 'node:test'; import assert from 'node:assert'; +const onlyWithAmaro = { skip: !process.config.variables.node_use_amaro }; + describe('Module syntax detection', { concurrency: !process.env.TEST_PARALLEL }, () => { describe('string input', { concurrency: !process.env.TEST_PARALLEL }, () => { it('permits ESM syntax in --eval input without requiring --input-type=module', async () => { @@ -264,7 +266,7 @@ describe('Module syntax detection', { concurrency: !process.env.TEST_PARALLEL }, }); it('still throws on `await` in an ordinary sync function', - { skip: !process.config.variables.node_use_amaro }, + onlyWithAmaro, async () => { const { stdout, stderr, code, signal } = await spawnPromisified(process.execPath, [ '--eval', @@ -317,7 +319,7 @@ describe('Module syntax detection', { concurrency: !process.env.TEST_PARALLEL }, }); it('still throws on double `const` declaration not at the top level', - { skip: !process.config.variables.node_use_amaro }, + onlyWithAmaro, async () => { const { stdout, stderr, code, signal } = await spawnPromisified(process.execPath, [ '--eval', diff --git a/test/es-module/test-esm-import-meta-main-eval.mjs b/test/es-module/test-esm-import-meta-main-eval.mjs index 336b06ff065805..c72a80ae536325 100644 --- a/test/es-module/test-esm-import-meta-main-eval.mjs +++ b/test/es-module/test-esm-import-meta-main-eval.mjs @@ -21,6 +21,8 @@ function wrapScriptInUrlWorker(script) { `; } +const onlyWithAmaro = { skip: !process.config.variables.node_use_amaro }; + describe('import.meta.main in evaluated scripts', () => { const importMetaMainScript = ` import assert from 'node:assert/strict'; @@ -85,7 +87,7 @@ const { isMain: importedModuleIsMain } = await import( assert.strictEqual(importedModuleIsMain, false, 'import.meta.main should evaluate false in imported module'); `; - it('should evaluate true in evaluated script', { skip: !process.config.variables.node_use_amaro }, async () => { + it('should evaluate true in evaluated script', onlyWithAmaro, async () => { const result = await spawnPromisified( process.execPath, ['--input-type=module-typescript', '--disable-warning=ExperimentalWarning', '--eval', importMetaMainTSScript], @@ -99,7 +101,7 @@ assert.strictEqual(importedModuleIsMain, false, 'import.meta.main should evaluat }); it('should evaluate true in worker instantiated with module source by evaluated script', - { skip: !process.config.variables.node_use_amaro }, + onlyWithAmaro, async () => { const result = await spawnPromisified( process.execPath, @@ -117,7 +119,7 @@ assert.strictEqual(importedModuleIsMain, false, 'import.meta.main should evaluat }); it('should evaluate true in worker instantiated with `data:` URL by evaluated script', - { skip: !process.config.variables.node_use_amaro }, + onlyWithAmaro, async () => { const result = await spawnPromisified( process.execPath, diff --git a/test/es-module/test-esm-loader-entry-url.mjs b/test/es-module/test-esm-loader-entry-url.mjs index f6be7bcf7eebea..ae9396567faefb 100644 --- a/test/es-module/test-esm-loader-entry-url.mjs +++ b/test/es-module/test-esm-loader-entry-url.mjs @@ -23,6 +23,8 @@ async function assertSpawnedProcess(args, options = {}, expected = {}) { // Common expectation for experimental feature warning in stderr const experimentalFeatureWarning = { stderr: /--entry-url is an experimental feature/ }; +const onlyWithAmaro = { skip: !process.config.variables.node_use_amaro }; + describe('--entry-url', { concurrency: true }, () => { it('should reject loading a path that contains %', async () => { await assertSpawnedProcess( @@ -76,7 +78,7 @@ describe('--entry-url', { concurrency: true }, () => { ); }); - it('should support loading TypeScript URLs', { skip: !process.config.variables.node_use_amaro }, async () => { + it('should support loading TypeScript URLs', onlyWithAmaro, async () => { const typescriptUrls = [ 'typescript/cts/test-require-ts-file.cts', 'typescript/mts/test-import-ts-file.mts', diff --git a/test/es-module/test-esm-tla-syntax-errors-not-recognized-as-tla-error.mjs b/test/es-module/test-esm-tla-syntax-errors-not-recognized-as-tla-error.mjs index 93465c4500a081..e74e6cebf6aec4 100644 --- a/test/es-module/test-esm-tla-syntax-errors-not-recognized-as-tla-error.mjs +++ b/test/es-module/test-esm-tla-syntax-errors-not-recognized-as-tla-error.mjs @@ -2,6 +2,8 @@ import { spawnPromisified } from '../common/index.mjs'; import { describe, it } from 'node:test'; import assert from 'node:assert'; +const onlyWithAmaro = { skip: !process.config.variables.node_use_amaro }; + describe('unusual top-level await syntax errors', () => { const expressions = [ // string @@ -50,7 +52,7 @@ describe('unusual top-level await syntax errors', () => { }); it('should throw the error for unrelated syntax errors', - { skip: !process.config.variables.node_use_amaro }, + onlyWithAmaro, async () => { const expression = 'foo bar'; const wrapperExpressions = [ diff --git a/test/parallel/test-cli-node-options-docs.js b/test/parallel/test-cli-node-options-docs.js index 1be5ede13ce21b..207d453de0f402 100644 --- a/test/parallel/test-cli-node-options-docs.js +++ b/test/parallel/test-cli-node-options-docs.js @@ -64,7 +64,7 @@ for (const [, envVar, config] of nodeOptionsCC.matchAll(addOptionRE)) { } // Exception for HAVE_AMARO conditional default (defaults to true when Amaro is available) - if (config.includes('HAVE_AMARO')) { + if (process.config.variables.node_use_amaro) { hasTrueAsDefaultValue = true; } diff --git a/test/parallel/test-config-file.js b/test/parallel/test-config-file.js index a3e1d8defdb4e5..550d3a72a228df 100644 --- a/test/parallel/test-config-file.js +++ b/test/parallel/test-config-file.js @@ -13,6 +13,8 @@ const { test, it, describe } = require('node:test'); const { chmodSync, writeFileSync, constants } = require('node:fs'); const { join } = require('node:path'); +const onlyWithAmaro = { skip: !process.config.variables.node_use_amaro }; + test('should handle non existing json', async () => { const result = await spawnPromisified(process.execPath, [ '--experimental-config-file', @@ -49,7 +51,7 @@ test('should handle empty object json', async () => { assert.strictEqual(result.code, 0); }); -test('should parse boolean flag', { skip: !process.config.variables.node_use_amaro }, async () => { +test('should parse boolean flag', onlyWithAmaro, async () => { const result = await spawnPromisified(process.execPath, [ '--experimental-config-file', fixtures.path('rc/transform-types.json'), @@ -84,7 +86,7 @@ test('should throw an error when a flag is declared twice', async () => { }); -test('should override env-file', { skip: !process.config.variables.node_use_amaro }, async () => { +test('should override env-file', onlyWithAmaro, async () => { const result = await spawnPromisified(process.execPath, [ '--no-warnings', '--experimental-config-file', @@ -97,7 +99,7 @@ test('should override env-file', { skip: !process.config.variables.node_use_amar assert.strictEqual(result.code, 0); }); -test('should not override NODE_OPTIONS', { skip: !process.config.variables.node_use_amaro }, async () => { +test('should not override NODE_OPTIONS', onlyWithAmaro, async () => { const result = await spawnPromisified(process.execPath, [ '--no-warnings', '--experimental-config-file', @@ -114,7 +116,7 @@ test('should not override NODE_OPTIONS', { skip: !process.config.variables.node_ assert.strictEqual(result.code, 1); }); -test('should not override CLI flags', { skip: !process.config.variables.node_use_amaro }, async () => { +test('should not override CLI flags', onlyWithAmaro, async () => { const result = await spawnPromisified(process.execPath, [ '--no-warnings', '--no-experimental-transform-types', diff --git a/test/parallel/test-runner-coverage-default-exclusion.mjs b/test/parallel/test-runner-coverage-default-exclusion.mjs index dfe3fd156c4c0c..b15e9a0ec3533f 100644 --- a/test/parallel/test-runner-coverage-default-exclusion.mjs +++ b/test/parallel/test-runner-coverage-default-exclusion.mjs @@ -16,6 +16,8 @@ async function setupFixtures() { await cp(fixtureDir, tmpdir.path, { recursive: true }); } +const onlyWithAmaro = { skip: !process.config.variables.node_use_amaro }; + describe('test runner coverage default exclusion', skipIfNoInspector, () => { before(async () => { await setupFixtures(); @@ -86,7 +88,7 @@ describe('test runner coverage default exclusion', skipIfNoInspector, () => { assert.strictEqual(result.status, 0); }); - it('should exclude ts test files', { skip: !process.config.variables.node_use_amaro }, async () => { + it('should exclude ts test files', onlyWithAmaro, async () => { const report = [ '# start of coverage report', '# --------------------------------------------------------------', diff --git a/test/parallel/test-runner-global-setup-teardown.mjs b/test/parallel/test-runner-global-setup-teardown.mjs index a039c8274f5a9d..6effe8a29ae2be 100644 --- a/test/parallel/test-runner-global-setup-teardown.mjs +++ b/test/parallel/test-runner-global-setup-teardown.mjs @@ -10,6 +10,8 @@ import { join } from 'node:path'; const testFixtures = fixtures.path('test-runner'); +const onlyWithAmaro = { skip: !process.config.variables.node_use_amaro }; + async function runTest( { isolation, @@ -257,7 +259,7 @@ async function runTest( }); it('should run TypeScript globalSetup and globalTeardown functions', - { skip: !process.config.variables.node_use_amaro }, + onlyWithAmaro, async () => { const setupFlagPath = tmpdir.resolve('setup-executed-ts.tmp'); const teardownFlagPath = tmpdir.resolve('teardown-executed-ts.tmp'); diff --git a/test/parallel/test-runner-run-global-hooks.mjs b/test/parallel/test-runner-run-global-hooks.mjs index 23ede568e9e88a..5d8fc65e77a12c 100644 --- a/test/parallel/test-runner-run-global-hooks.mjs +++ b/test/parallel/test-runner-run-global-hooks.mjs @@ -167,7 +167,7 @@ describe('require(\'node:test\').run with global hooks', { concurrency: false }, }); it('should run TypeScript globalSetup and globalTeardown functions', - { skip: !process.config.variables.node_use_amaro }, + onlyWithAmaro, async () => { const setupFlagPath = tmpdir.resolve('setup-executed-ts.tmp'); const teardownFlagPath = tmpdir.resolve('teardown-executed-ts.tmp'); diff --git a/test/parallel/test-worker-eval-typescript.js b/test/parallel/test-worker-eval-typescript.js index 47bd25a4c80f54..5fb56a2c0dfba5 100644 --- a/test/parallel/test-worker-eval-typescript.js +++ b/test/parallel/test-worker-eval-typescript.js @@ -19,15 +19,17 @@ const cjsHelloWorld = ` const disableTypeScriptWarningFlag = '--disable-warning=ExperimentalWarning'; +const onlyWithAmaro = { skip: !process.config.variables.node_use_amaro }; + test('Worker eval module typescript without input-type', - { skip: !process.config.variables.node_use_amaro }, + onlyWithAmaro, async () => { const w = new Worker(esmHelloWorld, { eval: true, execArgv: [disableTypeScriptWarningFlag] }); assert.deepStrictEqual(await once(w, 'message'), ['Hello, World!']); }); test('Worker eval module typescript with --input-type=module-typescript', - { skip: !process.config.variables.node_use_amaro }, + onlyWithAmaro, async () => { const w = new Worker(esmHelloWorld, { eval: true, execArgv: ['--input-type=module-typescript', disableTypeScriptWarningFlag] }); @@ -35,7 +37,7 @@ test('Worker eval module typescript with --input-type=module-typescript', }); test('Worker eval module typescript with --input-type=commonjs-typescript', - { skip: !process.config.variables.node_use_amaro }, + onlyWithAmaro, async () => { const w = new Worker(esmHelloWorld, { eval: true, execArgv: ['--input-type=commonjs-typescript', disableTypeScriptWarningFlag] }); @@ -54,14 +56,14 @@ test('Worker eval module typescript with --input-type=module', async () => { }); test('Worker eval commonjs typescript without input-type', - { skip: !process.config.variables.node_use_amaro }, + onlyWithAmaro, async () => { const w = new Worker(cjsHelloWorld, { eval: true, execArgv: [disableTypeScriptWarningFlag] }); assert.deepStrictEqual(await once(w, 'message'), ['Hello, World!']); }); test('Worker eval commonjs typescript with --input-type=commonjs-typescript', - { skip: !process.config.variables.node_use_amaro }, + onlyWithAmaro, async () => { const w = new Worker(cjsHelloWorld, { eval: true, execArgv: ['--input-type=commonjs-typescript', disableTypeScriptWarningFlag] }); @@ -69,7 +71,7 @@ test('Worker eval commonjs typescript with --input-type=commonjs-typescript', }); test('Worker eval commonjs typescript with --input-type=module-typescript', - { skip: !process.config.variables.node_use_amaro }, + onlyWithAmaro, async () => { const w = new Worker(cjsHelloWorld, { eval: true, execArgv: ['--input-type=module-typescript', disableTypeScriptWarningFlag] }); From a290baffb14d321aa41a5f20d80629088720e189 Mon Sep 17 00:00:00 2001 From: y-okt Date: Wed, 26 Nov 2025 00:16:15 +0900 Subject: [PATCH 6/9] test: include passing tests from skip list some tests are skipped although they aren't relevant to amaro. Fixes: https://github.com/nodejs/node/pull/60815 --- test/es-module/test-esm-detect-ambiguous.mjs | 10 ++-------- test/es-module/test-esm-resolve-type.mjs | 4 ++++ ...m-tla-syntax-errors-not-recognized-as-tla-error.mjs | 6 +----- test/parallel/test-cli-node-options-docs.js | 2 +- .../parallel/test-compile-cache-typescript-commonjs.js | 2 +- test/parallel/test-compile-cache-typescript-esm.js | 2 +- test/parallel/test-config-file.js | 1 - .../test-runner-coverage-default-exclusion.mjs | 4 +--- test/parallel/test-worker-cli-options.js | 3 --- ...st-worker-load-file-with-extension-other-than-js.js | 3 --- test/parallel/test-worker-syntax-error.js | 3 --- 11 files changed, 11 insertions(+), 29 deletions(-) diff --git a/test/es-module/test-esm-detect-ambiguous.mjs b/test/es-module/test-esm-detect-ambiguous.mjs index 4bd94a9a0ea846..e60d67a145fd8f 100644 --- a/test/es-module/test-esm-detect-ambiguous.mjs +++ b/test/es-module/test-esm-detect-ambiguous.mjs @@ -4,8 +4,6 @@ import { spawn } from 'node:child_process'; import { describe, it } from 'node:test'; import assert from 'node:assert'; -const onlyWithAmaro = { skip: !process.config.variables.node_use_amaro }; - describe('Module syntax detection', { concurrency: !process.env.TEST_PARALLEL }, () => { describe('string input', { concurrency: !process.env.TEST_PARALLEL }, () => { it('permits ESM syntax in --eval input without requiring --input-type=module', async () => { @@ -265,9 +263,7 @@ describe('Module syntax detection', { concurrency: !process.env.TEST_PARALLEL }, assert.strictEqual(signal, null); }); - it('still throws on `await` in an ordinary sync function', - onlyWithAmaro, - async () => { + it('still throws on `await` in an ordinary sync function', async () => { const { stdout, stderr, code, signal } = await spawnPromisified(process.execPath, [ '--eval', 'function fn() { await Promise.resolve(); } fn();', @@ -318,9 +314,7 @@ describe('Module syntax detection', { concurrency: !process.env.TEST_PARALLEL }, assert.strictEqual(signal, null); }); - it('still throws on double `const` declaration not at the top level', - onlyWithAmaro, - async () => { + it('still throws on double `const` declaration not at the top level', async () => { const { stdout, stderr, code, signal } = await spawnPromisified(process.execPath, [ '--eval', 'function fn() { const require = 1; const require = 2; } fn();', diff --git a/test/es-module/test-esm-resolve-type.mjs b/test/es-module/test-esm-resolve-type.mjs index 9d97413379ad3c..fbd75d98a8da8e 100644 --- a/test/es-module/test-esm-resolve-type.mjs +++ b/test/es-module/test-esm-resolve-type.mjs @@ -198,6 +198,10 @@ try { subdirPackageType, expectedResolvedFormat, mainSuffix = '' ] = testVariant; + const skip = mainImportScript.endsWith('.ts') && !process.config.variables.node_use_amaro; + if (skip) { + return; + } const mDir = rel(`node_modules/${moduleName}`); const subDir = rel(`node_modules/${moduleName}/subdir`); diff --git a/test/es-module/test-esm-tla-syntax-errors-not-recognized-as-tla-error.mjs b/test/es-module/test-esm-tla-syntax-errors-not-recognized-as-tla-error.mjs index e74e6cebf6aec4..acdf0ec7ca4da8 100644 --- a/test/es-module/test-esm-tla-syntax-errors-not-recognized-as-tla-error.mjs +++ b/test/es-module/test-esm-tla-syntax-errors-not-recognized-as-tla-error.mjs @@ -2,8 +2,6 @@ import { spawnPromisified } from '../common/index.mjs'; import { describe, it } from 'node:test'; import assert from 'node:assert'; -const onlyWithAmaro = { skip: !process.config.variables.node_use_amaro }; - describe('unusual top-level await syntax errors', () => { const expressions = [ // string @@ -51,9 +49,7 @@ describe('unusual top-level await syntax errors', () => { } }); - it('should throw the error for unrelated syntax errors', - onlyWithAmaro, - async () => { + it('should throw the error for unrelated syntax errors', async () => { const expression = 'foo bar'; const wrapperExpressions = [ [`function callSyntaxError() {}; callSyntaxError(${expression});`, /missing \) after argument list/], diff --git a/test/parallel/test-cli-node-options-docs.js b/test/parallel/test-cli-node-options-docs.js index 207d453de0f402..1be5ede13ce21b 100644 --- a/test/parallel/test-cli-node-options-docs.js +++ b/test/parallel/test-cli-node-options-docs.js @@ -64,7 +64,7 @@ for (const [, envVar, config] of nodeOptionsCC.matchAll(addOptionRE)) { } // Exception for HAVE_AMARO conditional default (defaults to true when Amaro is available) - if (process.config.variables.node_use_amaro) { + if (config.includes('HAVE_AMARO')) { hasTrueAsDefaultValue = true; } diff --git a/test/parallel/test-compile-cache-typescript-commonjs.js b/test/parallel/test-compile-cache-typescript-commonjs.js index 60e86c3c0f9d5d..704eb82a3273aa 100644 --- a/test/parallel/test-compile-cache-typescript-commonjs.js +++ b/test/parallel/test-compile-cache-typescript-commonjs.js @@ -12,7 +12,7 @@ const tmpdir = require('../common/tmpdir'); const fixtures = require('../common/fixtures'); // Check cache for .ts files that would be run as CommonJS. -{ +if (process.config.variables.node_use_amaro) { tmpdir.refresh(); const dir = tmpdir.resolve('.compile_cache_dir'); const script = fixtures.path('typescript', 'ts', 'test-commonjs-parsing.ts'); diff --git a/test/parallel/test-compile-cache-typescript-esm.js b/test/parallel/test-compile-cache-typescript-esm.js index 98473dbb2a5b64..a36dc6ca45cc01 100644 --- a/test/parallel/test-compile-cache-typescript-esm.js +++ b/test/parallel/test-compile-cache-typescript-esm.js @@ -12,7 +12,7 @@ const tmpdir = require('../common/tmpdir'); const fixtures = require('../common/fixtures'); // Check cache for .ts files that would be run as ESM. -{ +if (process.config.variables.node_use_amaro) { tmpdir.refresh(); const dir = tmpdir.resolve('.compile_cache_dir'); const script = fixtures.path('typescript', 'ts', 'test-module-typescript.ts'); diff --git a/test/parallel/test-config-file.js b/test/parallel/test-config-file.js index 550d3a72a228df..9ffc2a90bee9e1 100644 --- a/test/parallel/test-config-file.js +++ b/test/parallel/test-config-file.js @@ -85,7 +85,6 @@ test('should throw an error when a flag is declared twice', async () => { assert.strictEqual(result.code, 9); }); - test('should override env-file', onlyWithAmaro, async () => { const result = await spawnPromisified(process.execPath, [ '--no-warnings', diff --git a/test/parallel/test-runner-coverage-default-exclusion.mjs b/test/parallel/test-runner-coverage-default-exclusion.mjs index b15e9a0ec3533f..44e5f7600d3270 100644 --- a/test/parallel/test-runner-coverage-default-exclusion.mjs +++ b/test/parallel/test-runner-coverage-default-exclusion.mjs @@ -16,8 +16,6 @@ async function setupFixtures() { await cp(fixtureDir, tmpdir.path, { recursive: true }); } -const onlyWithAmaro = { skip: !process.config.variables.node_use_amaro }; - describe('test runner coverage default exclusion', skipIfNoInspector, () => { before(async () => { await setupFixtures(); @@ -88,7 +86,7 @@ describe('test runner coverage default exclusion', skipIfNoInspector, () => { assert.strictEqual(result.status, 0); }); - it('should exclude ts test files', onlyWithAmaro, async () => { + it('should exclude ts test files', async () => { const report = [ '# start of coverage report', '# --------------------------------------------------------------', diff --git a/test/parallel/test-worker-cli-options.js b/test/parallel/test-worker-cli-options.js index fbd899356dfd0e..3e6ab46db6ea74 100644 --- a/test/parallel/test-worker-cli-options.js +++ b/test/parallel/test-worker-cli-options.js @@ -1,9 +1,6 @@ // Flags: --expose-internals --expose-gc 'use strict'; const common = require('../common'); -if (!process.config.variables.node_use_amaro) { - common.skip('Requires Amaro'); -} const { Worker } = require('worker_threads'); const assert = require('assert'); diff --git a/test/parallel/test-worker-load-file-with-extension-other-than-js.js b/test/parallel/test-worker-load-file-with-extension-other-than-js.js index 4443d7a07cbbf1..7c2afce4fbe2b3 100644 --- a/test/parallel/test-worker-load-file-with-extension-other-than-js.js +++ b/test/parallel/test-worker-load-file-with-extension-other-than-js.js @@ -1,8 +1,5 @@ 'use strict'; const common = require('../common'); -if (!process.config.variables.node_use_amaro) { - common.skip('Requires Amaro'); -} const fixtures = require('../common/fixtures'); const { Worker } = require('worker_threads'); diff --git a/test/parallel/test-worker-syntax-error.js b/test/parallel/test-worker-syntax-error.js index 9d620a2a49c0bc..99ebf26a9fa714 100644 --- a/test/parallel/test-worker-syntax-error.js +++ b/test/parallel/test-worker-syntax-error.js @@ -1,8 +1,5 @@ 'use strict'; const common = require('../common'); -if (!process.config.variables.node_use_amaro) { - common.skip('Requires Amaro'); -} const assert = require('assert'); const { Worker } = require('worker_threads'); From 138865010b4cd32b81c8a67f08d1c8f504ea1685 Mon Sep 17 00:00:00 2001 From: y-okt Date: Wed, 26 Nov 2025 00:43:12 +0900 Subject: [PATCH 7/9] test: fix linting and remove unnecessary space changes to make the changes clear, remove unnecessary space changes Fixes: https://github.com/nodejs/node/pull/60815 --- test/es-module/test-esm-detect-ambiguous.mjs | 38 +++++----- .../test-esm-import-meta-main-eval.mjs | 66 ++++++++-------- ...tax-errors-not-recognized-as-tla-error.mjs | 48 ++++++------ .../test-compile-cache-typescript-esm.js | 5 +- .../test-runner-global-setup-teardown.mjs | 56 +++++++------- .../parallel/test-runner-run-global-hooks.mjs | 54 ++++++------- test/parallel/test-worker-eval-typescript.js | 76 ++++++++----------- ...-load-file-with-extension-other-than-js.js | 1 + 8 files changed, 160 insertions(+), 184 deletions(-) diff --git a/test/es-module/test-esm-detect-ambiguous.mjs b/test/es-module/test-esm-detect-ambiguous.mjs index e60d67a145fd8f..234e27a947a13f 100644 --- a/test/es-module/test-esm-detect-ambiguous.mjs +++ b/test/es-module/test-esm-detect-ambiguous.mjs @@ -264,16 +264,16 @@ describe('Module syntax detection', { concurrency: !process.env.TEST_PARALLEL }, }); it('still throws on `await` in an ordinary sync function', async () => { - const { stdout, stderr, code, signal } = await spawnPromisified(process.execPath, [ - '--eval', - 'function fn() { await Promise.resolve(); } fn();', - ]); + const { stdout, stderr, code, signal } = await spawnPromisified(process.execPath, [ + '--eval', + 'function fn() { await Promise.resolve(); } fn();', + ]); - assert.match(stderr, /SyntaxError: await is only valid in async function/); - assert.strictEqual(stdout, ''); - assert.strictEqual(code, 1); - assert.strictEqual(signal, null); - }); + assert.match(stderr, /SyntaxError: await is only valid in async function/); + assert.strictEqual(stdout, ''); + assert.strictEqual(code, 1); + assert.strictEqual(signal, null); + }); it('throws on undefined `require` when top-level `await` triggers ESM parsing', async () => { const { stdout, stderr, code, signal } = await spawnPromisified(process.execPath, [ @@ -315,16 +315,16 @@ describe('Module syntax detection', { concurrency: !process.env.TEST_PARALLEL }, }); it('still throws on double `const` declaration not at the top level', async () => { - const { stdout, stderr, code, signal } = await spawnPromisified(process.execPath, [ - '--eval', - 'function fn() { const require = 1; const require = 2; } fn();', - ]); - - assert.match(stderr, /SyntaxError: Identifier 'require' has already been declared/); - assert.strictEqual(stdout, ''); - assert.strictEqual(code, 1); - assert.strictEqual(signal, null); - }); + const { stdout, stderr, code, signal } = await spawnPromisified(process.execPath, [ + '--eval', + 'function fn() { const require = 1; const require = 2; } fn();', + ]); + + assert.match(stderr, /SyntaxError: Identifier 'require' has already been declared/); + assert.strictEqual(stdout, ''); + assert.strictEqual(code, 1); + assert.strictEqual(signal, null); + }); }); describe('warn about typeless packages for .js files with ESM syntax', { concurrency: true }, () => { diff --git a/test/es-module/test-esm-import-meta-main-eval.mjs b/test/es-module/test-esm-import-meta-main-eval.mjs index c72a80ae536325..978cd88fc56d33 100644 --- a/test/es-module/test-esm-import-meta-main-eval.mjs +++ b/test/es-module/test-esm-import-meta-main-eval.mjs @@ -100,39 +100,35 @@ assert.strictEqual(importedModuleIsMain, false, 'import.meta.main should evaluat }); }); - it('should evaluate true in worker instantiated with module source by evaluated script', - onlyWithAmaro, - async () => { - const result = await spawnPromisified( - process.execPath, - ['--input-type=module-typescript', - '--disable-warning=ExperimentalWarning', - '--eval', - wrapScriptInEvalWorker(importMetaMainTSScript)], - ); - assert.deepStrictEqual(result, { - stderr: '', - stdout: '', - code: 0, - signal: null, - }); - }); - - it('should evaluate true in worker instantiated with `data:` URL by evaluated script', - onlyWithAmaro, - async () => { - const result = await spawnPromisified( - process.execPath, - ['--input-type=module', - '--input-type=module-typescript', - '--disable-warning=ExperimentalWarning', - '--eval', wrapScriptInUrlWorker(importMetaMainTSScript)], - ); - assert.deepStrictEqual(result, { - stderr: '', - stdout: '', - code: 0, - signal: null, - }); - }); + it('should evaluate true in worker instantiated with module source by evaluated script', onlyWithAmaro, async () => { + const result = await spawnPromisified( + process.execPath, + ['--input-type=module-typescript', + '--disable-warning=ExperimentalWarning', + '--eval', + wrapScriptInEvalWorker(importMetaMainTSScript)], + ); + assert.deepStrictEqual(result, { + stderr: '', + stdout: '', + code: 0, + signal: null, + }); + }); + + it('should evaluate true in worker instantiated with `data:` URL by evaluated script', onlyWithAmaro, async () => { + const result = await spawnPromisified( + process.execPath, + ['--input-type=module', + '--input-type=module-typescript', + '--disable-warning=ExperimentalWarning', + '--eval', wrapScriptInUrlWorker(importMetaMainTSScript)], + ); + assert.deepStrictEqual(result, { + stderr: '', + stdout: '', + code: 0, + signal: null, + }); + }); }); diff --git a/test/es-module/test-esm-tla-syntax-errors-not-recognized-as-tla-error.mjs b/test/es-module/test-esm-tla-syntax-errors-not-recognized-as-tla-error.mjs index acdf0ec7ca4da8..d001c593fd0e3a 100644 --- a/test/es-module/test-esm-tla-syntax-errors-not-recognized-as-tla-error.mjs +++ b/test/es-module/test-esm-tla-syntax-errors-not-recognized-as-tla-error.mjs @@ -50,29 +50,29 @@ describe('unusual top-level await syntax errors', () => { }); it('should throw the error for unrelated syntax errors', async () => { - const expression = 'foo bar'; - const wrapperExpressions = [ - [`function callSyntaxError() {}; callSyntaxError(${expression});`, /missing \) after argument list/], - [`if (${expression}) {}`, /Unexpected identifier/], - [`{ key: ${expression} }`, /Unexpected identifier/], - [`[${expression}]`, /Unexpected identifier/], - [`(${expression})`, /Unexpected identifier/], - [`const ${expression} = 1;`, /Missing initializer in const declaration/], - [`console.log('PI: ' Math.PI);`, /missing \) after argument list/], - [`callAwait(await "" "");`, /missing \) after argument list/], - ]; + const expression = 'foo bar'; + const wrapperExpressions = [ + [`function callSyntaxError() {}; callSyntaxError(${expression});`, /missing \) after argument list/], + [`if (${expression}) {}`, /Unexpected identifier/], + [`{ key: ${expression} }`, /Unexpected identifier/], + [`[${expression}]`, /Unexpected identifier/], + [`(${expression})`, /Unexpected identifier/], + [`const ${expression} = 1;`, /Missing initializer in const declaration/], + [`console.log('PI: ' Math.PI);`, /missing \) after argument list/], + [`callAwait(await "" "");`, /missing \) after argument list/], + ]; - for (const [wrapperExpression, error] of wrapperExpressions) { - const { code, signal, stdout, stderr } = await spawnPromisified(process.execPath, [ - '--eval', - ` - ${wrapperExpression} - `, - ]); - assert.match(stderr, error); - assert.strictEqual(stdout, ''); - assert.strictEqual(code, 1); - assert.strictEqual(signal, null); - } - }); + for (const [wrapperExpression, error] of wrapperExpressions) { + const { code, signal, stdout, stderr } = await spawnPromisified(process.execPath, [ + '--eval', + ` + ${wrapperExpression} + `, + ]); + assert.match(stderr, error); + assert.strictEqual(stdout, ''); + assert.strictEqual(code, 1); + assert.strictEqual(signal, null); + } + }); }); diff --git a/test/parallel/test-compile-cache-typescript-esm.js b/test/parallel/test-compile-cache-typescript-esm.js index a36dc6ca45cc01..e4bd7ac36ae7b8 100644 --- a/test/parallel/test-compile-cache-typescript-esm.js +++ b/test/parallel/test-compile-cache-typescript-esm.js @@ -2,10 +2,7 @@ // This tests NODE_COMPILE_CACHE works for ESM with types. -const common = require('../common'); -if (!process.config.variables.node_use_amaro) { - common.skip('Requires Amaro'); -} +require('../common'); const { spawnSyncAndAssert } = require('../common/child_process'); const assert = require('assert'); const tmpdir = require('../common/tmpdir'); diff --git a/test/parallel/test-runner-global-setup-teardown.mjs b/test/parallel/test-runner-global-setup-teardown.mjs index 6effe8a29ae2be..56b5ca6b112171 100644 --- a/test/parallel/test-runner-global-setup-teardown.mjs +++ b/test/parallel/test-runner-global-setup-teardown.mjs @@ -258,37 +258,35 @@ async function runTest( 'Teardown should not run after setup fails'); }); - it('should run TypeScript globalSetup and globalTeardown functions', - onlyWithAmaro, - async () => { - const setupFlagPath = tmpdir.resolve('setup-executed-ts.tmp'); - const teardownFlagPath = tmpdir.resolve('teardown-executed-ts.tmp'); + it('should run TypeScript globalSetup and globalTeardown functions', onlyWithAmaro, async () => { + const setupFlagPath = tmpdir.resolve('setup-executed-ts.tmp'); + const teardownFlagPath = tmpdir.resolve('teardown-executed-ts.tmp'); - const { stdout, stderr } = await runTest({ - isolation, - globalSetupFile: 'basic-setup-teardown.ts', - env: { - SETUP_FLAG_PATH: setupFlagPath, - TEARDOWN_FLAG_PATH: teardownFlagPath - }, - additionalFlags: ['--no-warnings'], - runnerEnabled - }); + const { stdout, stderr } = await runTest({ + isolation, + globalSetupFile: 'basic-setup-teardown.ts', + env: { + SETUP_FLAG_PATH: setupFlagPath, + TEARDOWN_FLAG_PATH: teardownFlagPath + }, + additionalFlags: ['--no-warnings'], + runnerEnabled + }); - assert.match(stdout, /pass 2/); - assert.match(stdout, /fail 0/); - assert.match(stdout, /Global setup executed/); - assert.match(stdout, /Global teardown executed/); - assert.strictEqual(stderr.length, 0); - - // After all tests complete, the teardown should have run - assert.ok(fs.existsSync(teardownFlagPath), 'Teardown flag file should exist'); - const content = fs.readFileSync(teardownFlagPath, 'utf8'); - assert.strictEqual(content, 'Teardown was executed'); - - // Setup flag should have been removed by teardown - assert.ok(!fs.existsSync(setupFlagPath), 'Setup flag file should have been removed'); - }); + assert.match(stdout, /pass 2/); + assert.match(stdout, /fail 0/); + assert.match(stdout, /Global setup executed/); + assert.match(stdout, /Global teardown executed/); + assert.strictEqual(stderr.length, 0); + + // After all tests complete, the teardown should have run + assert.ok(fs.existsSync(teardownFlagPath), 'Teardown flag file should exist'); + const content = fs.readFileSync(teardownFlagPath, 'utf8'); + assert.strictEqual(content, 'Teardown was executed'); + + // Setup flag should have been removed by teardown + assert.ok(!fs.existsSync(setupFlagPath), 'Setup flag file should have been removed'); + }); it('should run ESM globalSetup and globalTeardown functions', async () => { const setupFlagPath = tmpdir.resolve('setup-executed-esm.tmp'); diff --git a/test/parallel/test-runner-run-global-hooks.mjs b/test/parallel/test-runner-run-global-hooks.mjs index 5d8fc65e77a12c..c047d61c7cad1f 100644 --- a/test/parallel/test-runner-run-global-hooks.mjs +++ b/test/parallel/test-runner-run-global-hooks.mjs @@ -1,4 +1,4 @@ -import { mustCall, mustCallAtLeast, skip } from '../common/index.mjs'; +import { mustCall, mustCallAtLeast } from '../common/index.mjs'; import * as fixtures from '../common/fixtures.mjs'; import { describe, it, beforeEach, run } from 'node:test'; import assert from 'node:assert'; @@ -8,9 +8,7 @@ import path from 'node:path'; import { spawn } from 'node:child_process'; import { once } from 'node:events'; -if (!process.config.variables.node_use_amaro) { - skip('Requires Amaro'); -} +const onlyWithAmaro = { skip: !process.config.variables.node_use_amaro }; const testFixtures = fixtures.path('test-runner', 'global-setup-teardown'); const runnerFixture = fixtures.path('test-runner', 'test-runner-global-hooks.mjs'); @@ -166,31 +164,29 @@ describe('require(\'node:test\').run with global hooks', { concurrency: false }, assert.strictEqual(content, 'Setup part, Teardown part'); }); - it('should run TypeScript globalSetup and globalTeardown functions', - onlyWithAmaro, - async () => { - const setupFlagPath = tmpdir.resolve('setup-executed-ts.tmp'); - const teardownFlagPath = tmpdir.resolve('teardown-executed-ts.tmp'); - - const { results } = await runTestWithGlobalHooks({ - globalSetupFile: 'basic-setup-teardown.ts', - runnerEnv: { - SETUP_FLAG_PATH: setupFlagPath, - TEARDOWN_FLAG_PATH: teardownFlagPath - }, - isolation - }); - - assert.strictEqual(results.passed, 2); - assert.strictEqual(results.failed, 0); - // After all tests complete, the teardown should have run - assert.ok(fs.existsSync(teardownFlagPath), 'Teardown flag file should exist'); - const content = fs.readFileSync(teardownFlagPath, 'utf8'); - assert.strictEqual(content, 'Teardown was executed'); - - // Setup flag should have been removed by teardown - assert.ok(!fs.existsSync(setupFlagPath), 'Setup flag file should have been removed'); - }); + it('should run TypeScript globalSetup and globalTeardown functions', onlyWithAmaro, async () => { + const setupFlagPath = tmpdir.resolve('setup-executed-ts.tmp'); + const teardownFlagPath = tmpdir.resolve('teardown-executed-ts.tmp'); + + const { results } = await runTestWithGlobalHooks({ + globalSetupFile: 'basic-setup-teardown.ts', + runnerEnv: { + SETUP_FLAG_PATH: setupFlagPath, + TEARDOWN_FLAG_PATH: teardownFlagPath + }, + isolation + }); + + assert.strictEqual(results.passed, 2); + assert.strictEqual(results.failed, 0); + // After all tests complete, the teardown should have run + assert.ok(fs.existsSync(teardownFlagPath), 'Teardown flag file should exist'); + const content = fs.readFileSync(teardownFlagPath, 'utf8'); + assert.strictEqual(content, 'Teardown was executed'); + + // Setup flag should have been removed by teardown + assert.ok(!fs.existsSync(setupFlagPath), 'Setup flag file should have been removed'); + }); it('should run ESM globalSetup and globalTeardown functions', async () => { const setupFlagPath = tmpdir.resolve('setup-executed-esm.tmp'); diff --git a/test/parallel/test-worker-eval-typescript.js b/test/parallel/test-worker-eval-typescript.js index 5fb56a2c0dfba5..5f1eac1eb9d358 100644 --- a/test/parallel/test-worker-eval-typescript.js +++ b/test/parallel/test-worker-eval-typescript.js @@ -21,31 +21,25 @@ const disableTypeScriptWarningFlag = '--disable-warning=ExperimentalWarning'; const onlyWithAmaro = { skip: !process.config.variables.node_use_amaro }; -test('Worker eval module typescript without input-type', - onlyWithAmaro, - async () => { - const w = new Worker(esmHelloWorld, { eval: true, execArgv: [disableTypeScriptWarningFlag] }); - assert.deepStrictEqual(await once(w, 'message'), ['Hello, World!']); - }); +test('Worker eval module typescript without input-type', onlyWithAmaro, async () => { + const w = new Worker(esmHelloWorld, { eval: true, execArgv: [disableTypeScriptWarningFlag] }); + assert.deepStrictEqual(await once(w, 'message'), ['Hello, World!']); +}); -test('Worker eval module typescript with --input-type=module-typescript', - onlyWithAmaro, - async () => { - const w = new Worker(esmHelloWorld, { eval: true, execArgv: ['--input-type=module-typescript', - disableTypeScriptWarningFlag] }); - assert.deepStrictEqual(await once(w, 'message'), ['Hello, World!']); - }); +test('Worker eval module typescript with --input-type=module-typescript', onlyWithAmaro, async () => { + const w = new Worker(esmHelloWorld, { eval: true, execArgv: ['--input-type=module-typescript', + disableTypeScriptWarningFlag] }); + assert.deepStrictEqual(await once(w, 'message'), ['Hello, World!']); +}); -test('Worker eval module typescript with --input-type=commonjs-typescript', - onlyWithAmaro, - async () => { - const w = new Worker(esmHelloWorld, { eval: true, execArgv: ['--input-type=commonjs-typescript', - disableTypeScriptWarningFlag] }); +test('Worker eval module typescript with --input-type=commonjs-typescript', onlyWithAmaro, async () => { + const w = new Worker(esmHelloWorld, { eval: true, execArgv: ['--input-type=commonjs-typescript', + disableTypeScriptWarningFlag] }); - const [err] = await once(w, 'error'); - assert.strictEqual(err.name, 'SyntaxError'); - assert.match(err.message, /Cannot use import statement outside a module/); - }); + const [err] = await once(w, 'error'); + assert.strictEqual(err.name, 'SyntaxError'); + assert.match(err.message, /Cannot use import statement outside a module/); +}); test('Worker eval module typescript with --input-type=module', async () => { const w = new Worker(esmHelloWorld, { eval: true, execArgv: ['--input-type=module', @@ -55,27 +49,21 @@ test('Worker eval module typescript with --input-type=module', async () => { assert.match(err.message, /Missing initializer in const declaration/); }); -test('Worker eval commonjs typescript without input-type', - onlyWithAmaro, - async () => { - const w = new Worker(cjsHelloWorld, { eval: true, execArgv: [disableTypeScriptWarningFlag] }); - assert.deepStrictEqual(await once(w, 'message'), ['Hello, World!']); - }); +test('Worker eval commonjs typescript without input-type', onlyWithAmaro, async () => { + const w = new Worker(cjsHelloWorld, { eval: true, execArgv: [disableTypeScriptWarningFlag] }); + assert.deepStrictEqual(await once(w, 'message'), ['Hello, World!']); +}); -test('Worker eval commonjs typescript with --input-type=commonjs-typescript', - onlyWithAmaro, - async () => { - const w = new Worker(cjsHelloWorld, { eval: true, execArgv: ['--input-type=commonjs-typescript', - disableTypeScriptWarningFlag] }); - assert.deepStrictEqual(await once(w, 'message'), ['Hello, World!']); - }); +test('Worker eval commonjs typescript with --input-type=commonjs-typescript', onlyWithAmaro, async () => { + const w = new Worker(cjsHelloWorld, { eval: true, execArgv: ['--input-type=commonjs-typescript', + disableTypeScriptWarningFlag] }); + assert.deepStrictEqual(await once(w, 'message'), ['Hello, World!']); +}); -test('Worker eval commonjs typescript with --input-type=module-typescript', - onlyWithAmaro, - async () => { - const w = new Worker(cjsHelloWorld, { eval: true, execArgv: ['--input-type=module-typescript', - disableTypeScriptWarningFlag] }); - const [err] = await once(w, 'error'); - assert.strictEqual(err.name, 'ReferenceError'); - assert.match(err.message, /require is not defined in ES module scope, you can use import instead/); - }); +test('Worker eval commonjs typescript with --input-type=module-typescript', onlyWithAmaro, async () => { + const w = new Worker(cjsHelloWorld, { eval: true, execArgv: ['--input-type=module-typescript', + disableTypeScriptWarningFlag] }); + const [err] = await once(w, 'error'); + assert.strictEqual(err.name, 'ReferenceError'); + assert.match(err.message, /require is not defined in ES module scope, you can use import instead/); +}); diff --git a/test/parallel/test-worker-load-file-with-extension-other-than-js.js b/test/parallel/test-worker-load-file-with-extension-other-than-js.js index 7c2afce4fbe2b3..5dca297576b978 100644 --- a/test/parallel/test-worker-load-file-with-extension-other-than-js.js +++ b/test/parallel/test-worker-load-file-with-extension-other-than-js.js @@ -1,6 +1,7 @@ 'use strict'; const common = require('../common'); const fixtures = require('../common/fixtures'); + const { Worker } = require('worker_threads'); (common.mustCall(() => { From 5a746fd997e118e8a467223f1edf6b0284f064e2 Mon Sep 17 00:00:00 2001 From: y-okt Date: Wed, 26 Nov 2025 00:47:20 +0900 Subject: [PATCH 8/9] test: fix spacing issue there are still some spacing diffs, and this addresses that Fixes: https://github.com/nodejs/node/pull/60815 --- ...est-esm-tla-syntax-errors-not-recognized-as-tla-error.mjs | 4 ++-- test/parallel/test-compile-cache-typescript-commonjs.js | 5 +---- test/parallel/test-util-getcallsites.js | 1 + 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/test/es-module/test-esm-tla-syntax-errors-not-recognized-as-tla-error.mjs b/test/es-module/test-esm-tla-syntax-errors-not-recognized-as-tla-error.mjs index d001c593fd0e3a..ed6d3e44f8f14b 100644 --- a/test/es-module/test-esm-tla-syntax-errors-not-recognized-as-tla-error.mjs +++ b/test/es-module/test-esm-tla-syntax-errors-not-recognized-as-tla-error.mjs @@ -66,8 +66,8 @@ describe('unusual top-level await syntax errors', () => { const { code, signal, stdout, stderr } = await spawnPromisified(process.execPath, [ '--eval', ` - ${wrapperExpression} - `, + ${wrapperExpression} + `, ]); assert.match(stderr, error); assert.strictEqual(stdout, ''); diff --git a/test/parallel/test-compile-cache-typescript-commonjs.js b/test/parallel/test-compile-cache-typescript-commonjs.js index 704eb82a3273aa..fc27f96eec7238 100644 --- a/test/parallel/test-compile-cache-typescript-commonjs.js +++ b/test/parallel/test-compile-cache-typescript-commonjs.js @@ -2,10 +2,7 @@ // This tests NODE_COMPILE_CACHE works for CommonJS with types. -const common = require('../common'); -if (!process.config.variables.node_use_amaro) { - common.skip('Requires Amaro'); -} +require('../common'); const { spawnSyncAndAssert } = require('../common/child_process'); const assert = require('assert'); const tmpdir = require('../common/tmpdir'); diff --git a/test/parallel/test-util-getcallsites.js b/test/parallel/test-util-getcallsites.js index 2054b8d2b017cb..7cab4f6cac6397 100644 --- a/test/parallel/test-util-getcallsites.js +++ b/test/parallel/test-util-getcallsites.js @@ -6,6 +6,7 @@ if (!process.config.variables.node_use_amaro) { } const fixtures = require('../common/fixtures'); const file = fixtures.path('get-call-sites.js'); + const { getCallSites } = require('node:util'); const { spawnSync } = require('node:child_process'); const assert = require('node:assert'); From c33440288b9c397d01b4b601d822493f50edd0dd Mon Sep 17 00:00:00 2001 From: y-okt Date: Fri, 28 Nov 2025 21:45:50 +0900 Subject: [PATCH 9/9] test: skip test-compile-cache-typescript tests skip these as they are failing without amaro Fixes: https://github.com/nodejs/node/pull/60815 --- test/parallel/test-compile-cache-typescript-commonjs.js | 7 +++++-- test/parallel/test-compile-cache-typescript-esm.js | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/test/parallel/test-compile-cache-typescript-commonjs.js b/test/parallel/test-compile-cache-typescript-commonjs.js index fc27f96eec7238..60e86c3c0f9d5d 100644 --- a/test/parallel/test-compile-cache-typescript-commonjs.js +++ b/test/parallel/test-compile-cache-typescript-commonjs.js @@ -2,14 +2,17 @@ // This tests NODE_COMPILE_CACHE works for CommonJS with types. -require('../common'); +const common = require('../common'); +if (!process.config.variables.node_use_amaro) { + common.skip('Requires Amaro'); +} const { spawnSyncAndAssert } = require('../common/child_process'); const assert = require('assert'); const tmpdir = require('../common/tmpdir'); const fixtures = require('../common/fixtures'); // Check cache for .ts files that would be run as CommonJS. -if (process.config.variables.node_use_amaro) { +{ tmpdir.refresh(); const dir = tmpdir.resolve('.compile_cache_dir'); const script = fixtures.path('typescript', 'ts', 'test-commonjs-parsing.ts'); diff --git a/test/parallel/test-compile-cache-typescript-esm.js b/test/parallel/test-compile-cache-typescript-esm.js index e4bd7ac36ae7b8..98473dbb2a5b64 100644 --- a/test/parallel/test-compile-cache-typescript-esm.js +++ b/test/parallel/test-compile-cache-typescript-esm.js @@ -2,14 +2,17 @@ // This tests NODE_COMPILE_CACHE works for ESM with types. -require('../common'); +const common = require('../common'); +if (!process.config.variables.node_use_amaro) { + common.skip('Requires Amaro'); +} const { spawnSyncAndAssert } = require('../common/child_process'); const assert = require('assert'); const tmpdir = require('../common/tmpdir'); const fixtures = require('../common/fixtures'); // Check cache for .ts files that would be run as ESM. -if (process.config.variables.node_use_amaro) { +{ tmpdir.refresh(); const dir = tmpdir.resolve('.compile_cache_dir'); const script = fixtures.path('typescript', 'ts', 'test-module-typescript.ts');