Last active
November 27, 2024 14:05
-
-
Save jimkeller/9a3946f3ca7841625d3d9167a0ed72f8 to your computer and use it in GitHub Desktop.
mocking getBoundingClientRect in jest
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const my_element = document.getElementById('#my-element) | |
jest.spyOn(my_element, "getBoundingClientRect").mockImplementation( | |
() => { | |
return new DOMRect(0, 0, 100, 500) //100px wide, 500px tall | |
} | |
) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment