Skip to content

Commit

Permalink
fix(test-utils): meaningful console logs for headless test (#252)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pessimistress authored Mar 8, 2024
1 parent 7e19850 commit f35a945
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions modules/test-utils/src/browser-automation/browser-test-driver.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// probe.gl, MIT license
/* eslint-disable camelcase */

import {ScreenshotOptions, Page} from 'puppeteer';
import {ScreenshotOptions, ConsoleMessage, Page} from 'puppeteer';
import fs from 'fs';
import {COLOR, addColor} from '@probe.gl/log';
import {COLOR} from '@probe.gl/log';
import diffImages, {DiffImagesOptions} from '../utils/diff-images';
import * as eventDispatchers from '../utils/puppeteer-events';
import BrowserDriver, {ServerConfiguration} from './browser-driver';
Expand Down Expand Up @@ -143,7 +143,7 @@ export default class BrowserTestDriver extends BrowserDriver {
}

/* eslint-disable no-console */
_onConsole(event) {
_onConsole(event: ConsoleMessage) {
if (!this.headless) {
// Do not mirror console messages if the browser is open
return;
Expand All @@ -161,12 +161,13 @@ export default class BrowserTestDriver extends BrowserDriver {
console.log(text);
break;

case 'warning':
console.log(addColor(text, COLOR.YELLOW));
case 'warn':
console.warn(text);
break;

case 'error':
console.log(addColor(text, COLOR.RED));
const errorObject = event.args()[0]?.remoteObject();
console.error(errorObject?.description || text);
break;

default:
Expand Down

0 comments on commit f35a945

Please sign in to comment.