本文整理匯總了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,
}),
);
}
}