MCPcopy
hub / github.com/jestjs/jest / formatStack

Function formatStack

packages/expect/src/toThrowMatchers.ts:458–479  ·  view source on GitHub ↗
(thrown: Thrown | null)

Source from the content-addressed store, hash-verified

456};
457
458const formatStack = (thrown: Thrown | null) => {
459 if (thrown === null || !thrown.isError) {
460 return '';
461 } else {
462 const config = {
463 rootDir: process.cwd(),
464 testMatch: [],
465 };
466 const options = {
467 noStackTrace: false,
468 };
469 if (thrown.value instanceof AggregateError) {
470 return formatExecError(thrown.value, config, options);
471 } else {
472 return formatStackTrace(
473 separateMessageFromStack(thrown.value.stack!).stack,
474 config,
475 options,
476 );
477 }
478 }
479};
480
481function createMessageAndCause(error: Error) {
482 if (error.cause) {

Callers 6

toThrowExpectedRegExpFunction · 0.85
toThrowExpectedObjectFunction · 0.85
toThrowExpectedClassFunction · 0.85
toThrowExpectedStringFunction · 0.85
toThrowFunction · 0.85

Calls 3

formatExecErrorFunction · 0.90
formatStackTraceFunction · 0.90
separateMessageFromStackFunction · 0.90

Tested by

no test coverage detected