ci: make console.warn work in tests (#18771)
This commit is contained in:
parent
390e7f5719
commit
29decbdd4d
3 changed files with 28 additions and 10 deletions
|
@ -39,11 +39,14 @@
|
|||
|
||||
// Rediret all output to browser.
|
||||
if (isCi) {
|
||||
global.__defineGetter__('console', function () {
|
||||
return {
|
||||
log: (...args) => ipcRenderer.send('console.log', args),
|
||||
error: (...args) => ipcRenderer.send('console.error', args)
|
||||
const fakeConsole = {}
|
||||
for (const k in console) {
|
||||
if (console.hasOwnProperty(k) && k !== 'assert') {
|
||||
fakeConsole[k] = (...args) => ipcRenderer.send('console-call', k, args)
|
||||
}
|
||||
}
|
||||
global.__defineGetter__('console', function () {
|
||||
return fakeConsole
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -52,16 +52,15 @@ if (process.platform !== 'darwin') {
|
|||
|
||||
// Write output to file if OUTPUT_TO_FILE is defined.
|
||||
const outputToFile = process.env.OUTPUT_TO_FILE
|
||||
const print = function (_, args) {
|
||||
const print = function (_, method, args) {
|
||||
const output = util.format.apply(null, args)
|
||||
if (outputToFile) {
|
||||
fs.appendFileSync(outputToFile, output + '\n')
|
||||
} else {
|
||||
console.error(output)
|
||||
console[method](output)
|
||||
}
|
||||
}
|
||||
ipcMain.on('console.log', print)
|
||||
ipcMain.on('console.error', print)
|
||||
ipcMain.on('console-call', print)
|
||||
|
||||
ipcMain.on('process.exit', function (event, code) {
|
||||
process.exit(code)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue