MCPcopy
hub / github.com/mongodb/node-mongodb-native / afterEachLogging

Method afterEachLogging

test/tools/runner/config.ts:483–512  ·  view source on GitHub ↗
(ctx: Context)

Source from the content-addressed store, hash-verified

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/**

Callers 1

afterEachLoggingFunction · 0.80

Calls 3

errorMethod · 0.80
inspectMethod · 0.80
isMethod · 0.45

Tested by

no test coverage detected