diff --git a/lib/internal/test_runner/runner.js b/lib/internal/test_runner/runner.js index 38f7022314ed73..0b426929d57eaa 100644 --- a/lib/internal/test_runner/runner.js +++ b/lib/internal/test_runner/runner.js @@ -7,6 +7,7 @@ const { ArrayPrototypeJoin, ArrayPrototypePush, ArrayPrototypeSlice, + ArrayPrototypeSome, ArrayPrototypeSort, ObjectAssign, PromisePrototypeThen, @@ -16,6 +17,7 @@ const { SafeMap, SafeSet, StringPrototypeRepeat, + StringPrototypeStartsWith, } = primordials; const { spawn } = require('child_process'); @@ -117,7 +119,8 @@ function createTestFileList() { function filterExecArgv(arg, i, arr) { return !ArrayPrototypeIncludes(kFilterArgs, arg) && !ArrayPrototypeIncludes(kFilterArgValues, arg) && - !ArrayPrototypeIncludes(kFilterArgValues, arr[i - 1]); + !ArrayPrototypeIncludes(kFilterArgValues, arr[i - 1]) && + !ArrayPrototypeSome(kFilterArgValues, (p) => StringPrototypeStartsWith(arg, `${p}=`)); } function getRunArgs({ path, inspectPort }) { diff --git a/lib/internal/test_runner/test.js b/lib/internal/test_runner/test.js index 66f43d0b1f7a31..743c5832e64207 100644 --- a/lib/internal/test_runner/test.js +++ b/lib/internal/test_runner/test.js @@ -7,6 +7,7 @@ const { ArrayPrototypeSlice, ArrayPrototypeSome, ArrayPrototypeUnshift, + Boolean, FunctionPrototype, MathMax, Number, @@ -173,7 +174,7 @@ class Test extends AsyncResource { this.concurrency = 1; this.nesting = 0; this.only = testOnlyFlag; - this.reporter = new TapStream({ objectMode: hasReporters }); + this.reporter = new TapStream({ __proto__: null, objectMode: hasReporters }); this.runOnlySubtests = this.only; this.testNumber = 0; this.timeout = kDefaultTimeout; diff --git a/lib/test/reporter/dot.js b/lib/test/reporter/dot.js index 970603e06a4226..80d07092ccb05a 100644 --- a/lib/test/reporter/dot.js +++ b/lib/test/reporter/dot.js @@ -3,8 +3,8 @@ module.exports = async function*(source) { for await (const { type } of source) { if (type === 'test:fail' || type === 'test:pass') { - yield "."; + yield '.'; } } - yield "\n"; + yield '\n'; }; diff --git a/lib/test/reporter/spec.js b/lib/test/reporter/spec.js index b73a1741e2db20..5e618ab7588a73 100644 --- a/lib/test/reporter/spec.js +++ b/lib/test/reporter/spec.js @@ -1,6 +1,10 @@ 'use strict'; -const console = require('console'); +const { + ArrayPrototypePop, + ArrayPrototypeShift, + ArrayPrototypeUnshift, +} = primordials; const Transform = require('internal/streams/transform'); const { green, blue, red, white } = require('internal/util/colors'); @@ -34,21 +38,23 @@ class SpecReporter extends Transform { switch (type) { case 'test:fail': case 'test:pass': { - this.#stack.shift(); + ArrayPrototypeShift(this.#stack); // This is the matching `test:subtest` event let prefix = ''; while (this.#stack.length) { - const msg = this.#stack.pop(); - this.#reported.unshift(msg); + // Report all the parent `test:subtest` events + const msg = ArrayPrototypePop(this.#stack); + ArrayPrototypeUnshift(this.#reported, msg); prefix += `${this.#indent(msg.nesting)}${symbols['arrow:right']}${msg.name}\n`; } if (this.#reported[0] && this.#reported[0].nesting === data.nesting && this.#reported[0].name === data.name) { - this.#reported.shift(); + // If this test has had children - it was already reporter, so slightly modify the output + ArrayPrototypeShift(this.#reported); return `${prefix}${this.#indent(data.nesting)}${color}${symbols['arrow:right']}${white}${data.name}\n\n`; } return `${prefix}${this.#indent(data.nesting)}${color}${symbol}${data.name}${white}\n`; } case 'test:subtest': - this.#stack.unshift(data); + ArrayPrototypeUnshift(this.#stack, data); break; case 'test:diagnostic': return `${color}${symbol}${data}${white}\n`;