Skip to content

fix(test): preserve full stack traces in test.step with POM and Promise.all#40167

Open
ishanrajsingh wants to merge 1 commit intomicrosoft:mainfrom
ishanrajsingh:fix/stacktrace-step-pom
Open

fix(test): preserve full stack traces in test.step with POM and Promise.all#40167
ishanrajsingh wants to merge 1 commit intomicrosoft:mainfrom
ishanrajsingh:fix/stacktrace-step-pom

Conversation

@ishanrajsingh
Copy link
Copy Markdown

Issue #40141

Problem

Stack traces are truncated when using test.step inside Page Object Model (POM) methods,
especially when combined with Promise.all.

User-land stack frames (e.g. POM methods and test file calls) were missing,
making debugging difficult.

Root Cause

Stack traces were being overwritten in intermediate step handling:

  • _addStep.complete
  • _failWithError

This removed original async stack frames.

Fix

  • Preserve original error stack
  • Append step context only in _failWithError (final error pipeline)
  • Avoid modifying stack in _addStep.complete
  • Improve stack capture and parsing in stackTrace.ts

Result

Stack traces now correctly include:

  • POM methods (e.g. shouldBeCorrect, shouldBeValidColor)
  • test file call site
  • step hierarchy (test.step)

JavaScript async limitations (e.g. Promise.all) may still omit some parent frames,
but Playwright no longer truncates or removes user-land stack traces.

Validation

  • Verified via CLI output
  • Verified via Trace Viewer step hierarchy
  • Reproduced using minimal test case from issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant