function globalWithDocumentOnWhichDynamicchunkScriptExists() {
  return {
    console,
    setTimeout: (fn, ms) => {
      // avoid leaving the test runner hanging 
      return setTimeout(fn, ms).unref()
    },
    clearTimeout,
    document: {
      getElementsByTagName: () => [
        {
          getAttribute: (attr) => {
            if (attr === 'src') {
              return 'dynamicchunk.js'
            }
          },
        },
      ], // makes webpack consider looking up the chunk without loading it dynamically
    },
  }
}
Creates a global object with a document object that pretends to contain the
chunk script. Includes timeouts to get to the point where the script is
considered present.