Skip to content

fix(test-runner): recover beforeAll-skipped tests for --last-failed - #42056

Merged
Pavel Feldman (pavelfeldman) merged 1 commit into
microsoft:mainfrom
Pinio31:fix/last-run-recover-beforeall-skipped-tests
Jul 30, 2026
Merged

Pavel Feldman (pavelfeldman) merged 1 commit into
microsoft:mainfrom
Pinio31:fix/last-run-recover-beforeall-skipped-tests

Conversation

@Pinio31

Copy link
Copy Markdown
Contributor

What

When an ancestor beforeAll hook fails, Playwright fails the first test in that group and marks the remaining tests as "did not run". Internally, those tests get outcome() === 'skipped' and ok() === true, exactly like a test intentionally skipped via test.skip()/fixme().

.last-run.json's failedTests is computed as allTests().filter(t => !t.ok()), so these did-not-run tests are silently excluded, indistinguishable from intentional skips. When CI reruns with --last-failed, only the ids in failedTests are re-executed so these tests are dropped and become unreachable for the rest of that run.

Fix

Adds a didNotRun() check in packages/playwright/src/runner/lastRun.ts and includes those tests in failedTests. The predicate mirrors the one already used in reporters/base.ts for the CLI's "N did not run" summary line: outcome() === 'skipped' and either no results yet or expectedStatus !== 'skipped'. Interrupted runs (e.g. Ctrl+C) are explicitly excluded, since those tests were already in progress rather than skipped by a hook failure.

Testing

Added two tests to tests/playwright-test/runner.spec.ts:

  • a beforeAll-hook-failure case where the sibling "did not run" test is recovered and actually re-executes (and passes) on --last-failed
  • a regression guard confirming intentional test.skip() still stays excluded from --last-failed

When an ancestor beforeAll hook fails, Playwright fails the first test in
that group and marks the remaining tests as "did not run". Internally,
those tests get outcome() === 'skipped' and ok() === true, identical to
a test intentionally skipped via test.skip()/fixme().

.last-run.json's failedTests is computed as allTests().filter(t => !t.ok()),
so these did-not-run tests were silently excluded, indistinguishable from
intentional skips. On a CI rerun with --last-failed, only the ids in
failedTests are re-executed, so these tests were dropped and became
unreachable for the rest of that run.

This adds a didNotRun() check mirroring the predicate already used in
reporters/base.ts for the CLI's "N did not run" summary line, and includes
those tests in failedTests. Interrupted runs (e.g. Ctrl+C) are explicitly
excluded, since those tests were already in progress rather than skipped
by a hook failure.

References microsoft#33974
@github-actions

Copy link
Copy Markdown
Contributor

Test results for "tests 1"

5 flaky ⚠️ [chromium-library] › library/screencast.spec.ts:28 › screencast.start delivers frames via onFrame callback `@frozen-time-library-chromium-linux`
⚠️ [chromium-library] › library/video.spec.ts:356 › screencast › should work for popups `@frozen-time-library-chromium-linux`
⚠️ [chromium-library] › library/video.spec.ts:495 › screencast › should capture static page in persistent context Radoslav Kirilov (@smoke) `@frozen-time-library-chromium-linux`
⚠️ [chromium-library] › library/video.spec.ts:736 › screencast › should work with video+trace `@chromium-ubuntu-22.04-arm-node20`
⚠️ [chromium-library] › library/video.spec.ts:736 › screencast › should work with video+trace `@chromium-ubuntu-22.04-node20`

51068 passed, 1188 skipped


Merge workflow run.

@github-actions

Copy link
Copy Markdown
Contributor

Test results for "MCP"

3 failed
❌ [chrome] › mcp/cli-drag.spec.ts:53 › drop files and data onto an element @mcp-macos-latest-chrome
❌ [firefox] › mcp/cli-core.spec.ts:179 › dialog-dismiss @mcp-windows-latest-firefox
❌ [firefox] › mcp/cli-core.spec.ts:189 › dialog-accept @mcp-windows-latest-firefox

7812 passed, 1272 skipped


Merge workflow run.

@pavelfeldman
Pavel Feldman (pavelfeldman) merged commit 0484712 into microsoft:main Jul 30, 2026
48 of 50 checks passed
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.

3 participants