Mocking the DOM during tests

In tests, please, __mocks__ the DOM, please!

Either mock things that doesn't exist. Which should make more sense, because _urq is window spoiled by userReport script. We could mock in manual mock the UserReport provider. That thing should be tested already.

But talking about that, what if the script is blocking and or broken, would it break our stuff too.

How about we provide our own tracking method, that then passes it (because we can listen to those events) and delegate them internally to that external tracker.

// file __mocks__/dom.ts
import { JSDOM } from 'jsdom'
const dom = new JSDOM()
global.document = dom.window.document
global.window = dom.window
// So that calling document, or window during tests will use that instance of JSDOM

See how to mock the DOM with Jest manual mocks.