Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Fix logging in end-to-end tests #8028

Merged
merged 2 commits into from
Mar 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/end-to-end-tests/src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class ElementSession {
"requestfinished", async (req: puppeteer.HTTPRequest) => {
const type = req.resourceType();
const response = await req.response();
return `${type} ${response.status()} ${req.method()} ${req.url()} \n`;
return `${type} ${response?.status() ?? '<no response>'} ${req.method()} ${req.url()} \n`;
});
this.log = new Logger(this.username);
}
Expand Down
3 changes: 2 additions & 1 deletion test/end-to-end-tests/src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down