| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -142,6 +142,7 @@ class TestContext { | |||
| 142 | 142 | class Test extends AsyncResource { | |
| 143 | 143 | #abortController; | |
| 144 | 144 | #outerSignal; | |
| 145 | + #reportedSubtest; | ||
| 145 | 146 | ||
| 146 | 147 | constructor(options) { | |
| 147 | 148 | super('Test'); | |
@@ -308,7 +309,7 @@ class Test extends AsyncResource { | |||
| 308 | 309 | } | |
| 309 | 310 | ||
| 310 | 311 | if (i === 1 && this.parent !== null) { | |
| 311 | - this.reporter.subtest(this.indent, this.name); | ||
| 312 | + this.reportSubtest(); | ||
| 312 | 313 | } | |
| 313 | 314 | ||
| 314 | 315 | // Report the subtest's results and remove it from the ready map. | |
@@ -631,12 +632,6 @@ class Test extends AsyncResource { | |||
| 631 | 632 | this.processReadySubtestRange(true); | |
| 632 | 633 | ||
| 633 | 634 | // Output this test's results and update the parent's waiting counter. | |
| 634 | - if (this.subtests.length > 0) { | ||
| 635 | - this.reporter.plan(this.subtests[0].indent, this.subtests.length); | ||
| 636 | - } else { | ||
| 637 | - this.reporter.subtest(this.indent, this.name); | ||
| 638 | - } | ||
| 639 | - | ||
| 640 | 635 | this.report(); | |
| 641 | 636 | this.parent.waitingOn++; | |
| 642 | 637 | this.finished = true; | |
@@ -648,6 +643,11 @@ class Test extends AsyncResource { | |||
| 648 | 643 | } | |
| 649 | 644 | ||
| 650 | 645 | report() { | |
| 646 | + if (this.subtests.length > 0) { | ||
| 647 | + this.reporter.plan(this.subtests[0].indent, this.subtests.length); | ||
| 648 | + } else { | ||
| 649 | + this.reportSubtest(); | ||
| 650 | + } | ||
| 651 | 651 | let directive; | |
| 652 | 652 | ||
| 653 | 653 | if (this.skipped) { | |
@@ -666,6 +666,15 @@ class Test extends AsyncResource { | |||
| 666 | 666 | this.reporter.diagnostic(this.indent, this.diagnostics[i]); | |
| 667 | 667 | } | |
| 668 | 668 | } | |
| 669 | + | ||
| 670 | + reportSubtest() { | ||
| 671 | + if (this.#reportedSubtest || this.parent === null) { | ||
| 672 | + return; | ||
| 673 | + } | ||
| 674 | + this.#reportedSubtest = true; | ||
| 675 | + this.parent.reportSubtest(); | ||
| 676 | + this.reporter.subtest(this.indent, this.name); | ||
| 677 | + } | ||
| 669 | 678 | } | |
| 670 | 679 | ||
| 671 | 680 | class TestHook extends Test { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,10 @@ | |||
| 1 | + // Flags: --no-warnings | ||
| 2 | + 'use strict'; | ||
| 3 | + require('../common'); | ||
| 4 | + const { describe, it } = require('node:test'); | ||
| 5 | + | ||
| 6 | + describe('nested - no tests', () => { | ||
| 7 | + describe('nested', () => { | ||
| 8 | + it('nested', () => {}); | ||
| 9 | + }); | ||
| 10 | + }); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,26 @@ | |||
| 1 | + TAP version 13 | ||
| 2 | + # Subtest: nested - no tests | ||
| 3 | + # Subtest: nested | ||
| 4 | + # Subtest: nested | ||
| 5 | + ok 1 - nested | ||
| 6 | + --- | ||
| 7 | + duration_ms: * | ||
| 8 | + ... | ||
| 9 | + 1..1 | ||
| 10 | + ok 1 - nested | ||
| 11 | + --- | ||
| 12 | + duration_ms: * | ||
| 13 | + ... | ||
| 14 | + 1..1 | ||
| 15 | + ok 1 - nested - no tests | ||
| 16 | + --- | ||
| 17 | + duration_ms: * | ||
| 18 | + ... | ||
| 19 | + 1..1 | ||
| 20 | + # tests 1 | ||
| 21 | + # pass 1 | ||
| 22 | + # fail 0 | ||
| 23 | + # cancelled 0 | ||
| 24 | + # skipped 0 | ||
| 25 | + # todo 0 | ||
| 26 | + # duration_ms * | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments