From 4c53e56cb4f25e71f47b0cab65cfe3dcb0000afb Mon Sep 17 00:00:00 2001 From: Dmitry Gozman Date: Thu, 14 Nov 2024 11:03:34 +0000 Subject: [PATCH] cherry-pick(#33583): fix(merge): update error.cause location (#33601) --- packages/playwright/src/reporters/merge.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/playwright/src/reporters/merge.ts b/packages/playwright/src/reporters/merge.ts index 5eedcac136..102335cceb 100644 --- a/packages/playwright/src/reporters/merge.ts +++ b/packages/playwright/src/reporters/merge.ts @@ -18,7 +18,7 @@ import fs from 'fs'; import path from 'path'; import type { ReporterDescription } from '../../types/test'; import type { FullConfigInternal } from '../common/config'; -import type { JsonConfig, JsonEvent, JsonFullResult, JsonLocation, JsonProject, JsonSuite, JsonTestCase, JsonTestResultEnd, JsonTestStepStart } from '../isomorphic/teleReceiver'; +import type { JsonConfig, JsonEvent, JsonFullResult, JsonLocation, JsonProject, JsonSuite, JsonTestCase, JsonTestResultEnd, JsonTestStepStart, JsonTestStepEnd } from '../isomorphic/teleReceiver'; import { TeleReporterReceiver } from '../isomorphic/teleReceiver'; import { JsonStringInternalizer, StringInternPool } from '../isomorphic/stringInternPool'; import { createReporters } from '../runner/reporters'; @@ -471,7 +471,7 @@ class PathSeparatorPatcher { } if (jsonEvent.method === 'onTestEnd') { const testResult = jsonEvent.params.result as JsonTestResultEnd; - testResult.errors.forEach(error => this._updateLocation(error.location)); + testResult.errors.forEach(error => this._updateErrorLocations(error)); testResult.attachments.forEach(attachment => { if (attachment.path) attachment.path = this._updatePath(attachment.path); @@ -483,6 +483,11 @@ class PathSeparatorPatcher { this._updateLocation(step.location); return; } + if (jsonEvent.method === 'onStepEnd') { + const step = jsonEvent.params.step as JsonTestStepEnd; + this._updateErrorLocations(step.error); + return; + } } private _updateProject(project: JsonProject) { @@ -504,6 +509,13 @@ class PathSeparatorPatcher { } } + private _updateErrorLocations(error: TestError | undefined) { + while (error) { + this._updateLocation(error.location); + error = error.cause; + } + } + private _updateLocation(location?: JsonLocation) { if (location) location.file = this._updatePath(location.file);