Repository navigation
Description
Describe the bug
Something about the viewport persists between test suite runs (using r to re-run), causing tests that depend on scrolling and IntersectionObserver 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 to getBoundingClientRect but the IntersectionObserver 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
cd examples/basic
npm install
npm run test test/suite.test.tsx
Test passes the first time, but hit r to run again and it fails.
System Info
System:
OS: macOS 15.3.1
CPU: (12) arm64 Apple M2 Max
Memory: 20.00 GB / 64.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.18.1 - ~/.asdf/installs/nodejs/20.18.1/bin/node
Yarn: 1.22.22 - /opt/homebrew/bin/yarn
npm: 10.8.2 - ~/.asdf/plugins/nodejs/shims/npm
pnpm: 9.5.0 - /opt/homebrew/bin/pnpm
Watchman: 2024.08.12.00 - /opt/homebrew/bin/watchman
Browsers:
Chrome: 134.0.6998.45
Firefox Nightly: 127.0
Safari: 18.3
npmPackages:
@vitest/browser: latest => 3.0.8
@vitest/ui: latest => 3.0.8
playwright: ^1.50.1 => 1.51.0
vite: latest => 6.2.1
vitest: latest => 3.0.8Used Package Manager
npm
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsApproved
Activity
test(scene): mobile (375px) two-column chat-shape snapshots
chore(citations): sweep code-comment citations to the address grammarβ¦