@provino/dialect-jest 0.0.0-stage → 0.1.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +8 -2
- package/THIRD_PARTY_NOTICES.md +266 -0
- package/dist/affected/index.d.ts +13 -0
- package/dist/affected/index.js +424 -0
- package/dist/failure-message.d.ts +245 -0
- package/dist/failure-message.js +125 -0
- package/dist/global-setup/index.d.ts +11 -0
- package/dist/global-setup/index.js +40 -0
- package/dist/index.d.ts +41 -0
- package/dist/index.js +528 -0
- package/dist/inline-snapshots/index.d.ts +6 -0
- package/dist/inline-snapshots/index.js +263 -0
- package/dist/jest-require.js +42 -0
- package/dist/node/index.d.ts +1716 -0
- package/dist/node/index.js +7307 -0
- package/dist/results/index.d.ts +248 -0
- package/dist/results/index.js +844 -0
- package/dist/runtime/index.d.ts +450 -0
- package/dist/runtime/index.js +3455 -0
- package/package.json +97 -3
|
@@ -0,0 +1,424 @@
|
|
|
1
|
+
import * as path from "node:path";
|
|
2
|
+
import { spawn } from "node:child_process";
|
|
3
|
+
|
|
4
|
+
// src/affected/exec.ts
|
|
5
|
+
/** The code of every failure this module reports: what `provino jest` prints as Jest does. */
|
|
6
|
+
const SCM_COMMAND_FAILED = "JEST_SCM_COMMAND_FAILED";
|
|
7
|
+
/** execa 5.1.1's `DEFAULT_MAX_BUFFER` (`index.js` L15): 100 MB of each stream. */
|
|
8
|
+
const MAX_BUFFER = 1e8;
|
|
9
|
+
/** execa's `stripFinalNewline`: one trailing `\n` (or `\r\n`). */
|
|
10
|
+
function stripFinalNewline(text) {
|
|
11
|
+
if (text.endsWith("\r\n")) return text.slice(0, -2);
|
|
12
|
+
if (text.endsWith("\n")) return text.slice(0, -1);
|
|
13
|
+
return text;
|
|
14
|
+
}
|
|
15
|
+
/** execa's `getErrorPrefix`, for the cases a plain spawn can meet. */
|
|
16
|
+
function prefixOf(code, signal, exitCode) {
|
|
17
|
+
if (code !== void 0) return `failed with ${code}`;
|
|
18
|
+
if (signal !== void 0) return `was killed with ${signal}`;
|
|
19
|
+
if (exitCode !== void 0) return `failed with exit code ${exitCode}`;
|
|
20
|
+
return "failed";
|
|
21
|
+
}
|
|
22
|
+
/** The outcome of a command that was cancelled (by `firstChunk` or `signal`): no output, no error. */
|
|
23
|
+
const CANCELLED = Symbol("cancelled");
|
|
24
|
+
/**
|
|
25
|
+
* Runs `file args` and resolves with its stdout (the final newline stripped), or `CANCELLED`. A
|
|
26
|
+
* command that can't start, ends badly or writes more than `maxBuffer` rejects with execa's
|
|
27
|
+
* message and `code` `JEST_SCM_COMMAND_FAILED`. It settles only once the process has exited and
|
|
28
|
+
* its streams have closed, so a killed command is reaped before the caller moves on.
|
|
29
|
+
*/
|
|
30
|
+
function runCommand(file, args, options) {
|
|
31
|
+
const command = [file, ...args].join(" ");
|
|
32
|
+
const maxBuffer = options.maxBuffer ?? 1e8;
|
|
33
|
+
return new Promise((resolvePromise, reject) => {
|
|
34
|
+
if (options.signal?.aborted === true) {
|
|
35
|
+
resolvePromise(CANCELLED);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
let stdout = "";
|
|
39
|
+
let stderr = "";
|
|
40
|
+
let cancelled = false;
|
|
41
|
+
let overflowed = false;
|
|
42
|
+
let spawnError;
|
|
43
|
+
const child = spawn(file, args, {
|
|
44
|
+
cwd: options.cwd,
|
|
45
|
+
env: options.env ?? process.env,
|
|
46
|
+
stdio: [
|
|
47
|
+
"ignore",
|
|
48
|
+
"pipe",
|
|
49
|
+
"pipe"
|
|
50
|
+
]
|
|
51
|
+
});
|
|
52
|
+
const cancel = () => {
|
|
53
|
+
cancelled = true;
|
|
54
|
+
child.kill();
|
|
55
|
+
};
|
|
56
|
+
options.signal?.addEventListener("abort", cancel, { once: true });
|
|
57
|
+
child.stdout?.setEncoding("utf8");
|
|
58
|
+
child.stderr?.setEncoding("utf8");
|
|
59
|
+
const bytes = {
|
|
60
|
+
out: 0,
|
|
61
|
+
err: 0
|
|
62
|
+
};
|
|
63
|
+
const grow = (stream, current, chunk) => {
|
|
64
|
+
bytes[stream] += Buffer.byteLength(chunk);
|
|
65
|
+
if (!overflowed && bytes[stream] > maxBuffer) {
|
|
66
|
+
overflowed = true;
|
|
67
|
+
child.kill();
|
|
68
|
+
}
|
|
69
|
+
return current + chunk;
|
|
70
|
+
};
|
|
71
|
+
let first = true;
|
|
72
|
+
child.stdout?.on("data", (chunk) => {
|
|
73
|
+
if (first) {
|
|
74
|
+
first = false;
|
|
75
|
+
if (options.firstChunk?.(chunk) === true) {
|
|
76
|
+
cancel();
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
if (!cancelled) stdout = grow("out", stdout, chunk);
|
|
81
|
+
});
|
|
82
|
+
child.stderr?.on("data", (chunk) => {
|
|
83
|
+
if (!cancelled) stderr = grow("err", stderr, chunk);
|
|
84
|
+
});
|
|
85
|
+
let settled = false;
|
|
86
|
+
const finish = (exitCode, signal) => {
|
|
87
|
+
if (settled) return;
|
|
88
|
+
settled = true;
|
|
89
|
+
options.signal?.removeEventListener("abort", cancel);
|
|
90
|
+
if (cancelled) {
|
|
91
|
+
resolvePromise(CANCELLED);
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
const out = stripFinalNewline(stdout);
|
|
95
|
+
const err = stripFinalNewline(stderr);
|
|
96
|
+
if (spawnError === void 0 && !overflowed && exitCode === 0) {
|
|
97
|
+
resolvePromise(out);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
let short;
|
|
101
|
+
if (overflowed) short = `Command failed: ${command}\nmaxBuffer exceeded`;
|
|
102
|
+
else {
|
|
103
|
+
const head = `Command ${prefixOf(typeof spawnError?.code === "string" ? spawnError.code : void 0, signal ?? void 0, exitCode ?? void 0)}: ${command}`;
|
|
104
|
+
short = spawnError === void 0 ? head : `${head}\n${spawnError.message}`;
|
|
105
|
+
}
|
|
106
|
+
reject(Object.assign(new Error([
|
|
107
|
+
short,
|
|
108
|
+
err,
|
|
109
|
+
out
|
|
110
|
+
].filter(Boolean).join("\n")), {
|
|
111
|
+
code: SCM_COMMAND_FAILED,
|
|
112
|
+
command,
|
|
113
|
+
exitCode: overflowed ? void 0 : exitCode ?? void 0,
|
|
114
|
+
signal: overflowed ? void 0 : signal ?? void 0,
|
|
115
|
+
stdout: out,
|
|
116
|
+
stderr: err
|
|
117
|
+
}));
|
|
118
|
+
};
|
|
119
|
+
child.on("error", (error) => {
|
|
120
|
+
spawnError = error;
|
|
121
|
+
if (child.pid === void 0) finish(null, null);
|
|
122
|
+
});
|
|
123
|
+
child.on("close", finish);
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// src/affected/scm.ts
|
|
128
|
+
/** The lines of a command's output as absolute paths (`findChangedFilesUsingCommand`). */
|
|
129
|
+
function toPaths(stdout, cwd) {
|
|
130
|
+
return stdout.split("\n").filter((line) => line !== "").map((changedPath) => path.resolve(cwd, changedPath));
|
|
131
|
+
}
|
|
132
|
+
async function stdoutOf(file, args, cwd, env) {
|
|
133
|
+
const out = await runCommand(file, args, {
|
|
134
|
+
cwd,
|
|
135
|
+
...env === void 0 ? {} : { env }
|
|
136
|
+
});
|
|
137
|
+
return out === CANCELLED ? "" : out;
|
|
138
|
+
}
|
|
139
|
+
/** `git.ts` L12-L23. */
|
|
140
|
+
async function gitFiles(args, cwd) {
|
|
141
|
+
return toPaths(await stdoutOf("git", args, cwd), cwd);
|
|
142
|
+
}
|
|
143
|
+
/** jest-changed-files `src/git.ts` L25-L107. */
|
|
144
|
+
const gitAdapter = {
|
|
145
|
+
async findChangedFiles(cwd, options) {
|
|
146
|
+
const changedSince = options.withAncestor === true ? "HEAD^" : options.changedSince;
|
|
147
|
+
const includePaths = (options.includePaths ?? []).map((absoluteRoot) => path.normalize(path.relative(cwd, absoluteRoot)));
|
|
148
|
+
if (options.lastCommit === true) return gitFiles([
|
|
149
|
+
"show",
|
|
150
|
+
"--name-only",
|
|
151
|
+
"--pretty=format:",
|
|
152
|
+
"HEAD",
|
|
153
|
+
"--",
|
|
154
|
+
...includePaths
|
|
155
|
+
], cwd);
|
|
156
|
+
const staged = [
|
|
157
|
+
"diff",
|
|
158
|
+
"--cached",
|
|
159
|
+
"--name-only",
|
|
160
|
+
"--",
|
|
161
|
+
...includePaths
|
|
162
|
+
];
|
|
163
|
+
const unstaged = [
|
|
164
|
+
"ls-files",
|
|
165
|
+
"--other",
|
|
166
|
+
"--modified",
|
|
167
|
+
"--exclude-standard",
|
|
168
|
+
"--",
|
|
169
|
+
...includePaths
|
|
170
|
+
];
|
|
171
|
+
if (changedSince != null && changedSince.length > 0) {
|
|
172
|
+
const [committed, cached, rest] = await Promise.all([
|
|
173
|
+
gitFiles([
|
|
174
|
+
"diff",
|
|
175
|
+
"--name-only",
|
|
176
|
+
`${changedSince}...HEAD`,
|
|
177
|
+
"--",
|
|
178
|
+
...includePaths
|
|
179
|
+
], cwd),
|
|
180
|
+
gitFiles(staged, cwd),
|
|
181
|
+
gitFiles(unstaged, cwd)
|
|
182
|
+
]);
|
|
183
|
+
return [
|
|
184
|
+
...committed,
|
|
185
|
+
...cached,
|
|
186
|
+
...rest
|
|
187
|
+
];
|
|
188
|
+
}
|
|
189
|
+
const [cached, rest] = await Promise.all([gitFiles(staged, cwd), gitFiles(unstaged, cwd)]);
|
|
190
|
+
return [...cached, ...rest];
|
|
191
|
+
},
|
|
192
|
+
async getRoot(cwd) {
|
|
193
|
+
try {
|
|
194
|
+
return path.resolve(cwd, await stdoutOf("git", ["rev-parse", "--show-cdup"], cwd));
|
|
195
|
+
} catch {
|
|
196
|
+
return null;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
/** `hg.ts` L13 and `sl.ts` L18: `HGPLAIN` turns off the settings that change the output. */
|
|
201
|
+
function plainEnv() {
|
|
202
|
+
return {
|
|
203
|
+
...process.env,
|
|
204
|
+
HGPLAIN: "1"
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
/** The `status` arguments hg and sl share (`hg.ts` L17-L30, `sl.ts` L24-L37). */
|
|
208
|
+
function statusArgs(options) {
|
|
209
|
+
const args = ["status", "-amnu"];
|
|
210
|
+
if (options.withAncestor === true) args.push("--rev", "first(min(!public() & ::.)^+.^)");
|
|
211
|
+
else if (options.changedSince != null && options.changedSince.length > 0) args.push("--rev", `ancestor(., ${options.changedSince})`);
|
|
212
|
+
else if (options.lastCommit === true) args.push("--change", ".");
|
|
213
|
+
args.push(...options.includePaths ?? []);
|
|
214
|
+
return args;
|
|
215
|
+
}
|
|
216
|
+
/** jest-changed-files `src/hg.ts` L15-L48. */
|
|
217
|
+
const hgAdapter = {
|
|
218
|
+
async findChangedFiles(cwd, options) {
|
|
219
|
+
return toPaths(await stdoutOf("hg", statusArgs(options), cwd, plainEnv()), cwd);
|
|
220
|
+
},
|
|
221
|
+
async getRoot(cwd) {
|
|
222
|
+
try {
|
|
223
|
+
return await stdoutOf("hg", ["root"], cwd, plainEnv());
|
|
224
|
+
} catch {
|
|
225
|
+
return null;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
/**
|
|
230
|
+
* jest-changed-files `src/sl.ts` L22-L76. `sl` may be the steam locomotive, which draws with escape
|
|
231
|
+
* codes: a first chunk that starts with ESC kills it, and no Sapling root is looked for again by
|
|
232
|
+
* this adapter. Jest keeps that in a module variable for its process; here the adapter holds it,
|
|
233
|
+
* and the provider that owns the adapter lives as long as the coordinator (`index.ts`). The first
|
|
234
|
+
* locomotive also stops every other `sl root` still running, so up to five probes started at
|
|
235
|
+
* once don't all draw: each is killed and reaped before its lookup returns.
|
|
236
|
+
*/
|
|
237
|
+
function slAdapter() {
|
|
238
|
+
let isSteamLocomotive = false;
|
|
239
|
+
/** Aborted by the first locomotive: every `sl root` still running is killed. */
|
|
240
|
+
const locomotive = new AbortController();
|
|
241
|
+
return {
|
|
242
|
+
async findChangedFiles(cwd, options) {
|
|
243
|
+
return toPaths(await stdoutOf("sl", statusArgs(options), cwd, plainEnv()), cwd);
|
|
244
|
+
},
|
|
245
|
+
async getRoot(cwd) {
|
|
246
|
+
if (isSteamLocomotive) return null;
|
|
247
|
+
try {
|
|
248
|
+
const out = await runCommand("sl", ["root"], {
|
|
249
|
+
cwd,
|
|
250
|
+
env: plainEnv(),
|
|
251
|
+
signal: locomotive.signal,
|
|
252
|
+
firstChunk: (chunk) => {
|
|
253
|
+
if (chunk.codePointAt(0) === 27) {
|
|
254
|
+
isSteamLocomotive = true;
|
|
255
|
+
locomotive.abort();
|
|
256
|
+
}
|
|
257
|
+
return isSteamLocomotive;
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
return out === CANCELLED ? null : out;
|
|
261
|
+
} catch {
|
|
262
|
+
return null;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// src/affected/changed-files.ts
|
|
269
|
+
/** `index.ts` L18-L20: at most `limit` calls of `run` at once (`pLimit(5)`). */
|
|
270
|
+
function createLimiter(limit) {
|
|
271
|
+
let active = 0;
|
|
272
|
+
const waiting = [];
|
|
273
|
+
const next = () => {
|
|
274
|
+
if (active >= limit) return;
|
|
275
|
+
const start = waiting.shift();
|
|
276
|
+
if (start === void 0) return;
|
|
277
|
+
active++;
|
|
278
|
+
start();
|
|
279
|
+
};
|
|
280
|
+
return (run) => new Promise((resolvePromise, reject) => {
|
|
281
|
+
waiting.push(() => {
|
|
282
|
+
run().then(resolvePromise, reject).finally(() => {
|
|
283
|
+
active--;
|
|
284
|
+
next();
|
|
285
|
+
});
|
|
286
|
+
});
|
|
287
|
+
next();
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
/** The repositories of some roots, by kind, as sets (`findRepos`, `index.ts` L62-L74). */
|
|
291
|
+
async function findRepos(roots, adapters) {
|
|
292
|
+
const mutex = createLimiter(5);
|
|
293
|
+
const find = (adapter) => Promise.all(roots.map((root) => mutex(() => adapter.getRoot(root))));
|
|
294
|
+
const [git, hg, sl] = await Promise.all([
|
|
295
|
+
find(adapters.git),
|
|
296
|
+
find(adapters.hg),
|
|
297
|
+
find(adapters.sl)
|
|
298
|
+
]);
|
|
299
|
+
const present = (list) => new Set(list.filter((repo) => repo !== null));
|
|
300
|
+
return {
|
|
301
|
+
git: present(git),
|
|
302
|
+
hg: present(hg),
|
|
303
|
+
sl: present(sl)
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* A changed-files provider and the adapters it keeps: what Jest keeps per process (whether `sl` is
|
|
308
|
+
* the steam locomotive) lives as long as the provider does.
|
|
309
|
+
*/
|
|
310
|
+
function createChangedFilesProvider() {
|
|
311
|
+
const adapters = {
|
|
312
|
+
git: gitAdapter,
|
|
313
|
+
hg: hgAdapter,
|
|
314
|
+
sl: slAdapter()
|
|
315
|
+
};
|
|
316
|
+
return (options) => changedFilesForRoots(options, adapters);
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* `getChangedFilesForRoots` (`index.ts` L26-L60): every changed file of every repository the roots
|
|
320
|
+
* are in, with the roots as `includePaths`. A failing command rejects with execa's message.
|
|
321
|
+
*/
|
|
322
|
+
async function changedFilesForRoots(options, adapters) {
|
|
323
|
+
const { roots } = options;
|
|
324
|
+
const repos = await findRepos(roots, adapters);
|
|
325
|
+
const changedFilesOptions = {
|
|
326
|
+
includePaths: roots,
|
|
327
|
+
changedSince: options.changedSince,
|
|
328
|
+
lastCommit: options.lastCommit,
|
|
329
|
+
withAncestor: options.withAncestor
|
|
330
|
+
};
|
|
331
|
+
const all = await Promise.all([
|
|
332
|
+
...Array.from(repos.git, (repo) => adapters.git.findChangedFiles(repo, changedFilesOptions)),
|
|
333
|
+
...Array.from(repos.hg, (repo) => adapters.hg.findChangedFiles(repo, changedFilesOptions)),
|
|
334
|
+
...Array.from(repos.sl, (repo) => adapters.sl.findChangedFiles(repo, changedFilesOptions))
|
|
335
|
+
]);
|
|
336
|
+
const changedFiles = /* @__PURE__ */ new Set();
|
|
337
|
+
for (const files of all) for (const file of files) changedFiles.add(file);
|
|
338
|
+
return {
|
|
339
|
+
changedFiles: [...changedFiles],
|
|
340
|
+
repos: {
|
|
341
|
+
git: [...repos.git],
|
|
342
|
+
hg: [...repos.hg],
|
|
343
|
+
sl: [...repos.sl]
|
|
344
|
+
}
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
// src/affected/extractor.ts
|
|
349
|
+
const NOT_A_DOT = "(?<!\\.\\s*)";
|
|
350
|
+
const CAPTURE_STRING_LITERAL = (pos) => `([\`'"])([^'"\`]*?)(?:\\${pos})`;
|
|
351
|
+
const WORD_SEPARATOR = "\\b";
|
|
352
|
+
const LEFT_PARENTHESIS = "\\(";
|
|
353
|
+
const RIGHT_PARENTHESIS = "\\)";
|
|
354
|
+
const WHITESPACE = "\\s*";
|
|
355
|
+
const OPTIONAL_COMMA = "(:?,\\s*)?";
|
|
356
|
+
function createRegExp(parts, flags) {
|
|
357
|
+
return new RegExp(parts.join(""), flags);
|
|
358
|
+
}
|
|
359
|
+
function alternatives(...parts) {
|
|
360
|
+
return `(?:${parts.join("|")})`;
|
|
361
|
+
}
|
|
362
|
+
function functionCallStart(...names) {
|
|
363
|
+
return [
|
|
364
|
+
NOT_A_DOT,
|
|
365
|
+
WORD_SEPARATOR,
|
|
366
|
+
alternatives(...names),
|
|
367
|
+
WHITESPACE,
|
|
368
|
+
LEFT_PARENTHESIS,
|
|
369
|
+
WHITESPACE
|
|
370
|
+
];
|
|
371
|
+
}
|
|
372
|
+
const BLOCK_COMMENT_RE = /\/\*[\s\S]*?\*\//g;
|
|
373
|
+
const LINE_COMMENT_RE = /\/\/.*/g;
|
|
374
|
+
const REQUIRE_OR_DYNAMIC_IMPORT_RE = createRegExp([
|
|
375
|
+
...functionCallStart("require", "import"),
|
|
376
|
+
CAPTURE_STRING_LITERAL(1),
|
|
377
|
+
WHITESPACE,
|
|
378
|
+
OPTIONAL_COMMA,
|
|
379
|
+
RIGHT_PARENTHESIS
|
|
380
|
+
], "g");
|
|
381
|
+
const IMPORT_OR_EXPORT_RE = createRegExp(["\\b(?:import|export)\\s+(?!type(?:of)?\\s+)(?:[^'\"]+\\s+from\\s+)?", CAPTURE_STRING_LITERAL(1)], "g");
|
|
382
|
+
const JEST_EXTENSIONS_RE = createRegExp([
|
|
383
|
+
...functionCallStart("jest\\s*\\.\\s*(?:requireActual|requireMock|createMockFromModule)"),
|
|
384
|
+
CAPTURE_STRING_LITERAL(1),
|
|
385
|
+
WHITESPACE,
|
|
386
|
+
OPTIONAL_COMMA,
|
|
387
|
+
RIGHT_PARENTHESIS
|
|
388
|
+
], "g");
|
|
389
|
+
/** Haste's extractor: the specifiers `code` names, in the order the regexes find them. */
|
|
390
|
+
function extractHasteDependencies(code) {
|
|
391
|
+
const dependencies = /* @__PURE__ */ new Set();
|
|
392
|
+
const addDependency = (match, _quote, dep) => {
|
|
393
|
+
dependencies.add(dep);
|
|
394
|
+
return match;
|
|
395
|
+
};
|
|
396
|
+
code.replaceAll(BLOCK_COMMENT_RE, "").replaceAll(LINE_COMMENT_RE, "").replace(IMPORT_OR_EXPORT_RE, addDependency).replace(REQUIRE_OR_DYNAMIC_IMPORT_RE, addDependency).replace(JEST_EXTENSIONS_RE, addDependency);
|
|
397
|
+
return dependencies;
|
|
398
|
+
}
|
|
399
|
+
/** The extractor object (`DependencyExtractor`): haste's own, with no fallback to call. */
|
|
400
|
+
const hasteExtractor = {
|
|
401
|
+
extract: (code) => extractHasteDependencies(code),
|
|
402
|
+
cacheKey: "jest-haste-map@30.5.1"
|
|
403
|
+
};
|
|
404
|
+
|
|
405
|
+
// src/affected/index.ts
|
|
406
|
+
/**
|
|
407
|
+
* The one provider of this process: the behaviour loader imports this leaf once (Node caches the
|
|
408
|
+
* module), so the provider, and what its `sl` adapter learned, lives as long as the coordinator.
|
|
409
|
+
*/
|
|
410
|
+
const provider = createChangedFilesProvider();
|
|
411
|
+
/**
|
|
412
|
+
* Jest's changed files (`orchestrator.changedFiles`): jest-changed-files 30.5.1's
|
|
413
|
+
* `getChangedFilesForRoots` rebuilt over git, hg and sl. A command that fails rejects with execa's
|
|
414
|
+
* message, which Jest prints, and the code `JEST_SCM_COMMAND_FAILED`.
|
|
415
|
+
* @public
|
|
416
|
+
*/
|
|
417
|
+
const jestChangedFiles = (options) => provider(options);
|
|
418
|
+
/**
|
|
419
|
+
* Haste's dependency extractor (`orchestrator.affected.extractor`): jest-haste-map 30.5.2's regexes.
|
|
420
|
+
* @public
|
|
421
|
+
*/
|
|
422
|
+
const jestDependencyExtractor = () => hasteExtractor;
|
|
423
|
+
|
|
424
|
+
export { jestChangedFiles, jestDependencyExtractor };
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A test's status (`AssertionResult['status']`). A skipped test is `pending`; `skipped` is a
|
|
3
|
+
* file's flag, not a status.
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
type Status = "passed" | "failed" | "skipped" | "pending" | "todo" | "disabled" | "focused";
|
|
7
|
+
/**
|
|
8
|
+
* One test's result (`@jest/types` `TestResult.AssertionResult`, with `startAt` and `wouldRun` as
|
|
9
|
+
* `jest-circus` 30.5.2 fills them).
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
interface AssertionResult {
|
|
13
|
+
ancestorTitles: string[];
|
|
14
|
+
duration?: number | null;
|
|
15
|
+
failing?: boolean;
|
|
16
|
+
failureDetails: unknown[];
|
|
17
|
+
failureMessages: string[];
|
|
18
|
+
fullName: string;
|
|
19
|
+
invocations?: number;
|
|
20
|
+
location?: {
|
|
21
|
+
column: number;
|
|
22
|
+
line: number;
|
|
23
|
+
} | null;
|
|
24
|
+
numPassingAsserts: number;
|
|
25
|
+
retryMessages?: string[];
|
|
26
|
+
retryReasons?: string[];
|
|
27
|
+
startAt?: number | null;
|
|
28
|
+
status: Status;
|
|
29
|
+
title: string;
|
|
30
|
+
/** Set by `--collectTests` on a test that a run would start. */
|
|
31
|
+
wouldRun?: true;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* A serialized error (`TestResult.SerializableError`).
|
|
35
|
+
* @public
|
|
36
|
+
*/
|
|
37
|
+
interface SerializableError {
|
|
38
|
+
code?: unknown;
|
|
39
|
+
message: string;
|
|
40
|
+
stack: string | null | undefined;
|
|
41
|
+
type?: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* A `console` call a file made (`@jest/console` `LogEntry`).
|
|
45
|
+
* @public
|
|
46
|
+
*/
|
|
47
|
+
interface ConsoleEntry {
|
|
48
|
+
message: string;
|
|
49
|
+
origin: string;
|
|
50
|
+
type: string;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* What `onTestCaseStart` gets (`Circus.TestCaseStartInfo`, `@jest/types`).
|
|
54
|
+
* @public
|
|
55
|
+
*/
|
|
56
|
+
interface TestCaseStartInfo {
|
|
57
|
+
ancestorTitles: string[];
|
|
58
|
+
fullName: string;
|
|
59
|
+
mode: "skip" | "only" | "todo" | undefined;
|
|
60
|
+
title: string;
|
|
61
|
+
startedAt?: number | null;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* The shape of Jest's `displayName` project option.
|
|
65
|
+
* @public
|
|
66
|
+
*/
|
|
67
|
+
interface DisplayName {
|
|
68
|
+
name: string;
|
|
69
|
+
color: string;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* One file's result (`TestResult`). `console`, `coverage`, `v8Coverage` and `memoryUsage` are what
|
|
73
|
+
* Jest leaves out when it has none.
|
|
74
|
+
* @public
|
|
75
|
+
*/
|
|
76
|
+
interface TestResult {
|
|
77
|
+
console?: ConsoleEntry[] | undefined;
|
|
78
|
+
coverage?: Record<string, unknown>;
|
|
79
|
+
displayName?: DisplayName | undefined;
|
|
80
|
+
failing?: boolean;
|
|
81
|
+
failureMessage?: string | null;
|
|
82
|
+
leaks: boolean;
|
|
83
|
+
memoryUsage?: number;
|
|
84
|
+
numFailingTests: number;
|
|
85
|
+
numPassingTests: number;
|
|
86
|
+
numPendingTests: number;
|
|
87
|
+
numTodoTests: number;
|
|
88
|
+
openHandles: Error[];
|
|
89
|
+
perfStats: {
|
|
90
|
+
end: number;
|
|
91
|
+
loadTestEnvironmentEnd: number;
|
|
92
|
+
loadTestEnvironmentStart: number;
|
|
93
|
+
runtime: number;
|
|
94
|
+
setupAfterEnvEnd: number;
|
|
95
|
+
setupAfterEnvStart: number;
|
|
96
|
+
setupFilesEnd: number;
|
|
97
|
+
setupFilesStart: number;
|
|
98
|
+
slow: boolean;
|
|
99
|
+
start: number;
|
|
100
|
+
};
|
|
101
|
+
skipped: boolean;
|
|
102
|
+
snapshot: {
|
|
103
|
+
added: number;
|
|
104
|
+
fileDeleted: boolean;
|
|
105
|
+
matched: number;
|
|
106
|
+
unchecked: number;
|
|
107
|
+
uncheckedKeys: string[];
|
|
108
|
+
unmatched: number;
|
|
109
|
+
updated: number;
|
|
110
|
+
};
|
|
111
|
+
testExecError?: SerializableError | undefined;
|
|
112
|
+
testFilePath: string;
|
|
113
|
+
testResults: AssertionResult[];
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* The files that still had obsolete snapshots (`UncheckedSnapshot`).
|
|
117
|
+
* @public
|
|
118
|
+
*/
|
|
119
|
+
interface UncheckedSnapshot {
|
|
120
|
+
filePath: string;
|
|
121
|
+
keys: string[];
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* The run's snapshot totals (`SnapshotSummary`).
|
|
125
|
+
* @public
|
|
126
|
+
*/
|
|
127
|
+
interface SnapshotSummary {
|
|
128
|
+
added: number;
|
|
129
|
+
didUpdate: boolean;
|
|
130
|
+
failure: boolean;
|
|
131
|
+
filesAdded: number;
|
|
132
|
+
filesRemoved: number;
|
|
133
|
+
filesRemovedList: string[];
|
|
134
|
+
filesUnmatched: number;
|
|
135
|
+
filesUpdated: number;
|
|
136
|
+
matched: number;
|
|
137
|
+
total: number;
|
|
138
|
+
unchecked: number;
|
|
139
|
+
uncheckedKeysByFile: UncheckedSnapshot[];
|
|
140
|
+
unmatched: number;
|
|
141
|
+
updated: number;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* The run's results (`AggregatedResult`). `coverageMap` is set only once the reports are written
|
|
145
|
+
* (Jest's CoverageReporter sets it in its `onRunComplete`), so a reporter before it never sees one.
|
|
146
|
+
* @public
|
|
147
|
+
*/
|
|
148
|
+
interface AggregatedResult {
|
|
149
|
+
numFailedTests: number;
|
|
150
|
+
numFailedTestSuites: number;
|
|
151
|
+
numPassedTests: number;
|
|
152
|
+
numPassedTestSuites: number;
|
|
153
|
+
numPendingTests: number;
|
|
154
|
+
numTodoTests: number;
|
|
155
|
+
numPendingTestSuites: number;
|
|
156
|
+
numRuntimeErrorTestSuites: number;
|
|
157
|
+
numTotalTests: number;
|
|
158
|
+
numTotalTestSuites: number;
|
|
159
|
+
openHandles: Error[];
|
|
160
|
+
snapshot: SnapshotSummary;
|
|
161
|
+
startTime: number;
|
|
162
|
+
success: boolean;
|
|
163
|
+
testResults: TestResult[];
|
|
164
|
+
wasInterrupted: boolean;
|
|
165
|
+
runExecError?: SerializableError;
|
|
166
|
+
/** An `istanbul-lib-coverage` `CoverageMap` of the run's coverage, when it collected some. */
|
|
167
|
+
coverageMap?: unknown;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* What a `testResultsProcessor` module exports (`TestResultsProcessor`).
|
|
171
|
+
* @public
|
|
172
|
+
*/
|
|
173
|
+
type TestResultsProcessor = (results: AggregatedResult) => AggregatedResult | Promise<AggregatedResult>;
|
|
174
|
+
/**
|
|
175
|
+
* A file's result as `--json` prints it (`FormattedTestResult`).
|
|
176
|
+
* @public
|
|
177
|
+
*/
|
|
178
|
+
interface FormattedTestResult {
|
|
179
|
+
message: string;
|
|
180
|
+
name: string;
|
|
181
|
+
summary: string;
|
|
182
|
+
status: "failed" | "passed" | "skipped" | "focused";
|
|
183
|
+
startTime: number;
|
|
184
|
+
endTime: number;
|
|
185
|
+
coverage: unknown;
|
|
186
|
+
assertionResults: AssertionResult[];
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* The run's results as `--json` prints them (`FormattedTestResults`, which is the aggregate with
|
|
190
|
+
* its files formatted; a processor's own keys stay).
|
|
191
|
+
* @public
|
|
192
|
+
*/
|
|
193
|
+
interface FormattedTestResults extends Omit<AggregatedResult, "testResults"> {
|
|
194
|
+
testResults: FormattedTestResult[];
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* A test file of the run (`Test`): where it is and the project it belongs to. Jest's context also
|
|
198
|
+
* holds the haste map and resolver; here it is the project's config alone.
|
|
199
|
+
* @public
|
|
200
|
+
*/
|
|
201
|
+
interface Test<Config = unknown> {
|
|
202
|
+
context: TestContext<Config>;
|
|
203
|
+
duration?: number;
|
|
204
|
+
path: string;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* A project's context (`TestContext`), reduced to its `config`.
|
|
208
|
+
* @public
|
|
209
|
+
*/
|
|
210
|
+
interface TestContext<Config = unknown> {
|
|
211
|
+
config: Config;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* What `jest-message-util` reads of a project: `rootDir` and `testMatch`.
|
|
215
|
+
* @public
|
|
216
|
+
*/
|
|
217
|
+
interface StackTraceConfig {
|
|
218
|
+
readonly rootDir: string;
|
|
219
|
+
readonly testMatch: readonly string[];
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* `jest-message-util`'s `StackTraceOptions`.
|
|
223
|
+
* @public
|
|
224
|
+
*/
|
|
225
|
+
interface StackTraceOptions {
|
|
226
|
+
readonly noStackTrace: boolean;
|
|
227
|
+
readonly noCodeFrame?: boolean;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* The text Jest prints for the failures of one file's tests (`formatResultsErrors`), or `null`
|
|
231
|
+
* when none failed.
|
|
232
|
+
* @public
|
|
233
|
+
*/
|
|
234
|
+
declare function formatTestFailures(assertionResults: readonly AssertionResult[], config: StackTraceConfig, options: StackTraceOptions, testPath: string): Promise<string | null>;
|
|
235
|
+
/**
|
|
236
|
+
* The text Jest prints for an error that ended a file (`formatExecError`).
|
|
237
|
+
* @public
|
|
238
|
+
*/
|
|
239
|
+
declare function formatFileError(error: SerializableError, config: StackTraceConfig, options: StackTraceOptions, testPath: string): Promise<string>;
|
|
240
|
+
/**
|
|
241
|
+
* One retried attempt's error as Jest prints it (`formatErrorStack`, what `retryMessages` holds).
|
|
242
|
+
* @public
|
|
243
|
+
*/
|
|
244
|
+
declare function formatRetryError(stack: string, config: StackTraceConfig, options: StackTraceOptions, testPath: string): Promise<string>;
|
|
245
|
+
export { TestContext as _, formatTestFailures as a, UncheckedSnapshot as b, ConsoleEntry as c, FormattedTestResults as d, SerializableError as f, TestCaseStartInfo as g, Test as h, formatRetryError as i, DisplayName as l, Status as m, StackTraceOptions as n, AggregatedResult as o, SnapshotSummary as p, formatFileError as r, AssertionResult as s, StackTraceConfig as t, FormattedTestResult as u, TestResult as v, TestResultsProcessor as y };
|