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T use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","const deepAssign = require('deep-assign');\n\nconst log = require('loglevel');\nconst unmirror = require('chrome-unmirror');\n\nconst createInstance = require('./lib/instance');\nconst connectClient = require('./lib/client');\nconst EventBus = require('./lib/event-bus');\nconst chromeOut = require('./lib/chrome-out');\nconst network = require('./lib/network');\n\nprocess.on('unhandledRejection', (error) => {\n  const { error: stderr } = console;\n  // this should always output to console.error, regardless of loglevel\n  stderr('Promise Rejection: ', error);\n});\n\nclass MochaChrome {\n  constructor(options) {\n    // eslint-disable-next-line no-param-reassign\n    options = deepAssign(\n      {\n        chromeFlags: [],\n        chromeLauncher: {},\n        loadTimeout: 1000,\n        logLevel: 'error',\n        ignoreExceptions: false,\n        ignoreConsole: false,\n        ignoreResourceErrors: false,\n        mocha: {\n          reporter: 'spec',\n          ui: 'bdd',\n          useColors: true\n        }\n      },\n      options\n    );\n\n    log.setDefaultLevel('error');\n    log.setLevel(options.logLevel);\n\n    const bus = new EventBus(log);\n\n    if (!options.url) {\n      this.fail('`options.url` must be specified to run tests');\n    }\n\n    bus.on('ready', (/* content */) => {\n      this.client.Runtime.evaluate({ expression: `mocha.setup({ reporter: 'spec' })` });\n    });\n\n    bus.on('mocha', (content) => {\n      process.stdout.write(content);\n    });\n\n    bus.on('width', (/* content */) => {\n      // eslint-disable-next-line no-bitwise\n      const columns = (parseInt(process.env.COLUMNS || process.stdout.columns, 10) * 0.75) | 0;\n      const expression = `Mocha.reporters.Base.window.width = ${columns};`;\n\n      this.client.Runtime.evaluate({ expression });\n    });\n\n    bus.on('config', (/* content */) => {\n      const config = JSON.stringify(options.mocha);\n      const expression = `mocha.setup(${config})`;\n\n      this.client.Runtime.evaluate({ expression });\n    });\n\n    bus.on('started', (tests) => {\n      this.started = true;\n      log.info(`Test Run Started - Running ${tests} Tests\\n`);\n\n      if (tests === 0) {\n        this.fail('mocha.run() was called with no tests');\n      }\n    });\n\n    bus.on('ended', (stats) => {\n      this.ended = true;\n      this.exit(stats.failures);\n    });\n\n    bus.on('resourceFailed', (/* data */) => {\n      this.loadError = true;\n    });\n\n    this.bus = bus;\n    this.options = options;\n    this.loadError = false;\n  }\n\n  async connect() {\n    const instance = await createInstance(log, this.options);\n    const client = await connectClient(instance, log, this.options);\n    const { DOMStorage, Network, Runtime } = client;\n\n    if (!client) {\n      this.fail('CDP Client could not connect');\n      return;\n    }\n\n    this.bus.watch(DOMStorage);\n\n    chromeOut(log, this.options, Runtime);\n    network(this.bus, log, Network, this.options.ignoreResourceErrors);\n\n    this.client = client;\n    this.instance = instance;\n  }\n\n  async run() {\n    this.client.Page.loadEventFired(() => {\n      if (this.closed) {\n        return;\n      }\n\n      if (this.loadError) {\n        this.fail(`Failed to load the page. Check the url: ${this.options.url}`);\n        return;\n      }\n\n      setTimeout(async () => {\n        if (this.closed) {\n          return;\n        }\n\n        const expression = '(function () { return !!window.mocha; })()';\n        const res = await this.client.Runtime.evaluate({ expression });\n\n        if (!unmirror(res.result)) {\n          this.fail(\n            `mocha was not found in the page within ${this.options.loadTimeout}ms of the page loading.`\n          );\n        }\n\n        if (!this.started) {\n          this.fail(\n            `mocha.run() was not called within ${this.options.loadTimeout}ms of the page loading.`\n          );\n        }\n      }, this.options.loadTimeout);\n    });\n\n    await this.client.Page.navigate({ url: this.options.url });\n  }\n\n  on(name, fn) {\n    this.bus.on(name, fn);\n  }\n\n  fail(message) {\n    log.error('Mocha-Chrome Failed:', message || '');\n\n    if (this.bus) {\n      this.bus.emit('failure', message);\n    }\n\n    this.exit(1);\n  }\n\n  async exit(/* code */) {\n    this.closed = true;\n    await this.client.close();\n    await this.instance.kill();\n\n    this.bus.emit('exit', 1);\n  }\n}\n\nmodule.exports = MochaChrome;\n"]}