本文整理汇总了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',
};
};