Dispatches a scroll event to the window (without `act()`).
()
| 291 | |
| 292 | /** Dispatches a scroll event to the window (without `act()`). */ |
| 293 | function dispatchWindowScroll() { |
| 294 | const event = new window.Event("scroll", { bubbles: true }); |
| 295 | // Vitest's jsdom environment aliases the global `window` to `globalThis`, so the |
| 296 | // `currentTarget` of an event bubbling up to the (internal) jsdom Window is not `=== window`. |
| 297 | // Report the global `window` as the current target so that the scroll listeners recognize it. |
| 298 | Object.defineProperty(event, "currentTarget", { get: () => window }); |
| 299 | document.dispatchEvent(event); |
| 300 | } |
| 301 | |
| 302 | /** |
| 303 | * Mocks scrolling the window: `scrollX`/`scrollY` (initially 0), `innerHeight`/`innerWidth` and `scrollTo()` |
no outgoing calls
no test coverage detected