From 103b8439cae2a113f4f0796dd6fcbced294a3ed8 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Sun, 29 Sep 2024 17:22:10 +0200 Subject: [PATCH] test_runner: avoid spread operator on arrays PR-URL: https://github.com/nodejs/node/pull/55143 Reviewed-By: Matteo Collina Reviewed-By: Colin Ihrig Reviewed-By: James M Snell --- lib/internal/test_runner/runner.js | 3 ++- lib/internal/test_runner/test.js | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/internal/test_runner/runner.js b/lib/internal/test_runner/runner.js index b8d7740614cee5..2241df6b378253 100644 --- a/lib/internal/test_runner/runner.js +++ b/lib/internal/test_runner/runner.js @@ -158,7 +158,8 @@ function getRunArgs(path, { forceExit, ArrayPrototypePushApply(argv, execArgv); if (path === kIsolatedProcessName) { - ArrayPrototypePush(argv, '--test', ...ArrayPrototypeSlice(process.argv, 1)); + ArrayPrototypePush(argv, '--test'); + ArrayPrototypePushApply(argv, ArrayPrototypeSlice(process.argv, 1)); } else { ArrayPrototypePush(argv, path); } diff --git a/lib/internal/test_runner/test.js b/lib/internal/test_runner/test.js index 993c98802abde4..0bc24bae54496a 100644 --- a/lib/internal/test_runner/test.js +++ b/lib/internal/test_runner/test.js @@ -8,6 +8,7 @@ const { ArrayPrototypeSome, ArrayPrototypeSplice, ArrayPrototypeUnshift, + ArrayPrototypeUnshiftApply, FunctionPrototype, MathMax, Number, @@ -735,9 +736,9 @@ class Test extends AsyncResource { computeInheritedHooks() { if (this.parent.hooks.beforeEach.length > 0) { - ArrayPrototypeUnshift( + ArrayPrototypeUnshiftApply( this.hooks.beforeEach, - ...ArrayPrototypeSlice(this.parent.hooks.beforeEach), + ArrayPrototypeSlice(this.parent.hooks.beforeEach), ); }