@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,248 @@
|
|
|
1
|
+
import { _ as TestContext, a as formatTestFailures, b as UncheckedSnapshot, c as ConsoleEntry, d as FormattedTestResults, f as SerializableError, g as TestCaseStartInfo, h as Test, i as formatRetryError, l as DisplayName, m as Status, n as StackTraceOptions, o as AggregatedResult, p as SnapshotSummary, r as formatFileError, s as AssertionResult, t as StackTraceConfig, u as FormattedTestResult, v as TestResult, y as TestResultsProcessor } from "../failure-message.js";
|
|
2
|
+
import { FileInfo, FileResult, Reporter, SerializedError, SnapshotRunSummary, TaskId, TaskNode, TaskResult, TestTask } from "@provino/types";
|
|
3
|
+
/**
|
|
4
|
+
* One test's events, as the collector keeps them.
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
interface TestRecord {
|
|
8
|
+
readonly task: TestTask;
|
|
9
|
+
/** The `task:end` result; absent for a test that never ended (a crashed worker). */
|
|
10
|
+
readonly result: TaskResult | undefined;
|
|
11
|
+
/** The coordinator's clock (ms since the epoch) when the test started. */
|
|
12
|
+
readonly startedAt: number | null;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* One file's events, as the collector keeps them.
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
interface FileEvents {
|
|
19
|
+
readonly info: FileInfo;
|
|
20
|
+
/** The file's absolute path. */
|
|
21
|
+
readonly testFilePath: string;
|
|
22
|
+
/** The file's tree (`file:collected`), or `undefined` when it never got that far. */
|
|
23
|
+
readonly tree: readonly TaskNode[] | undefined;
|
|
24
|
+
/** The file never loaded (`file-collect-end`'s `loadFailed`): its import threw, say. */
|
|
25
|
+
readonly loadFailed?: true;
|
|
26
|
+
/**
|
|
27
|
+
* The worker's runner failed the file after it ran (an unhandled error with the origin
|
|
28
|
+
* `runner`: the environment's teardown threw, say). Jest's `runTest` rejects then, so the
|
|
29
|
+
* scheduler's no-tests check never runs and the error is the file's.
|
|
30
|
+
*/
|
|
31
|
+
readonly runnerFailed?: true;
|
|
32
|
+
readonly records: ReadonlyMap<TaskId, TestRecord>;
|
|
33
|
+
/**
|
|
34
|
+
* The order each suite's children ran in, for the suites a randomized run shuffled
|
|
35
|
+
* (`TaskResult.childOrder` of their end events); the file's own is `result.childOrder`.
|
|
36
|
+
*/
|
|
37
|
+
readonly orders?: ReadonlyMap<TaskId, readonly TaskId[]>;
|
|
38
|
+
readonly result: FileResult;
|
|
39
|
+
/** Errors a worker reported for the file outside any test. */
|
|
40
|
+
readonly unhandled: readonly SerializedError[];
|
|
41
|
+
/** The coordinator's clock when the file started and ended. */
|
|
42
|
+
readonly startedAt: number;
|
|
43
|
+
readonly endedAt: number;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* What the build reads of the run's settings.
|
|
47
|
+
* @public
|
|
48
|
+
*/
|
|
49
|
+
interface BuildOptions {
|
|
50
|
+
/** `testLocationInResults`: whether each test's location is reported. */
|
|
51
|
+
readonly locations: boolean;
|
|
52
|
+
readonly displayName: TestResult["displayName"];
|
|
53
|
+
/** `slowTestThreshold`, in seconds (Jest's default 5). */
|
|
54
|
+
readonly slowTestThreshold?: number;
|
|
55
|
+
/**
|
|
56
|
+
* The run only collected (`--collectTests`): each test is reported as
|
|
57
|
+
* `collectTestsWithoutRunning` (jestAdapterInit.ts L174-L252) does, with no duration, location,
|
|
58
|
+
* start or invocation, and `makeCollectedTestResult` builds the file's result.
|
|
59
|
+
*/
|
|
60
|
+
readonly collectOnly?: boolean;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* `flattenErrorStack` (jest-message-util 30.5.2, index.ts L504-L551) over a serialized error: the
|
|
64
|
+
* stack (or the message when it has none, or is missing the message), then each `cause` and each
|
|
65
|
+
* of an aggregate's `errors` as `\n\n[cause]: …` and `\n\n[errors]: …`.
|
|
66
|
+
* @public
|
|
67
|
+
*/
|
|
68
|
+
export declare function flattenSerializedError(error: SerializedError): string;
|
|
69
|
+
/**
|
|
70
|
+
* One test's result. A test that never ended is `failed` with no message (its file's error says
|
|
71
|
+
* why). Jest counts a skipped test's invocations as 1 (`cli/json-vscode-contract`), so does this.
|
|
72
|
+
* @public
|
|
73
|
+
*/
|
|
74
|
+
export declare function toAssertionResult(record: TestRecord, options: BuildOptions): AssertionResult;
|
|
75
|
+
/**
|
|
76
|
+
* What an empty file is reported as: Jest fails a file with no test (TestScheduler.ts L176-L184).
|
|
77
|
+
* @public
|
|
78
|
+
*/
|
|
79
|
+
export declare const NO_TESTS_MESSAGE = "Your test suite must contain at least one test.";
|
|
80
|
+
/**
|
|
81
|
+
* What a file that leaks is failed with under `--detectLeaks` (TestScheduler.ts L153-L169): the
|
|
82
|
+
* message `onResult` builds, plain (Jest paints `EXPERIMENTAL FEATURE!` bold red, which a
|
|
83
|
+
* reporter's style can't reach from here), with one frame in Jest's own package, as for
|
|
84
|
+
* `NO_TESTS_MESSAGE`.
|
|
85
|
+
* @public
|
|
86
|
+
*/
|
|
87
|
+
export declare const LEAK_MESSAGE: string;
|
|
88
|
+
/**
|
|
89
|
+
* One file's `TestResult`, with `failureMessage` left `null` (the text comes from
|
|
90
|
+
* `jest-message-util`, asynchronously: `collect.ts` fills it).
|
|
91
|
+
*
|
|
92
|
+
* - A file that loaded and has no test result fails with `Your test suite must contain at least one
|
|
93
|
+
* test.`, whatever errors or leaks it holds (`onResult`, which tests only the results' length),
|
|
94
|
+
* unless the worker's runner failed it after it ran (`runnerFailed`): `runTest` rejected then.
|
|
95
|
+
* - A file that ended with errors and no test that ran, or never loaded, is a runtime error:
|
|
96
|
+
* `testExecError` is its first error.
|
|
97
|
+
* - A file with errors beside tests that ran has `testExecError` `{ message: '', stack }` with the
|
|
98
|
+
* errors joined by newlines, as Jest does for `unhandledErrors` (jestAdapterInit.ts L314-L319).
|
|
99
|
+
* @public
|
|
100
|
+
*/
|
|
101
|
+
export declare function toTestResult(file: FileEvents, options: BuildOptions): TestResult;
|
|
102
|
+
/**
|
|
103
|
+
* What the end of a run adds to the aggregate.
|
|
104
|
+
* @public
|
|
105
|
+
*/
|
|
106
|
+
interface RunEnd {
|
|
107
|
+
readonly reason: "passed" | "failed" | "interrupted" | "terminated" | "hangup";
|
|
108
|
+
readonly snapshots: SnapshotRunSummary | undefined;
|
|
109
|
+
/** A reporter failed (Jest's `anyReporterErrors`). */
|
|
110
|
+
readonly reporterFailed: boolean;
|
|
111
|
+
/**
|
|
112
|
+
* An unhandled error no file owns reached the run: one a test's timer threw after its file had
|
|
113
|
+
* ended, say, on which Jest's own process (or worker) would have crashed. It fails the run.
|
|
114
|
+
*/
|
|
115
|
+
readonly unownedError?: boolean;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* The aggregate's closing fields (TestScheduler.ts L87-L95 and L198-L212): `didUpdate`, snapshot
|
|
119
|
+
* `failure`, `wasInterrupted` and `success`. Mutates `aggregated`.
|
|
120
|
+
* @public
|
|
121
|
+
*/
|
|
122
|
+
export declare function finishAggregated(aggregated: AggregatedResult, end: RunEnd): void;
|
|
123
|
+
/**
|
|
124
|
+
* What the collector reads of a project's config.
|
|
125
|
+
* @public
|
|
126
|
+
*/
|
|
127
|
+
interface ProjectConfigLike extends StackTraceConfig {
|
|
128
|
+
readonly displayName?: DisplayName | undefined;
|
|
129
|
+
readonly slowTestThreshold?: number;
|
|
130
|
+
/** Jest reads `testLocationInResults` from the project's config (`--testLocationInResults`). */
|
|
131
|
+
readonly testLocationInResults: boolean;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* What the collector reads of the run's global config.
|
|
135
|
+
* @public
|
|
136
|
+
*/
|
|
137
|
+
interface GlobalConfigLike {
|
|
138
|
+
readonly noStackTrace: boolean;
|
|
139
|
+
/** `--silent`: no console buffer (`runTest.ts` uses a `NullConsole`). */
|
|
140
|
+
readonly silent?: boolean | undefined;
|
|
141
|
+
/** `--verbose`: the console prints as it is written, so no buffer is kept. */
|
|
142
|
+
readonly verbose?: boolean | undefined;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* What `createJestResults` needs.
|
|
146
|
+
* @public
|
|
147
|
+
*/
|
|
148
|
+
interface JestResultsOptions<Config extends ProjectConfigLike> {
|
|
149
|
+
readonly globalConfig: GlobalConfigLike;
|
|
150
|
+
/** The run's projects in the order of `FileInfo.projectIndex`. */
|
|
151
|
+
readonly projectConfigs: readonly Config[];
|
|
152
|
+
/** The run only collects (`--collectTests`): each file's result is `makeCollectedTestResult`'s. */
|
|
153
|
+
readonly collectOnly?: boolean;
|
|
154
|
+
/** The clock (`Date.now`), injected so a test can fix it. */
|
|
155
|
+
readonly now?: () => number;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* The collector `createJestResults` returns.
|
|
159
|
+
* @public
|
|
160
|
+
*/
|
|
161
|
+
interface JestResults<Config extends ProjectConfigLike> {
|
|
162
|
+
/** The neutral reporter, named `jest-results`. */
|
|
163
|
+
readonly reporter: Reporter;
|
|
164
|
+
/** The run's results so far; complete after `run:end`. */
|
|
165
|
+
aggregated(): AggregatedResult;
|
|
166
|
+
/** A finished file's result. */
|
|
167
|
+
testResultOf(fileId: TaskId): TestResult | undefined;
|
|
168
|
+
/**
|
|
169
|
+
* A failed file's `failureMessage` in blocks, as the text reporters print it: each failed test's
|
|
170
|
+
* (`formatResultsErrors` of its assertion, with its id), then the file's own errors. Joined by
|
|
171
|
+
* `\n`, the blocks are `failureMessage`. `undefined` for a file with no failure text.
|
|
172
|
+
*/
|
|
173
|
+
failureTextOf(fileId: TaskId): readonly JestFailureBlock[] | undefined;
|
|
174
|
+
/** The `Test` Jest's reporters get for a file. */
|
|
175
|
+
testOf(file: FileInfo): Test<Config>;
|
|
176
|
+
/** The projects that have a file in the run. */
|
|
177
|
+
contexts(): Set<TestContext<Config>>;
|
|
178
|
+
/** A test's result as `onTestCaseResult` gets it (`parseSingleTestResult`), once the test has ended. */
|
|
179
|
+
assertionOf(test: TestTask, retried?: {
|
|
180
|
+
readonly attempt: number;
|
|
181
|
+
readonly state: "pass" | "fail" | "skip";
|
|
182
|
+
readonly errors: readonly SerializedError[];
|
|
183
|
+
readonly passingAssertions?: number;
|
|
184
|
+
}): AssertionResult | undefined;
|
|
185
|
+
/** What `onTestCaseStart` gets for a test that has started (`createTestCaseStartInfo`). */
|
|
186
|
+
startInfoOf(test: TestTask): TestCaseStartInfo;
|
|
187
|
+
/**
|
|
188
|
+
* Tells the aggregate that a reporter failed, which the bus only knows once every reporter has
|
|
189
|
+
* heard the end of the run (Jest's `anyReporterErrors`): `success` goes false.
|
|
190
|
+
*/
|
|
191
|
+
reportersFailed(failed: boolean): void;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* One block of a failed file's text: a failed test's (`taskId`), or the file's own errors.
|
|
195
|
+
* @public
|
|
196
|
+
*/
|
|
197
|
+
interface JestFailureBlock {
|
|
198
|
+
readonly taskId?: TaskId;
|
|
199
|
+
readonly text: string;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Builds the collector. `file:end` formats the file's failure text with `jest-message-util`, so the
|
|
203
|
+
* handler is async and the bus waits for it.
|
|
204
|
+
* @public
|
|
205
|
+
*/
|
|
206
|
+
export declare function createJestResults<Config extends ProjectConfigLike>(options: JestResultsOptions<Config>): JestResults<Config>;
|
|
207
|
+
/**
|
|
208
|
+
* The run's results with each file formatted (`formatTestResults`, formatTestResults.ts L71-L81).
|
|
209
|
+
* @public
|
|
210
|
+
*/
|
|
211
|
+
export declare function formatJson(results: AggregatedResult): FormattedTestResults;
|
|
212
|
+
/**
|
|
213
|
+
* `JSON.stringify` with what `serializeToJSON` adds: an error as `{ message, name, stack }` and a
|
|
214
|
+
* `bigint` as its literal (`1n`).
|
|
215
|
+
* @public
|
|
216
|
+
*/
|
|
217
|
+
export declare function serializeToJson(value: unknown, space?: string | number): string;
|
|
218
|
+
/**
|
|
219
|
+
* An empty run (`makeEmptyAggregatedTestResult`, helpers.ts L16-L47).
|
|
220
|
+
* @public
|
|
221
|
+
*/
|
|
222
|
+
export declare function makeEmptyAggregatedTestResult(): AggregatedResult;
|
|
223
|
+
/**
|
|
224
|
+
* A file's empty result (`createEmptyTestResult`, helpers.ts L89-L117).
|
|
225
|
+
* @public
|
|
226
|
+
*/
|
|
227
|
+
export declare function createEmptyTestResult(): TestResult;
|
|
228
|
+
/**
|
|
229
|
+
* The result of a file that failed to run (`buildFailureTestResult`, helpers.ts L49-L77).
|
|
230
|
+
* @public
|
|
231
|
+
*/
|
|
232
|
+
export declare function buildFailureTestResult(testPath: string, err: SerializableError): TestResult;
|
|
233
|
+
/**
|
|
234
|
+
* Adds a file's result to the run's (`addResult`, helpers.ts L79-L151). Mutates `aggregated` and
|
|
235
|
+
* sets `testResult.numTodoTests` to 0 when it is missing, as Jest does.
|
|
236
|
+
* @public
|
|
237
|
+
*/
|
|
238
|
+
export declare function addResult(aggregated: AggregatedResult, testResult: TestResult): void;
|
|
239
|
+
/**
|
|
240
|
+
* A file's result built from its tests' results, with the counts by status
|
|
241
|
+
* (`makeCollectedTestResult`, helpers.ts L153-L185, used by `--collectTests`).
|
|
242
|
+
* @public
|
|
243
|
+
*/
|
|
244
|
+
export declare function makeCollectedTestResult(testResults: AssertionResult[], options: {
|
|
245
|
+
displayName: TestResult["displayName"];
|
|
246
|
+
testFilePath: string;
|
|
247
|
+
}): TestResult;
|
|
248
|
+
export { type AggregatedResult, type AssertionResult, type BuildOptions, type ConsoleEntry, type DisplayName, type FileEvents, type FormattedTestResult, type FormattedTestResults, type GlobalConfigLike, type JestFailureBlock, type JestResults, type JestResultsOptions, type ProjectConfigLike, type RunEnd, type SerializableError, type SnapshotSummary, type StackTraceConfig, type StackTraceOptions, type Status, type Test, type TestCaseStartInfo, type TestContext, type TestRecord, type TestResult, type TestResultsProcessor, type UncheckedSnapshot, formatFileError, formatRetryError, formatTestFailures };
|