index.d.ts 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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 {WriteStream} from 'tty';
  8. import {Config, Global as Global_2} from '@jest/types';
  9. declare const ARROW = ' \u203A ';
  10. /**
  11. * Whether the given value has properties that can be deleted (regardless of protection).
  12. *
  13. * @param value The given value.
  14. */
  15. export declare function canDeleteProperties(value: unknown): value is object;
  16. declare const CLEAR: string;
  17. export declare function clearLine(stream: WriteStream): void;
  18. export declare function convertDescriptorToString(
  19. descriptor: Global_2.BlockNameLike | undefined,
  20. ): string;
  21. export declare function createDirectory(path: string): void;
  22. export declare function deepCyclicCopy<T>(
  23. value: T,
  24. options?: DeepCyclicCopyOptions,
  25. cycles?: WeakMap<any, any>,
  26. ): T;
  27. declare type DeepCyclicCopyOptions = {
  28. blacklist?: Set<string>;
  29. keepPrototype?: boolean;
  30. };
  31. /**
  32. * Deletes all the properties from the given value (if it's an object),
  33. * unless the value was protected via {@link #protectProperties}.
  34. *
  35. * @param value the given value.
  36. */
  37. export declare function deleteProperties(value: unknown): void;
  38. /**
  39. * - <b>off</b>: deletion is completely turned off.
  40. * - <b>soft</b>: doesn't delete objects, but instead wraps their getter/setter with a deprecation warning.
  41. * - <b>on</b>: actually delete objects (using `delete`).
  42. */
  43. export declare type DeletionMode = 'soft' | 'off' | 'on';
  44. export declare class ErrorWithStack extends Error {
  45. constructor(
  46. message: string | undefined,
  47. callsite: (...args: Array<any>) => unknown,
  48. stackLimit?: number,
  49. );
  50. }
  51. export declare function formatTime(
  52. time: number,
  53. prefixPower?: number,
  54. padLeftLength?: number,
  55. ): string;
  56. /**
  57. * Converts a list of globs into a function that matches a path against the
  58. * globs.
  59. *
  60. * Every time picomatch is called, it will parse the glob strings and turn
  61. * them into regexp instances. Instead of calling picomatch repeatedly with
  62. * the same globs, we can use this function which will build the picomatch
  63. * matchers ahead of time and then have an optimized path for determining
  64. * whether an individual path matches.
  65. *
  66. * This function is intended to match the behavior of `micromatch()`.
  67. *
  68. * @example
  69. * const isMatch = globsToMatcher(['*.js', '!*.test.js']);
  70. * isMatch('pizza.js'); // true
  71. * isMatch('pizza.test.js'); // false
  72. */
  73. export declare function globsToMatcher(globs: Array<string>): Matcher;
  74. declare const ICONS: {
  75. failed: string;
  76. pending: string;
  77. success: string;
  78. todo: string;
  79. };
  80. /**
  81. * Initializes the garbage collection utils with the given deletion mode.
  82. *
  83. * @param globalObject the global object on which to store the deletion mode.
  84. * @param deletionMode the deletion mode to use.
  85. */
  86. export declare function initializeGarbageCollectionUtils(
  87. globalObject: typeof globalThis,
  88. deletionMode: DeletionMode,
  89. ): void;
  90. export declare function installCommonGlobals(
  91. globalObject: typeof globalThis,
  92. globals: Config.ConfigGlobals,
  93. garbageCollectionDeletionMode?: DeletionMode,
  94. ): typeof globalThis & Config.ConfigGlobals;
  95. export declare function interopRequireDefault(obj: any): any;
  96. export declare function invariant(
  97. condition: unknown,
  98. message?: string,
  99. ): asserts condition;
  100. export declare const isInteractive: boolean;
  101. export declare function isNonNullable<T>(value: T): value is NonNullable<T>;
  102. export declare function isPromise<T = unknown>(
  103. candidate: unknown,
  104. ): candidate is PromiseLike<T>;
  105. declare type Matcher = (str: string) => boolean;
  106. export declare function pluralize(
  107. word: string,
  108. count: number,
  109. ending?: string,
  110. ): string;
  111. declare namespace preRunMessage {
  112. export {print_2 as print, remove};
  113. }
  114. export {preRunMessage};
  115. declare function print_2(stream: WriteStream): void;
  116. /**
  117. * Protects the given value from being deleted by {@link #deleteProperties}.
  118. *
  119. * @param value The given value.
  120. * @param properties If the array contains any property,
  121. * then only these properties will be protected; otherwise if the array is empty,
  122. * all properties will be protected.
  123. * @param depth Determines how "deep" the protection should be.
  124. * A value of 0 means that only the top-most properties will be protected,
  125. * while a value larger than 0 means that deeper levels of nesting will be protected as well.
  126. */
  127. export declare function protectProperties<T>(
  128. value: T,
  129. properties?: Array<keyof T>,
  130. depth?: number,
  131. ): boolean;
  132. declare function remove(stream: WriteStream): void;
  133. export declare function replacePathSepForGlob(path: string): string;
  134. export declare function requireOrImportModule<T>(
  135. filePath: string,
  136. applyInteropRequireDefault?: boolean,
  137. ): Promise<T>;
  138. export declare function setGlobal(
  139. globalToMutate: typeof globalThis | Global_2.Global,
  140. key: string | symbol,
  141. value: unknown,
  142. afterTeardown?: 'clean' | 'retain',
  143. ): void;
  144. declare namespace specialChars {
  145. export {ARROW, ICONS, CLEAR};
  146. }
  147. export {specialChars};
  148. export declare function tryRealpath(path: string): string;
  149. export {};