UNPKG

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