vitest icon indicating copy to clipboard operation
vitest copied to clipboard

page.screenshot is extremely low resolution with a large viewport

Open KaelWD opened this issue 1 month ago • 2 comments

Describe the bug

Running browser tests with playwright and viewport: { width: 1280, height: 800 }

This is unusable, the page is taller than 800px so everything else gets cropped off:

await page.viewport(600, 800)
await page.screenshot()

This captures the full page but #6512 scales it down to only 42px wide when the scrollHeight is 9300:

await page.viewport(600, document.body.scrollHeight)
await page.screenshot()

Reproduction

https://stackblitz.com/edit/vitest-dev-vitest-tszdoqkx

System Info

System:
    OS: Linux 6.17 Ubuntu 25.10 25.10 (Questing Quokka)
    CPU: (16) x64 AMD Ryzen 7 5700X3D 8-Core Processor
    Memory: 9.52 GB / 31.27 GB
    Container: Yes
    Shell: 4.0.6 - /usr/bin/fish
  Binaries:
    Node: 24.11.1 - /run/user/1000/fnm_multishells/437459_1764264127836/bin/node
    npm: 11.6.2 - /run/user/1000/fnm_multishells/437459_1764264127836/bin/npm
    pnpm: 10.23.0 - /run/user/1000/fnm_multishells/437459_1764264127836/bin/pnpm
  Browsers:
    Chrome: 142.0.7444.175
    Firefox: 145.0.1
    Firefox Developer Edition: 145.0.1

Used Package Manager

pnpm

Validations

KaelWD avatar Nov 28 '25 07:11 KaelWD

I've got a similar issue, but attempting to get a screenshot of a specific element (a custom component) within the iFrame. The iFrame and the Element have dimensions of 1920x1080 (just something so the zoom takes affect). The Vitest UI shows a calculated zoom of 28%. The screenshot dimensions are 547x308 and not the desired full fidelity screenshot.

Maybe the screenshot code needs to unset any zoom before capturing?

Alanoll avatar Nov 28 '25 17:11 Alanoll

Also encountering this issue

toakleaf avatar Dec 02 '25 14:12 toakleaf