Triple the speed of E2E tests and stop them exploding if a circular datastructure is logged (#8095)
* stop e2e tests exploding if a circular datastructure is logged it's valid for the webapp to log datastructures to the console which happen to be circular but the e2e test running explodes badly with a runtime exception and bombs out before logging anything or providing a sensible stacktrace. you can trap the exception though and get a sensible error however. * don't barf on circular refs in return vals either and log timestamps * log timestamps * speed up roomDir & E2EE tests by 3x use timeouts correctly, so the first set of scenarios take 42s to run rather than 2m21s * speed up space test by 20s
This commit is contained in:
parent
026ca1ab64
commit
b8b5dd82aa
7 changed files with 42 additions and 12 deletions
|
@ -57,11 +57,17 @@ export async function applyConfigChange(session: ElementSession, config: any): P
|
|||
|
||||
export async function serializeLog(msg: ConsoleMessage): Promise<string> {
|
||||
// 9 characters padding is somewhat arbitrary ("warning".length + some)
|
||||
let s = `${padEnd(msg.type(), 9, ' ')}| ${msg.text()} `; // trailing space is intentional
|
||||
let s = `${new Date().toISOString()} | ${ padEnd(msg.type(), 9, ' ')}| ${msg.text()} `; // trailing space is intentional
|
||||
const args = msg.args();
|
||||
for (let i = 0; i < args.length; i++) {
|
||||
const arg = args[i];
|
||||
const val = await arg.jsonValue();
|
||||
|
||||
let val;
|
||||
try {
|
||||
val = await arg.jsonValue();
|
||||
} catch (error) {
|
||||
val = `<error: ${error}>`;
|
||||
}
|
||||
|
||||
// We handle strings a bit differently because the `jsonValue` will be in a weird-looking
|
||||
// shape ("JSHandle:words are here"). Weirdly, `msg.text()` also catches text nodes that
|
||||
|
@ -96,7 +102,13 @@ export async function serializeLog(msg: ConsoleMessage): Promise<string> {
|
|||
}
|
||||
|
||||
// not an error, as far as we're concerned - return it as human-readable JSON
|
||||
return JSON.stringify(argInContext, null, 4);
|
||||
let ret;
|
||||
try {
|
||||
ret = JSON.stringify(argInContext, null, 4);
|
||||
} catch (error) {
|
||||
ret = `<error: ${error}>`;
|
||||
}
|
||||
return ret;
|
||||
});
|
||||
s += `${stringyArg} `; // trailing space is intentional
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue