(ctx: Context)
| 481 | } |
| 482 | |
| 483 | afterEachLogging(ctx: Context) { |
| 484 | if (this.loggingEnabled && ctx.currentTest.state === 'failed') { |
| 485 | for (const log of this.logs) { |
| 486 | console.error( |
| 487 | JSON.stringify( |
| 488 | log, |
| 489 | function (_, value) { |
| 490 | if (types.isMap(value)) return { Map: Array.from(value.entries()) }; |
| 491 | if (types.isSet(value)) return { Set: Array.from(value.values()) }; |
| 492 | if (types.isNativeError(value)) return { [value.name]: util.inspect(value) }; |
| 493 | if (typeof value === 'bigint') return { bigint: new Long(value).toExtendedJSON() }; |
| 494 | if (typeof value === 'symbol') return `Symbol(${value.description})`; |
| 495 | if (typeof value === 'number') { |
| 496 | if (Number.isNaN(value) || !Number.isFinite(value) || Object.is(value, -0)) |
| 497 | // @ts-expect-error: toExtendedJSON internal on double but not on long |
| 498 | return { number: new Double(value).toExtendedJSON() }; |
| 499 | } |
| 500 | if (Buffer.isBuffer(value)) |
| 501 | return { [value.constructor.name]: Buffer.prototype.base64Slice.call(value) }; |
| 502 | if (value === undefined) return { undefined: 'key was set but equal to undefined' }; |
| 503 | return value; |
| 504 | }, |
| 505 | 0 |
| 506 | ) |
| 507 | ); |
| 508 | } |
| 509 | } |
| 510 | this.loggingEnabled = false; |
| 511 | this.logs = []; |
| 512 | } |
| 513 | } |
| 514 | |
| 515 | /** |
no test coverage detected