You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Trying to migrate a test from jest to vitest. I have a use case where we are listening for message events on window, and I want to verify calls to the listener with a spy.
The provided reproduction shows two scenarios. One where the I call vi.spyOn before the event listener is added and the second where event listener is added first. The listener is called and runs in both cases but the spy only counts if the spy was created before adding to window.
This behavior seems unintuitive at best and like an error in the worst case.
Describe the bug
Trying to migrate a test from jest to vitest. I have a use case where we are listening for message events on window, and I want to verify calls to the listener with a spy.
The provided reproduction shows two scenarios. One where the I call
vi.spyOn
before the event listener is added and the second where event listener is added first. The listener is called and runs in both cases but the spy only counts if the spy was created before adding towindow
.This behavior seems unintuitive at best and like an error in the worst case.
Reproduction
https://stackblitz.com/edit/vitest-dev-vitest-t28wegld?file=test%2Fbasic.test.ts
System Info
Used Package Manager
yarn
Validations
The text was updated successfully, but these errors were encountered: