Skip to content

[Bug]: toHaveScreenshot fails in Github workflow #36228

Open
@AntonioVentilii

Description

@AntonioVentilii

Version

^1.52.0

Steps to reproduce

A simple Github workflow that runs some E2E tests, inside of which there is

expect(...). toHaveScreenshot()

Complete CI here: https://github.com/dfinity/oisy-wallet/actions/runs/15471499824/job/43556862674

Expected behavior

I expect it to create a screenshot at the first try, without errors.

Actual behavior

It fails with error:

TypeError: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined
    at Object.writeFileSync (node:fs:2435:5)
    at writeFileSync (/home/runner/work/oisy-wallet/oisy-wallet/node_modules/playwright/lib/matchers/toMatchSnapshot.js:333:21)
    at writeFiles (/home/runner/work/oisy-wallet/oisy-wallet/node_modules/playwright/lib/matchers/toMatchSnapshot.js:314:5)
    at Object.toHaveScreenshot (/home/runner/work/oisy-wallet/oisy-wallet/node_modules/playwright/lib/matchers/toMatchSnapshot.js:327:12)
    at HomepageLoggedIn.Homepage.takeScreenshotWithRetry (file:///home/runner/work/oisy-wallet/oisy-wallet/e2e/utils/pages/homepage.page.ts:497:5)
    at HomepageLoggedIn.takeScreenshot (file:///home/runner/work/oisy-wallet/oisy-wallet/e2e/utils/pages/homepage.page.ts:543:4)
    at file:///home/runner/work/oisy-wallet/oisy-wallet/e2e/homepage.spec.ts:22:2
    at /home/runner/work/oisy-wallet/oisy-wallet/node_modules/playwright/lib/worker/workerMain.js:304:9
    at /home/runner/work/oisy-wallet/oisy-wallet/node_modules/playwright/lib/worker/testInfo.js:277:11
    at TimeoutManager.withRunnable (/home/runner/work/oisy-wallet/oisy-wallet/node_modules/playwright/lib/worker/timeoutManager.js:67:14)
    at TestInfoImpl._runWithTimeout (/home/runner/work/oisy-wallet/oisy-wallet/node_modules/playwright/lib/worker/testInfo.js:275:7)
    at /home/runner/work/oisy-wallet/oisy-wallet/node_modules/playwright/lib/worker/workerMain.js:302:7
    at WorkerMain._runTest (/home/runner/work/oisy-wallet/oisy-wallet/node_modules/playwright/lib/worker/workerMain.js:277:5)
    at WorkerMain.runTestGroup (/home/runner/work/oisy-wallet/oisy-wallet/node_modules/playwright/lib/worker/workerMain.js:193:11)
    at process.<anonymous> (/home/runner/work/oisy-wallet/oisy-wallet/node_modules/playwright/lib/common/process.js:70:22) {
...

Additional context

  • It is completely random: some tests raises it, some others no. it is not test dependent (already checked).
  • No issue running it locally.
  • The element being snapshot is not undefined (already checked).
  • The element being snapshot is either Page or Locator.
  • Workaround: if we retry it does not raise an error (at the 3rd try or something similar).

Environment

It happens only in CI Github action with ubuntu-24.04

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions