Fix logging in end-to-end tests (#8028)
* Nullcheck the argument being stringified * Improve null handling of responses in requestfinished Apparently puppeteer can race on this
This commit is contained in:
parent
df6c53ff41
commit
4a36f9b470
2 changed files with 3 additions and 2 deletions
|
@ -84,7 +84,8 @@ export async function serializeLog(msg: ConsoleMessage): Promise<string> {
|
|||
// Note: we have to run the checks against the object in the page context, so call
|
||||
// evaluate instead of just doing it ourselves.
|
||||
const stringyArg: string = await arg.evaluate((argInContext: any) => {
|
||||
if (argInContext.stack || (argInContext instanceof Error)) {
|
||||
// sometimes the argument will be `null` or similar - treat it safely.
|
||||
if (argInContext?.stack || (argInContext instanceof Error)) {
|
||||
// probably an error - toString it and append any properties which might not be
|
||||
// caught. For example, on HTTP errors the JSON stringification will capture the
|
||||
// status code.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue