forked from jest-community/jest-editor-support
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
261 lines (227 loc) · 6.54 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
/**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import {EventEmitter} from 'events';
import {ChildProcess} from 'child_process';
import {Config as JestConfig} from '@jest/types';
import { CoverageMap, CoverageMapData } from 'istanbul-lib-coverage';
export interface RunArgs {
args: string[];
replace?: boolean; // default is false
}
export interface Options {
createProcess?: (
workspace: ProjectWorkspace,
args: string[],
) => ChildProcess;
noColor?: boolean;
testNamePattern?: string;
testFileNamePattern?: string;
reporters?: string[];
/** either to append or replace the Runner process arguments */
args?: RunArgs;
}
export type RunnerEvent = 'processClose' | 'processExit' | 'executableJSON' | 'executableStdErr' | 'executableOutput' | 'terminalError';
export type DeprecatedRunnerEvent = 'debuggerProcessExit';
export class Runner extends EventEmitter {
constructor(workspace: ProjectWorkspace, options?: Options);
watchMode: boolean;
watchAll: boolean;
start(watchMode?: boolean, watchAll?: boolean): void;
closeProcess(): void;
runJestWithUpdateForSnapshots(completion: () => void, args?: string[]): void;
on:(event: RunnerEvent|DeprecatedRunnerEvent, listener: (...args: any[]) => void) => this;
}
export interface JestSettings {
jestVersionMajor: number;
configs: JestConfig.ProjectConfig[];
}
export function getSettings(workspace: ProjectWorkspace, options?: Options): Promise<JestSettings>;
export function createProjectWorkspace(config: ProjectWorkspaceConfig): ProjectWorkspace;
export interface ProjectWorkspaceConfig {
jestCommandLine: string;
pathToConfig?: string;
rootPath: string;
localJestMajorVersion: number;
outputFileSuffix?: string;
collectCoverage?: boolean;
debug?: boolean;
}
export class ProjectWorkspace {
constructor(
rootPath: string,
jestCommandLine: string,
pathToConfig: string,
localJestMajorVersion: number,
outputFileSuffix?: string,
collectCoverage?: boolean,
debug?: boolean,
nodeEnv?: {[key: string]: string | undefined},
);
jestCommandLine: string;
pathToConfig: string;
rootPath: string;
localJestMajorVersion: number;
outputFileSuffix?: string;
collectCoverage?: boolean;
debug?: boolean;
nodeEnv?: {[key: string]: string | undefined};
}
export interface IParseResults {
describeBlocks: Array<DescribeBlock>;
expects: Array<Expect>;
itBlocks: Array<ItBlock>;
root: ParsedNode;
file: string;
}
export function parse(file: string, data?: string, strict?: boolean): IParseResults;
export interface Location {
column: number;
line: number;
}
export class ParsedRange {
start: Location;
end: Location;
constructor(
startLine: number,
startCol: number,
endLine: number,
endCol: number,
);
}
export enum ParsedNodeTypes {
it = 'it',
describe = 'describe',
expect = 'expect',
root = 'root',
}
export type ParsedNodeType = ParsedNodeTypes;
export declare class ParsedNode {
type: ParsedNodeType;
start: Location;
end: Location;
file: string;
children?: ParsedNode[];
constructor(type: ParsedNodeType, file: string);
filter(f: (parsedNode: ParsedNode) => boolean): Array<ParsedNode>;
addChild(type: ParsedNodeType): ParsedNode;
}
export declare class NamedBlock extends ParsedNode {
name: string;
nameRange: ParsedRange;
constructor(type: ParsedNodeType, file: string, name?: string);
}
export declare class ItBlock extends NamedBlock {
constructor(file: string, name?: string);
}
export declare class DescribeBlock extends NamedBlock {
constructor(file: string, name?: string);
}
export declare class Expect extends ParsedNode {
constructor(file: string);
}
export class TestReconciler {
stateForTestFile(file: string): TestReconcilationState;
assertionsForTestFile(file: string): TestAssertionStatus[] | null;
stateForTestAssertion(
file: string,
name: string,
): TestFileAssertionStatus | null;
updateFileWithJestStatus(data: any): TestFileAssertionStatus[];
removeTestFile(fileName: string): void;
}
/**
* Did the thing pass, fail or was it not run?
*/
export type TestReconcilationState =
| 'Unknown' // The file has not changed, so the watcher didn't hit it
| 'KnownFail' // Definitely failed
| 'KnownSuccess' // Definitely passed
| 'KnownSkip' // Definitely skipped (it.skip)
| 'KnownTodo'; // Definitely todo (it.todo)
/**
* The Jest Extension's version of a status for
* whether the file passed or not
*
*/
export interface TestFileAssertionStatus {
file: string;
message: string;
status: TestReconcilationState;
assertions: Array<TestAssertionStatus> | null;
}
/**
* The Jest Extension's version of a status for
* individual assertion fails
*
*/
export interface TestAssertionStatus {
title: string;
fullName: string;
ancestorTitles: string[];
status: TestReconcilationState;
message: string;
shortMessage?: string;
terseMessage?: string;
location?: Location;
line?: number;
}
export interface JestFileResults {
name: string;
summary: string;
message: string;
status: 'failed' | 'passed';
startTime: number;
endTime: number;
assertionResults: Array<JestAssertionResults>;
}
export interface JestAssertionResults {
name: string;
title: string;
status: 'failed' | 'passed';
failureMessages: string[];
fullName: string;
}
export interface JestTotalResults {
success: boolean;
startTime: number;
numTotalTests: number;
numTotalTestSuites: number;
numRuntimeErrorTestSuites: number;
numPassedTests: number;
numFailedTests: number;
numPendingTests: number;
coverageMap?: CoverageMapData;
testResults: Array<JestFileResults>;
}
export interface JestTotalResultsMeta {
noTestsFound: boolean;
}
export enum messageTypes {
noTests = 1,
testResults = 3,
unknown = 0,
watchUsage = 2,
}
export type MessageType = number;
export interface SnapshotMetadata {
exists: boolean;
name: string;
node: {
loc: ParsedNode;
};
content?: string;
}
export class Snapshot {
constructor(parser?: any, customMatchers?: string[]);
getMetadata(filepath: string, verbose?: boolean): SnapshotMetadata[];
}
type FormattedTestResults = {
testResults: TestResult[]
}
type TestResult = {
name: string
}