test_runner: add `testId` to test events · nodejs/node@f68189b
@@ -590,6 +590,8 @@ class Test extends AsyncResource {
590590this.timeout = kDefaultTimeout;
591591this.entryFile = entryFile;
592592this.testDisambiguator = new SafeMap();
593+this.nextTestId = 1;
594+this.testId = 0;
593595} else {
594596const nesting = parent.parent === null ? parent.nesting :
595597parent.nesting + 1;
@@ -606,6 +608,7 @@ class Test extends AsyncResource {
606608this.childNumber = parent.subtests.length + 1;
607609this.timeout = parent.timeout;
608610this.entryFile = parent.entryFile;
611+this.testId = this.root.nextTestId++;
609612610613if (isFilteringByName) {
611614this.filteredByName = this.willBeFilteredByName();
@@ -890,7 +893,7 @@ class Test extends AsyncResource {
890893const deferred = this.dequeuePendingSubtest();
891894const test = deferred.test;
892895this.assignReportOrder(test);
893-test.reporter.dequeue(test.nesting, test.loc, test.name, this.reportedType);
896+test.reporter.dequeue(test.nesting, test.loc, test.name, this.reportedType, test.testId);
894897await test.run();
895898deferred.resolve();
896899}
@@ -1147,7 +1150,7 @@ class Test extends AsyncResource {
11471150// it. Otherwise, return a Promise to the caller and mark the test as
11481151// pending for later execution.
11491152this.parent.unfinishedSubtests.add(this);
1150-this.reporter.enqueue(this.nesting, this.loc, this.name, this.reportedType);
1153+this.reporter.enqueue(this.nesting, this.loc, this.name, this.reportedType, this.testId);
11511154if (this.root.harness.buildPromise || !this.parent.hasConcurrency()) {
11521155const deferred = PromiseWithResolvers();
11531156@@ -1170,7 +1173,7 @@ class Test extends AsyncResource {
11701173}
1171117411721175this.parent.assignReportOrder(this);
1173-this.reporter.dequeue(this.nesting, this.loc, this.name, this.reportedType);
1176+this.reporter.dequeue(this.nesting, this.loc, this.name, this.reportedType, this.testId);
11741177return this.run();
11751178}
11761179@@ -1432,7 +1435,10 @@ class Test extends AsyncResource {
14321435const report = this.getReportDetails();
14331436report.details.passed = this.passed;
14341437this.testNumber ||= ++this.parent.outputSubtestCount;
1435-this.reporter.complete(this.nesting, this.loc, this.testNumber, this.name, report.details, report.directive);
1438+this.reporter.complete(
1439+this.nesting, this.loc, this.testNumber, this.name,
1440+report.details, report.directive, this.testId,
1441+);
14361442this.parent.activeSubtests--;
14371443}
14381444@@ -1585,9 +1591,15 @@ class Test extends AsyncResource {
15851591const report = this.getReportDetails();
1586159215871593if (this.passed) {
1588-this.reporter.ok(this.nesting, this.loc, this.testNumber, this.name, report.details, report.directive);
1594+this.reporter.ok(
1595+this.nesting, this.loc, this.testNumber, this.name,
1596+report.details, report.directive, this.testId,
1597+);
15891598} else {
1590-this.reporter.fail(this.nesting, this.loc, this.testNumber, this.name, report.details, report.directive);
1599+this.reporter.fail(
1600+this.nesting, this.loc, this.testNumber, this.name,
1601+report.details, report.directive, this.testId,
1602+);
15911603}
1592160415931605for (let i = 0; i < this.diagnostics.length; i++) {
@@ -1601,7 +1613,7 @@ class Test extends AsyncResource {
16011613}
16021614this.#reportedSubtest = true;
16031615this.parent.reportStarted();
1604-this.reporter.start(this.nesting, this.loc, this.name);
1616+this.reporter.start(this.nesting, this.loc, this.name, this.testId);
16051617}
1606161816071619clearExecutionTime() {