testing: fix undefined not being reported correctly in results

Fixes #125669
This commit is contained in:
Connor Peet 2021-07-07 14:57:41 -07:00
parent 6e35422648
commit c6d7cfed8a
No known key found for this signature in database
GPG key ID: CF8FD2EA0DBC61BD

View file

@ -224,6 +224,10 @@ function serializeError(err) {
function safeStringify(obj) {
const seen = new Set();
return JSON.stringify(obj, (key, value) => {
if (value === undefined) {
return '[undefined]';
}
if (isObject(value) || Array.isArray(value)) {
if (seen.has(value)) {
return '[Circular]';