Skip to content

fix(expect): if actual snapshot happens to not exist, don't crash #36234

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

agg23
Copy link
Contributor

@agg23 agg23 commented Jun 6, 2025

Fixes the crashing component of #36228.

page._expectScreenshot() has complicated logic to determine its return value and the returned type is not as typesafe as it should be. Under certain race conditions it is possible to timeout while still successfully taking a screenshot (similar to #36181).

Address the symptom and prevent Playwright from crashing when actual is nullish.

@agg23 agg23 requested a review from dgozman June 6, 2025 17:15
Copy link
Contributor

github-actions bot commented Jun 6, 2025

Test results for "tests 1"

1 failed
❌ [webkit-library] › library/screenshot.spec.ts:205:14 › element screenshot › element screenshot should work with a mobile viewport @webkit-ubuntu-22.04-node18

6 flaky ⚠️ [firefox-library] › library/inspector/cli-codegen-1.spec.ts:986:7 › cli codegen › should not throw csp directive violation errors @firefox-ubuntu-22.04-node18
⚠️ [playwright-test] › ui-mode-test-ct.spec.ts:59:5 › should run component tests after editing test @macos-latest-node18-1
⚠️ [webkit-library] › library/browsercontext-viewport-mobile.spec.ts:97:5 › mobile viewport › should fire orientationchange event @webkit-ubuntu-22.04-node18
⚠️ [webkit-library] › library/video.spec.ts:475:5 › screencast › should scale frames down to the requested size @webkit-ubuntu-22.04-node18
⚠️ [webkit-page] › page/page-screenshot.spec.ts:345:5 › page screenshot › should work while navigating @webkit-ubuntu-22.04-node18
⚠️ [playwright-test] › ui-mode-test-watch.spec.ts:145:5 › should watch all @windows-latest-node18-1

39351 passed, 820 skipped
✔️✔️✔️

Merge workflow run.

AntonioVentilii added a commit to dfinity/oisy-wallet that referenced this pull request Jun 12, 2025
# Motivation

The E2E tests are failing when the screenshot already exists. It is a
race-condition issue with playwright (see
[issue](microsoft/playwright#36228) and
[fix-PR](microsoft/playwright#36234)).

So, it may happen that the screenshot is partially saved and the test
fails.

Since the fix will only be released in v1.54 of playwright (see [comment
in issue
thread](microsoft/playwright#36228 (comment))),
and we need to move forward with the tests, for now we ignore eventual
errors given by screenshots, accepting even partial screenshots.

At the same time, we left behind a few fixes to make the screenshots
work.

# Changes

- Wrap `toHaveScreenshot` into a try-catch statement that ignores any
error.
- Fix test id for token groups.
- Revert II playwright to latest non-breaking-changes version (we will
tackle the breaking-changes with a bump in another PR).
- Skip `rewards` page tests: we have a new `earn` page in staging that
requires its own E2E tests.

# Tests

Screenshots are being saved too.

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
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