UNPKG

2.86 kBTypeScriptView Raw
1/**
2 * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
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 */
7import type { AggregatedResult, SerializableError, TestCaseResult, TestResult } from '@jest/test-result';
8import type { Config } from '@jest/types';
9import type { FS as HasteFS, ModuleMap } from 'jest-haste-map';
10import type Resolver from 'jest-resolve';
11import type { worker } from './CoverageWorker';
12export declare type ReporterOnStartOptions = {
13 estimatedTime: number;
14 showStatus: boolean;
15};
16export declare type Context = {
17 config: Config.ProjectConfig;
18 hasteFS: HasteFS;
19 moduleMap: ModuleMap;
20 resolver: Resolver;
21};
22export declare type Test = {
23 context: Context;
24 duration?: number;
25 path: Config.Path;
26};
27export declare type CoverageWorker = {
28 worker: typeof worker;
29};
30export declare type CoverageReporterOptions = {
31 changedFiles?: Set<Config.Path>;
32 sourcesRelatedToTestsInChangedFiles?: Set<Config.Path>;
33};
34export declare type CoverageReporterSerializedOptions = {
35 changedFiles?: Array<Config.Path>;
36 sourcesRelatedToTestsInChangedFiles?: Array<Config.Path>;
37};
38export declare type OnTestStart = (test: Test) => Promise<void>;
39export declare type OnTestFailure = (test: Test, error: SerializableError) => Promise<unknown>;
40export declare type OnTestSuccess = (test: Test, result: TestResult) => Promise<unknown>;
41export interface Reporter {
42 readonly onTestResult?: (test: Test, testResult: TestResult, aggregatedResult: AggregatedResult) => Promise<void> | void;
43 readonly onTestFileResult?: (test: Test, testResult: TestResult, aggregatedResult: AggregatedResult) => Promise<void> | void;
44 readonly onTestCaseResult?: (test: Test, testCaseResult: TestCaseResult) => Promise<void> | void;
45 readonly onRunStart: (results: AggregatedResult, options: ReporterOnStartOptions) => Promise<void> | void;
46 readonly onTestStart?: (test: Test) => Promise<void> | void;
47 readonly onTestFileStart?: (test: Test) => Promise<void> | void;
48 readonly onRunComplete: (contexts: Set<Context>, results: AggregatedResult) => Promise<void> | void;
49 readonly getLastError: () => Error | void;
50}
51export declare type SummaryOptions = {
52 currentTestCases?: Array<{
53 test: Test;
54 testCaseResult: TestCaseResult;
55 }>;
56 estimatedTime?: number;
57 roundTime?: boolean;
58 width?: number;
59};
60export declare type TestRunnerOptions = {
61 serial: boolean;
62};
63export declare type TestRunData = Array<{
64 context: Context;
65 matches: {
66 allTests: number;
67 tests: Array<Test>;
68 total: number;
69 };
70}>;
71export declare type TestSchedulerContext = {
72 firstRun: boolean;
73 previousSuccess: boolean;
74 changedFiles?: Set<Config.Path>;
75};