Skip to content

Commit 88fdbfb

Browse files
henrychvclaude
andcommitted
MOB-48124: Fix isFirstLevelStep to walk ancestor chain, not just check parent
Root-caused via a diagnostic reporter build with per-hook debug logging (sandbox only): when a whole-test timeout fires while a test.step() loop is still running, Playwright can attribute still-executing test.step() calls to its own teardown fixture (e.g. "Fixture \"context\"") as their parent, instead of null. isFirstLevelStep() previously treated any non-null parent as nesting, silently dropping these steps from STEP granularity even though they were never actually nested under another test.step(). Now walks the full ancestor chain and only disqualifies a step if a genuine test.step ancestor is found, ignoring hook/fixture ancestors. Verified via deterministic reproduction: a step with a corrupted "Fixture \"context\"" parent is now correctly still reported. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent 2bb5506 commit 88fdbfb

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

bzt/resources/playwright-custom-reporter/playwright-custom-reporter.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,14 +203,20 @@ class TaurusReporter {
203203
}
204204

205205
// Only first-level test.step() calls are reported (nested test.step calls are skipped).
206-
// Playwright's own category enum reserves 'test.step' exclusively for explicit
207-
// test.step() calls, so this already excludes hooks, fixtures, expects and pw:api steps.
206+
// "First-level" means no ancestor in the parent chain is itself a test.step. A parent
207+
// that is a hook/fixture/pw:api step does not count as nesting - it isn't something the
208+
// test author wrote. This matters because Playwright can attribute still-running
209+
// test.step() calls to its own teardown fixture (e.g. "Fixture \"context\"") as their
210+
// parent when a whole-test timeout races with in-flight user code, which would otherwise
211+
// make a genuinely top-level step look nested and get silently dropped.
208212
isFirstLevelStep(step) {
209213
if (!step || step.category !== 'test.step') {
210214
return false;
211215
}
212-
if (step.parent) {
213-
return false;
216+
for (let current = step.parent; current; current = current.parent) {
217+
if (current.category === 'test.step') {
218+
return false;
219+
}
214220
}
215221
return true;
216222
}

0 commit comments

Comments
 (0)