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UAAU,IAAU;YAClB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;YAClD,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;YACnE,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC1C,IAAI,CAAC,OAAO,EAAE,CAAC;QACjB,CAAC;QAEO,qBAAO,GAAf;YACE,eAAM,CAAC,QAAQ,CACb,CAAC,EACD,IAAI,CAAC,QAAQ,CAAC,eAAgB,CAAC,YAAY;gBACzC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,YAAY,CAClC,CAAC;QACJ,CAAC;QAlGD;YADC,uBAAY,EAAE;wCAOd;QAGD;YADC,uBAAY,EAAE;2CAmBd;QAGD;YADC,uBAAY,EAAE;6CAkBd;QAGD;YADC,uBAAY,EAAE;0CAiCd;QAGD;YADC,uBAAY,EAAE;4CAMd;QASH,UAAC;KAAA,AAjHD,CAAiC,kBAAQ,GAiHxC;sBAjHoB,GAAG","sourcesContent":["import { global } from '@theintern/common';\nimport { Executor } from '../executors/Executor';\nimport Reporter, { eventHandler, ReporterProperties } from './Reporter';\nimport Suite from '../Suite';\nimport Test from '../Test';\n\n/**\n * The Dom reporter outputs text into the DOM, essentially treating it like the\n * console.\n */\nexport default class Dom extends Reporter {\n document: HTMLDocument;\n\n suiteNode: HTMLElement;\n\n testNode: HTMLElement | undefined;\n\n constructor(executor: Executor, options: DomOptions = {}) {\n super(executor, options);\n this.document = options.document || document;\n this.suiteNode = options.suiteNode || this.document.body;\n }\n\n @eventHandler()\n error(error: Error) {\n const errorNode = this.document.createElement('pre');\n errorNode.appendChild(\n this.document.createTextNode(this.formatError(error))\n );\n this.document.body.appendChild(errorNode);\n }\n\n @eventHandler()\n suiteEnd(suite: Suite) {\n this.suiteNode = <HTMLElement>(\n (this.suiteNode!.parentNode!.parentNode || this.document.body)\n );\n\n if (suite.error) {\n this.suiteNode.appendChild(\n this.document.createTextNode('Suite \"' + suite.id + '\" failed')\n );\n this.suiteNode.style.color = 'red';\n\n const errorNode = this.document.createElement('pre');\n errorNode.appendChild(\n this.document.createTextNode(this.formatError(suite.error))\n );\n this.suiteNode.appendChild(errorNode);\n this._scroll();\n }\n }\n\n @eventHandler()\n suiteStart(suite: Suite) {\n const oldSuiteNode = this.suiteNode;\n this.suiteNode = this.document.createElement('ol');\n\n if (oldSuiteNode === this.document.body) {\n oldSuiteNode.appendChild(this.suiteNode);\n } else {\n const outerSuiteNode = this.document.createElement('li');\n const headerNode = this.document.createElement('div');\n\n headerNode.appendChild(this.document.createTextNode(suite.name!));\n outerSuiteNode.appendChild(headerNode);\n outerSuiteNode.appendChild(this.suiteNode);\n oldSuiteNode.appendChild(outerSuiteNode);\n }\n\n this._scroll();\n }\n\n @eventHandler()\n testEnd(test: Test) {\n if (test.skipped) {\n const testNode = (this.testNode = this.document.createElement('li'));\n testNode.appendChild(\n this.document.createTextNode(\n test.name +\n ' skipped' +\n (test.skipped ? ' (' + test.skipped + ')' : '')\n )\n );\n testNode.style.color = 'gray';\n this.suiteNode.appendChild(testNode);\n } else if (test.error) {\n const testNode = this.testNode!;\n testNode.appendChild(\n this.document.createTextNode(' failed (' + test.timeElapsed + 'ms)')\n );\n testNode.style.color = 'red';\n\n const errorNode = this.document.createElement('pre');\n errorNode.appendChild(\n this.document.createTextNode(this.formatError(test.error))\n );\n testNode.appendChild(errorNode);\n } else {\n const testNode = this.testNode!;\n testNode.appendChild(\n this.document.createTextNode(' passed (' + test.timeElapsed + 'ms)')\n );\n testNode.style.color = 'green';\n }\n this._scroll();\n }\n\n @eventHandler()\n testStart(test: Test) {\n this.testNode = this.document.createElement('li');\n this.testNode.appendChild(this.document.createTextNode(test.name));\n this.suiteNode.appendChild(this.testNode);\n this._scroll();\n }\n\n private _scroll() {\n global.scrollTo(\n 0,\n this.document.documentElement!.scrollHeight ||\n this.document.body.scrollHeight\n );\n }\n}\n\nexport interface DomProperties extends ReporterProperties {\n document: Document;\n suiteNode: HTMLElement;\n}\n\nexport type DomOptions = Partial<DomProperties>;\n"]} |