mocking document.domain and other objects in jest

I am trying to run tests in jest at the moment, at the moment I am getting an error that looks like this,

TypeError: Cannot read property 'indexOf' of undefined

      194 |     if (this.config.storage_host) {
      195 |       domain = this.config.storage_host;
    > 196 |     } else if (document.domain.indexOf("example") > 0) {
          |                                ^
      197 |       let domainParts: string[] = document.domain.split(".");
      198 |       domainParts.splice(0, 1);
      199 |       domain = domainParts.join(".");

The problem it would seem is that document.domain is undefined, how would I go about creating a document.domain for the tests? I assume I would mock it somehow, I have tried,

    Object.defineProperty(document, 'domain' {
        writable: true,
        value: 'https://www.example.com'
    });

but that did not make any change. I will also need to mock an object that is used throughout the application how would I go about that? The object is called ProvideState and has attributes like,

const ProvideState = {
    state: {
        app: 'client'
        context: '',
   }
}