Last active
July 14, 2023 16:33
-
-
Save araphiel/20b970b4a41b0fb8ff150124f24233d2 to your computer and use it in GitHub Desktop.
simple jest viewport resizer
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
/** note: jest global.innerWidth defaults to 1024px */ | |
const resizeJestViewport = (breakpoint: Breakpoints) => { | |
act(() => { | |
let width; | |
switch (breakpoint) { | |
case "desktop": | |
width = 1200; | |
break; | |
case "tablet": | |
width = 768; | |
break; | |
case "mobile": | |
width = 500; | |
break; | |
default: | |
width = 1024; | |
} | |
global.innerWidth = width; | |
global.dispatchEvent(new Event("resize")); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment