diff --git a/src/lib/executors/Browser.ts b/src/lib/executors/Browser.ts index cf58e66cf..b5c8d6a5e 100644 --- a/src/lib/executors/Browser.ts +++ b/src/lib/executors/Browser.ts @@ -59,7 +59,7 @@ export default class Browser extends Executor { this.registerReporter('dom', (options) => new Dom(this, options)); this.registerReporter( 'console', - (options) => new ConsoleReporter(this, options) + (options) => new ConsoleReporter(this, options, this.config.debug) ); if (options) { diff --git a/src/lib/reporters/Console.ts b/src/lib/reporters/Console.ts index fa8030397..e9ed3095c 100644 --- a/src/lib/reporters/Console.ts +++ b/src/lib/reporters/Console.ts @@ -8,11 +8,17 @@ import Reporter, { eventHandler, ReporterOptions } from './Reporter'; */ export default class ConsoleReporter extends Reporter { private _hasGrouping: boolean; + private _debugLogs: boolean; private _testId: keyof Test; - constructor(executor: Executor, options: ReporterOptions = {}) { + constructor( + executor: Executor, + options: ReporterOptions = {}, + debugLogs: boolean = false + ) { super(executor, options); this._hasGrouping = 'group' in this.console && 'groupEnd' in this.console; + this._debugLogs = debugLogs; this._testId = this._hasGrouping ? 'name' : 'id'; } @@ -22,6 +28,13 @@ export default class ConsoleReporter extends Reporter { this.console.error(this.formatError(error)); } + @eventHandler() + log(data: any) { + if (this._debugLogs) { + this.console.log(data); + } + } + @eventHandler() suiteEnd(suite: Suite) { // IE<10 does not provide a global console object when Developer Tools