I am using globalThis property specifically globalThis.scrollTo(0,0) in my React WebApp.
I am using Jest for unit testing alongwith Enzyme.
As of test cases fail as it is unable to identify globalThis and says that 'globalThis' is undefined.
Is there a way to introduce globalThis into the tests just like jsdom does for window etc ?
For Example
-- abc.tsx --
const abc: React.FC<CustomProps> = props => {
useEffect(() => {
globalThis?.scrollTo(0,0);
}
}
-- abcTest.tsx --
wrapper = mount(<abc/>);
mount produces error that "globalThis" is undefined