-
Notifications
You must be signed in to change notification settings - Fork 210
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix logging in electron certa tests.
Essentially just reacting to this change in mocha: mochajs/mocha#3725
- Loading branch information
Showing
5 changed files
with
45 additions
and
23 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
common/changes/@bentley/certa/fix-certa-logging_2021-05-10-15-46.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"changes": [ | ||
{ | ||
"packageName": "@bentley/certa", | ||
"comment": "", | ||
"type": "none" | ||
} | ||
], | ||
"packageName": "@bentley/certa", | ||
"email": "33036725+wgoehrig@users.noreply.github.com" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Bentley Systems, Incorporated. All rights reserved. | ||
* See LICENSE.md in the project root for license terms and full copyright notice. | ||
*--------------------------------------------------------------------------------------------*/ | ||
// NB: This file is not a CommonJs module - it needs to run in the browser. Do not import or export modules here! | ||
|
||
declare let _CertaConsole: undefined | ((name: string, args: any[]) => void); // eslint-disable-line @typescript-eslint/naming-convention | ||
|
||
// Redirect all console output back to the main (backend) process, if necessary | ||
if (typeof _CertaConsole !== "undefined") { | ||
function forwardConsole(name: keyof typeof console) { | ||
const original = console[name]; | ||
console[name] = (...args: any[]) => { | ||
_CertaConsole!(name, args); | ||
// Also preserve the original behavior. This way, test progress is reported in both the backend _and_ frontend processes. | ||
// This helps keep the output readable when debugging the frontend. | ||
original.apply(console, args); | ||
}; | ||
} | ||
forwardConsole("log"); | ||
forwardConsole("error"); | ||
forwardConsole("dir"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters