From 979af2695e79d24e771e2cb113e0412b5dd102e2 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Fri, 27 Sep 2024 16:54:47 +0200 Subject: [PATCH] test_runner: avoid spread operator on arrays --- lib/internal/test_runner/runner.js | 4 +++- lib/internal/test_runner/test.js | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/internal/test_runner/runner.js b/lib/internal/test_runner/runner.js index 4a19e13d9a029c..67bd417b88e806 100644 --- a/lib/internal/test_runner/runner.js +++ b/lib/internal/test_runner/runner.js @@ -10,6 +10,7 @@ const { ArrayPrototypeJoin, ArrayPrototypeMap, ArrayPrototypePush, + ArrayPrototypePushApply, ArrayPrototypeShift, ArrayPrototypeSlice, ArrayPrototypeSome, @@ -149,7 +150,8 @@ function getRunArgs(path, { forceExit, inspectPort, testNamePatterns, testSkipPa } 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 4331079f74e95a..5ad22f78068ed1 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, @@ -732,9 +733,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), ); }