UNPKG

2.48 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 */
7/// <reference types="node" />
8import type { AggregatedResult } from '@jest/test-result';
9import type { Config } from '@jest/types';
10declare type TestSuiteInfo = {
11 config: Config.ProjectConfig;
12 duration?: number;
13 testPath: string;
14};
15export declare type JestHookExposedFS = {
16 projects: Array<{
17 config: Config.ProjectConfig;
18 testPaths: Array<Config.Path>;
19 }>;
20};
21export declare type FileChange = (fs: JestHookExposedFS) => void;
22export declare type ShouldRunTestSuite = (testSuiteInfo: TestSuiteInfo) => Promise<boolean>;
23export declare type TestRunComplete = (results: AggregatedResult) => void;
24export declare type JestHookSubscriber = {
25 onFileChange: (fn: FileChange) => void;
26 onTestRunComplete: (fn: TestRunComplete) => void;
27 shouldRunTestSuite: (fn: ShouldRunTestSuite) => void;
28};
29export declare type JestHookEmitter = {
30 onFileChange: (fs: JestHookExposedFS) => void;
31 onTestRunComplete: (results: AggregatedResult) => void;
32 shouldRunTestSuite: (testSuiteInfo: TestSuiteInfo) => Promise<boolean> | boolean;
33};
34export declare type UsageData = {
35 key: string;
36 prompt: string;
37};
38export declare type AllowedConfigOptions = Partial<Pick<Config.GlobalConfig, 'bail' | 'changedSince' | 'collectCoverage' | 'collectCoverageFrom' | 'collectCoverageOnlyFrom' | 'coverageDirectory' | 'coverageReporters' | 'findRelatedTests' | 'nonFlagArgs' | 'notify' | 'notifyMode' | 'onlyFailures' | 'reporters' | 'testNamePattern' | 'testPathPattern' | 'updateSnapshot' | 'verbose'> & {
39 mode: 'watch' | 'watchAll';
40}>;
41export declare type UpdateConfigCallback = (config?: AllowedConfigOptions) => void;
42export interface WatchPlugin {
43 isInternal?: boolean;
44 apply?: (hooks: JestHookSubscriber) => void;
45 getUsageInfo?: (globalConfig: Config.GlobalConfig) => UsageData | null;
46 onKey?: (value: string) => void;
47 run?: (globalConfig: Config.GlobalConfig, updateConfigAndRun: UpdateConfigCallback) => Promise<void | boolean>;
48}
49export interface WatchPluginClass {
50 new (options: {
51 config: Record<string, unknown>;
52 stdin: NodeJS.ReadStream;
53 stdout: NodeJS.WriteStream;
54 }): WatchPlugin;
55}
56export declare type ScrollOptions = {
57 offset: number;
58 max: number;
59};
60export {};