viewport does not reset between test suite runs in headless browser mode #7649
Labels
feat: browser
Issues and PRs related to the browser runner
p3-minor-bug
An edge case that only affects very specific usage (priority)
Describe the bug
Something about the viewport persists between test suite runs (using
r
to re-run), causing tests that depend on scrolling andIntersectionObserver
to fail if the suite re-runs. Only fails in headless browser mode, it passes in headed mode.Reproduction
The test in the repro uses
IntersectionObserver
to detect when something comes into the viewport. The test checks that the top element is visible and scrolled to, then scrolls to the bottom and checks that the bottom element is visible and scrolled to. When re-running the suite, however, the top element appears to be visible according togetBoundingClientRect
but theIntersectionObserver
does not fire. Scrolling to the first element at the start of the test "fixes" this.repro branch: https://github.com/kwojcik/vitest/tree/viewportBug
Test passes the first time, but hit
r
to run again and it fails.System Info
Used Package Manager
npm
Validations
The text was updated successfully, but these errors were encountered: