index.d.ts 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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. /// <reference types="node" />
  8. import type {Config} from '@jest/types';
  9. import type {Global} from '@jest/types';
  10. declare const ARROW = ' \u203A ';
  11. declare const CLEAR: string;
  12. export declare function clearLine(stream: NodeJS.WriteStream): void;
  13. export declare function convertDescriptorToString(
  14. descriptor: Global.BlockNameLike | undefined,
  15. ): string;
  16. export declare function createDirectory(path: string): void;
  17. export declare function deepCyclicCopy<T>(
  18. value: T,
  19. options?: DeepCyclicCopyOptions,
  20. cycles?: WeakMap<any, any>,
  21. ): T;
  22. declare type DeepCyclicCopyOptions = {
  23. blacklist?: Set<string>;
  24. keepPrototype?: boolean;
  25. };
  26. export declare class ErrorWithStack extends Error {
  27. constructor(
  28. message: string | undefined,
  29. callsite: (...args: Array<any>) => unknown,
  30. stackLimit?: number,
  31. );
  32. }
  33. export declare function formatTime(
  34. time: number,
  35. prefixPower?: number,
  36. padLeftLength?: number,
  37. ): string;
  38. /**
  39. * Converts a list of globs into a function that matches a path against the
  40. * globs.
  41. *
  42. * Every time picomatch is called, it will parse the glob strings and turn
  43. * them into regexp instances. Instead of calling picomatch repeatedly with
  44. * the same globs, we can use this function which will build the picomatch
  45. * matchers ahead of time and then have an optimized path for determining
  46. * whether an individual path matches.
  47. *
  48. * This function is intended to match the behavior of `micromatch()`.
  49. *
  50. * @example
  51. * const isMatch = globsToMatcher(['*.js', '!*.test.js']);
  52. * isMatch('pizza.js'); // true
  53. * isMatch('pizza.test.js'); // false
  54. */
  55. export declare function globsToMatcher(globs: Array<string>): Matcher;
  56. declare const ICONS: {
  57. failed: string;
  58. pending: string;
  59. success: string;
  60. todo: string;
  61. };
  62. export declare function installCommonGlobals(
  63. globalObject: typeof globalThis,
  64. globals: Config.ConfigGlobals,
  65. ): typeof globalThis & Config.ConfigGlobals;
  66. export declare function interopRequireDefault(obj: any): any;
  67. export declare function invariant(
  68. condition: unknown,
  69. message?: string,
  70. ): asserts condition;
  71. export declare const isInteractive: boolean;
  72. export declare function isNonNullable<T>(value: T): value is NonNullable<T>;
  73. export declare function isPromise<T = unknown>(
  74. candidate: unknown,
  75. ): candidate is PromiseLike<T>;
  76. declare type Matcher = (str: string) => boolean;
  77. export declare function pluralize(
  78. word: string,
  79. count: number,
  80. ending?: string,
  81. ): string;
  82. declare namespace preRunMessage {
  83. export {print_2 as print, remove};
  84. }
  85. export {preRunMessage};
  86. declare function print_2(stream: NodeJS.WriteStream): void;
  87. declare function remove(stream: NodeJS.WriteStream): void;
  88. export declare function replacePathSepForGlob(path: string): string;
  89. export declare function requireOrImportModule<T>(
  90. filePath: string,
  91. applyInteropRequireDefault?: boolean,
  92. ): Promise<T>;
  93. export declare function setGlobal(
  94. globalToMutate: typeof globalThis | Global.Global,
  95. key: string,
  96. value: unknown,
  97. ): void;
  98. declare namespace specialChars {
  99. export {ARROW, ICONS, CLEAR};
  100. }
  101. export {specialChars};
  102. export declare function testPathPatternToRegExp(
  103. testPathPattern: Config.GlobalConfig['testPathPattern'],
  104. ): RegExp;
  105. export declare function tryRealpath(path: string): string;
  106. export {};