MCPcopy Index your code
hub / github.com/nodejs/node / postRun

Method postRun

lib/internal/test_runner/test.js:1476–1588  ·  view source on GitHub ↗
(pendingSubtestsError)

Source from the content-addressed store, hash-verified

1474 }
1475
1476 postRun(pendingSubtestsError) {
1477 // If the test was cancelled before it started, then the start and end
1478 // times need to be corrected.
1479 this.endTime ??= hrtime();
1480 this.startTime ??= this.endTime;
1481
1482 // The test has run, so recursively cancel any outstanding subtests and
1483 // mark this test as failed if any subtests failed.
1484 this.pendingSubtests = [];
1485 let failed = 0;
1486 for (let i = 0; i < this.subtests.length; i++) {
1487 const subtest = this.subtests[i];
1488
1489 if (!subtest.finished) {
1490 subtest.#cancel(pendingSubtestsError);
1491 subtest.postRun(pendingSubtestsError);
1492 }
1493 if (!subtest.passed && !subtest.isTodo) {
1494 failed++;
1495 }
1496 }
1497
1498 if ((this.passed || this.parent === null) && failed > 0) {
1499 const subtestString = `subtest${failed > 1 ? 's' : ''}`;
1500 const msg = `${failed} ${subtestString} failed`;
1501
1502 this.fail(new ERR_TEST_FAILURE(msg, kSubtestsFailed));
1503 }
1504
1505 this.outerSignal?.removeEventListener('abort', this.#abortHandler);
1506 this.mock?.reset();
1507
1508 if (this.parent !== null) {
1509 if (!this.filtered) {
1510 const report = this.getReportDetails();
1511 report.details.passed = this.passed;
1512 this.testNumber ||= ++this.parent.outputSubtestCount;
1513 this.reporter.complete(
1514 this.nesting, this.loc, this.testNumber, this.name,
1515 report.details, report.directive, this.testId, this.parent?.testId, this.tags,
1516 );
1517 this.parent.activeSubtests--;
1518 }
1519
1520 this.parent.addReadySubtest(this);
1521 this.parent.processReadySubtestRange(false);
1522 this.parent.processPendingSubtests();
1523 } else if (!this.reported) {
1524 const {
1525 diagnostics,
1526 harness,
1527 loc,
1528 nesting,
1529 reporter,
1530 } = this;
1531
1532 this.reported = true;
1533 reporter.plan(nesting, loc, harness.counters.topLevel);

Callers 7

filteredRunMethod · 0.95
runMethod · 0.95
runTestFileFunction · 0.45
cleanupFunction · 0.45
runFunction · 0.45
runMethod · 0.45
exitHandlerFunction · 0.45

Calls 15

failMethod · 0.95
getReportDetailsMethod · 0.95
durationMethod · 0.95
hrtimeFunction · 0.85
addReadySubtestMethod · 0.80
coverageMethod · 0.80
writeSnapshotFilesMethod · 0.80
removeEventListenerMethod · 0.65
#cancelMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected