This snippet:
```
import { window } from 'global';
```
will let you mock window variables in Jest tests.
However, it breaks hot module reloading in Vite,
because Vite injects code snippets in top of every
file:
```
window.STUFF = 'Vite injected some HMR code here';
import { window } from 'global';
// this fails: Uncaught ReferenceError: Cannot access 'window' before initialization
```
The simple solution is to rename `window` when importing it:
```
import { window as globalWindow } from 'global';
globalWindow.alert('hello world');
```
The code works like before, but Vite will be able to
inject its code snippet without interfering with the
rest of the code.