本文整理匯總了TypeScript中jest-message-util.separateMessageFromStack函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript separateMessageFromStack函數的具體用法?TypeScript separateMessageFromStack怎麽用?TypeScript separateMessageFromStack使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了separateMessageFromStack函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: formatStackTrace
const formatStack = (thrown: Thrown | null) =>
thrown === null || !thrown.isError
? ''
: formatStackTrace(
separateMessageFromStack(thrown.value.stack!).stack,
{
rootDir: process.cwd(),
testMatch: [],
},
{
noStackTrace: false,
},
);
示例2: _logFormattedReferenceError
private _logFormattedReferenceError(errorMessage: string) {
const originalStack = new ReferenceError(errorMessage)
.stack!.split('\n')
// Remove this file from the stack (jest-message-utils will keep one line)
.filter(line => line.indexOf(__filename) === -1)
.join('\n');
const {message, stack} = separateMessageFromStack(originalStack);
console.error(
`\n${message}\n` +
formatStackTrace(stack, this._config, {noStackTrace: false}),
);
}
示例3: separateMessageFromStack
const formatError = (error: string | ErrorWithCode): SerializableError => {
if (typeof error === 'string') {
const {message, stack} = separateMessageFromStack(error);
return {
message,
stack,
type: 'Error',
};
}
return {
code: error.code || undefined,
message: error.message,
stack: error.stack,
type: 'Error',
};
};