index.d.ts 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. */
  7. import {StackData} from 'stack-utils';
  8. import {Config, TestResult} from '@jest/types';
  9. export declare const formatExecError: (
  10. error: Error | TestResult.SerializableError | string | number | undefined,
  11. config: StackTraceConfig,
  12. options: StackTraceOptions,
  13. testPath?: string,
  14. reuseMessage?: boolean,
  15. noTitle?: boolean,
  16. ) => string;
  17. export declare const formatPath: (
  18. line: string,
  19. config: StackTraceConfig,
  20. relativeTestPath?: string | null,
  21. ) => string;
  22. export declare const formatResultsErrors: (
  23. testResults: Array<TestResult.AssertionResult>,
  24. config: StackTraceConfig,
  25. options: StackTraceOptions,
  26. testPath?: string,
  27. ) => string | null;
  28. export declare function formatStackTrace(
  29. stack: string,
  30. config: StackTraceConfig,
  31. options: StackTraceOptions,
  32. testPath?: string,
  33. ): string;
  34. export declare interface Frame extends StackData {
  35. file: string;
  36. }
  37. export declare function getStackTraceLines(
  38. stack: string,
  39. options?: StackTraceOptions,
  40. ): Array<string>;
  41. export declare function getTopFrame(lines: Array<string>): Frame | null;
  42. export declare const indentAllLines: (lines: string) => string;
  43. export declare const separateMessageFromStack: (content: string) => {
  44. message: string;
  45. stack: string;
  46. };
  47. export declare type StackTraceConfig = Pick<
  48. Config.ProjectConfig,
  49. 'rootDir' | 'testMatch'
  50. >;
  51. export declare type StackTraceOptions = {
  52. noStackTrace: boolean;
  53. noCodeFrame?: boolean;
  54. };
  55. export {};