How to render PhotoAlbum in jest tests #113
|
PhotoAlbum doesn't render any photos in jest tests. |
Answered by
igordanchenko
May 15, 2023
Replies: 1 comment
|
This is happening because jsdom sets all elements' beforeAll(() => {
jest
.spyOn(HTMLElement.prototype, "clientWidth", "get")
.mockImplementation(function () {
return (this.className || "").split(" ").includes("react-photo-album")
? 800
: 0;
});
}); |
0 replies
Answer selected by
igordanchenko
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is happening because jsdom sets all elements'
clientWidthto 0. You can overcome this limitation with the following mock.