UNPKG

1.69 kBTypeScriptView Raw
1/**
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7import type {Config} from '@jest/types';
8import type {StackData} from 'stack-utils';
9import type {TestResult} from '@jest/types';
10
11export declare const formatExecError: (
12 error: Error | TestResult.SerializableError | string | number | undefined,
13 config: StackTraceConfig,
14 options: StackTraceOptions,
15 testPath?: string,
16 reuseMessage?: boolean,
17 noTitle?: boolean,
18) => string;
19
20export declare const formatPath: (
21 line: string,
22 config: StackTraceConfig,
23 relativeTestPath?: string | null,
24) => string;
25
26export declare const formatResultsErrors: (
27 testResults: Array<TestResult.AssertionResult>,
28 config: StackTraceConfig,
29 options: StackTraceOptions,
30 testPath?: string,
31) => string | null;
32
33export declare const formatStackTrace: (
34 stack: string,
35 config: StackTraceConfig,
36 options: StackTraceOptions,
37 testPath?: string,
38) => string;
39
40export declare interface Frame extends StackData {
41 file: string;
42}
43
44export declare const getStackTraceLines: (
45 stack: string,
46 options?: StackTraceOptions,
47) => Array<string>;
48
49export declare const getTopFrame: (lines: Array<string>) => Frame | null;
50
51export declare const indentAllLines: (lines: string) => string;
52
53export declare const separateMessageFromStack: (content: string) => {
54 message: string;
55 stack: string;
56};
57
58export declare type StackTraceConfig = Pick<
59 Config.ProjectConfig,
60 'rootDir' | 'testMatch'
61>;
62
63export declare type StackTraceOptions = {
64 noStackTrace: boolean;
65 noCodeFrame?: boolean;
66};
67
68export {};