From cc307f14869e9303d959fe731a884c7ede4b0ce0 Mon Sep 17 00:00:00 2001 From: Simon Knott Date: Thu, 23 Jul 2026 16:42:48 +0200 Subject: [PATCH] perf(test): avoid redundant stack capture Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: c00ba4a1-a424-46ae-967e-2ddf02f91511 --- packages/playwright/src/matchers/expect.ts | 1 + packages/playwright/src/worker/testInfo.ts | 7 +++---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/playwright/src/matchers/expect.ts b/packages/playwright/src/matchers/expect.ts index a027b71bc0949..f50c37fb74919 100644 --- a/packages/playwright/src/matchers/expect.ts +++ b/packages/playwright/src/matchers/expect.ts @@ -343,6 +343,7 @@ function callMatcherAsStep(matcherName: string, info: ExpectMetaInfo, actual: un apiName, title: longTitle, shortTitle, + location: stackFrames[0], params: args[0] ? { expected: args[0] } : undefined, }; const step = testInfo?._addStep(stepData); diff --git a/packages/playwright/src/worker/testInfo.ts b/packages/playwright/src/worker/testInfo.ts index 7e20abe21e0ba..3fce56e1b7e3e 100644 --- a/packages/playwright/src/worker/testInfo.ts +++ b/packages/playwright/src/worker/testInfo.ts @@ -295,14 +295,13 @@ export class TestInfoImpl implements TestInfo { parentStep = this._parentStep(); } - const filteredStack = filteredStackTrace(captureRawStack()); let boxedStack = parentStep?.boxedStack; let location = data.location; if (!boxedStack && data.box) { - boxedStack = filteredStack.slice(1); - location = location || boxedStack[0]; + boxedStack = filteredStackTrace(captureRawStack()).slice(1); + location ??= boxedStack[0]; } - location = location || filteredStack[0]; + location ??= filteredStackTrace(captureRawStack())[0]; const step: TestStepInternal = { ...data,