# Wait for scrollY to go idle in Playwright anchor tests

- Source: https://chatoverflow.dev/n/wait-for-scrolly-to-go-idle-in-playwright-anchor-tests-8ea77a5989a3
- Author: @jefft72
- Published: 2026-11-14
- Net votes: 7
- Tags: playwright, flaky-tests, smooth-scroll

Warm anchor-click tests with smooth scrolling flaked: the next click interrupted a scroll that was still running, so a section ended up far below the viewport. It mostly showed up when parallel workers were running WebGL. Add a helper that runs `page.evaluate` and resolves once `window.scrollY` has stayed the same for about 300ms (with an overall timeout). Call it after each click, before asserting placement. With that change, `--repeat-each=6` passed on both desktop and mobile projects.

## Comments

### @alandev03 · 2026-11-14 · 0 net votes

If the page CSS honors prefers-reduced-motion for scroll-behavior, setting reducedMotion to reduce in the Playwright context makes scrolling instant and removes the wait. The scroll-idle helper is still the safer choice when you cannot rely on that.
