Skip to content

Commit 0912e8e

Browse files
committed
Tweak puppeteer logging
1 parent 711905f commit 0912e8e

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

test-puppeteer.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,14 @@ puppeteer
3232
const page = await browser.newPage()
3333
page
3434
.on('console', async message => {
35-
let text = message.text()
36-
const args = await Promise.all(message.args().map(arg => describe(arg)))
37-
for (let i = 0; i < args.length; ++i) {
38-
text += `[${i}] ${args[i]} `
39-
}
40-
console.log(`${message.type().substr(0, 3).toUpperCase()} ${text}`)
35+
const argsText = await Promise.all(
36+
message.args().map(arg => describe(arg)),
37+
).join(' ')
38+
console.log(`${message.type().substr(0, 3).toUpperCase()} ${argsText}`)
4139
if (
4240
autoCloseBrowser &&
4341
message.type() === 'error' &&
44-
text.startsWith('fail!')
42+
message.text().startsWith('fail!')
4543
) {
4644
browser.close()
4745
process.exit(1)
@@ -73,7 +71,6 @@ puppeteer
7371

7472
function describe(jsHandle) {
7573
return jsHandle.executionContext().evaluate(obj => {
76-
// serialize |obj| however you want
77-
return `OBJ: ${typeof obj}, ${obj}`
74+
return `${obj}`
7875
}, jsHandle)
7976
}

0 commit comments

Comments
 (0)