Replies: 1 comment
-
@trajano I believe the right syntax for Vitest is: const spy = vi.spyOn(Element.prototype, 'scrollIntoView');
const wrapper = mount(TestComponent);
button.click()
expect(spy).toHaveBeenCalled(); In order for it to work the element with Another way which works after it was appended is to query selector the element: const wrapper = mount(TestComponent);
const element = document.querySelector('.myElement');
const spy = vi.spyOn(element, 'scrollIntoView');
button.click()
expect(spy).toHaveBeenCalled(); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Right now in vitest I do something like this
But I was wondering if there was a way of doing it without modifying the prototype
Beta Was this translation helpful? Give feedback.
All reactions