-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
testkit: Enable browser tests log on terminal (#1181)
Introduce a Console message in the protocol between the LocalController on Browser and the RemoteController in Node for enabling the logs and other console messages to be printed in terminal and be available in artifacts. This feature should help debugging the errors in the testing pipeline.
- Loading branch information
Showing
5 changed files
with
50 additions
and
8 deletions.
There are no files selected for viewing
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,31 @@ | ||
import { response } from './responses' | ||
|
||
const originalConsole = console | ||
|
||
export default { | ||
install: (channel) => { | ||
// eslint-disable-next-line no-global-assign | ||
console = new Proxy({}, { | ||
get: (_, method) => (...args) => { | ||
originalConsole[method].apply(originalConsole, args) | ||
channel.writeResponse(null, response('Console', { | ||
method, | ||
args | ||
}), true) | ||
} | ||
}) | ||
}, | ||
handleConsole: (message) => { | ||
if (message.response.name === 'Console') { | ||
const { method, args } = message.response.data | ||
args[0] = typeof args[0] === 'string' ? `[RemoteConsole] ${args[0]}` : args[0] | ||
console[method].apply(console, args) | ||
return true | ||
} | ||
return false | ||
}, | ||
uninstall: () => { | ||
// eslint-disable-next-line no-global-assign | ||
console = originalConsole | ||
} | ||
} |
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