本文整理汇总了TypeScript中jest-message-util.formatStackTrace函数的典型用法代码示例。如果您正苦于以下问题:TypeScript formatStackTrace函数的具体用法?TypeScript formatStackTrace怎么用?TypeScript formatStackTrace使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了formatStackTrace函数的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: _checkFakeTimers
private _checkFakeTimers() {
if (this._global.setTimeout !== this._fakeTimerAPIs.setTimeout) {
this._global.console.warn(
`A function to advance timers was called but the timers API is not ` +
`mocked with fake timers. Call \`jest.useFakeTimers()\` in this ` +
`test or enable fake timers globally by setting ` +
`\`"timers": "fake"\` in ` +
`the configuration file. This warning is likely a result of a ` +
`default configuration change in Jest 15.\n\n` +
`Release Blog Post: https://jestjs.io/blog/2016/09/01/jest-15.html\n` +
`Stack Trace:\n` +
formatStackTrace(new Error().stack!, this._config, {
noStackTrace: false,
}),
);
}
}