diff --git a/lib/internal/test_runner/test.js b/lib/internal/test_runner/test.js index 27cea6e1789c31..39db7f668608a2 100644 --- a/lib/internal/test_runner/test.js +++ b/lib/internal/test_runner/test.js @@ -93,6 +93,7 @@ class Test extends AsyncResource { this.reporter = new TapStream(); this.runOnlySubtests = this.only; this.testNumber = 0; + this.shouldReportSubtest = false; } else { const indent = parent.parent === null ? parent.indent : parent.indent + parent.indentString; @@ -104,6 +105,7 @@ class Test extends AsyncResource { this.reporter = parent.reporter; this.runOnlySubtests = !this.only; this.testNumber = parent.subtests.length + 1; + this.shouldReportSubtest = true; } if (isUint32(concurrency) && concurrency !== 0) { @@ -162,7 +164,6 @@ class Test extends AsyncResource { processReadySubtestRange(canSend) { const start = this.waitingOn; const end = start + this.readySubtests.size; - let shouldReportSubtest = this.parent !== null; for (let i = start; i < end; i++) { const subtest = this.readySubtests.get(i); @@ -184,9 +185,9 @@ class Test extends AsyncResource { return; } - if (shouldReportSubtest) { + if (this.shouldReportSubtest) { this.reporter.subTest(this.indent, this.name); - shouldReportSubtest = false; + this.shouldReportSubtest = false; } // Report the subtest's results and remove it from the ready map. diff --git a/test/message/test_runner_output.out b/test/message/test_runner_output.out index 8c95eda5c84067..2f6e2502749068 100644 --- a/test/message/test_runner_output.out +++ b/test/message/test_runner_output.out @@ -238,7 +238,6 @@ not ok 22 - sync throw non-error fail --- duration_ms: * ... -# Subtest: level 0a # Subtest: level 1c ok 3 - level 1c ---