-
-
Notifications
You must be signed in to change notification settings - Fork 1k
/
rpc.ts
42 lines (36 loc) · 1.56 KB
/
rpc.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
import type { RawSourceMap } from 'source-map'
import type { FetchResult, ViteNodeResolveId } from 'vite-node'
import type { EnvironmentOptions, ResolvedConfig, VitestEnvironment } from './config'
import type { UserConsoleLog } from './general'
import type { SnapshotResult } from './snapshot'
import type { File, TaskResultPack } from './tasks'
import type { AfterSuiteRunMeta } from './worker'
export interface RuntimeRPC {
fetch: (id: string, environment: VitestEnvironment) => Promise<FetchResult>
resolveId: (id: string, importer: string | undefined, environment: VitestEnvironment) => Promise<ViteNodeResolveId | null>
getSourceMap: (id: string, force?: boolean) => Promise<RawSourceMap | undefined>
onFinished: (files: File[], errors?: unknown[]) => void
onWorkerExit: (error: unknown, code?: number) => void
onPathsCollected: (paths: string[]) => void
onUserConsoleLog: (log: UserConsoleLog) => void
onUnhandledError: (err: unknown, type: string) => void
onCollected: (files: File[]) => void
onAfterSuiteRun: (meta: AfterSuiteRunMeta) => void
onTaskUpdate: (pack: TaskResultPack[]) => void
snapshotSaved: (snapshot: SnapshotResult) => void
resolveSnapshotPath: (testPath: string) => string
}
export interface RunnerRPC {
// TODO: This could be "(reason: 'INPUT' | 'BAIL') => void" instead
onCancel: () => void
}
export interface ContextTestEnvironment {
name: VitestEnvironment
options: EnvironmentOptions | null
}
export interface ContextRPC {
config: ResolvedConfig
files: string[]
invalidates?: string[]
environment: ContextTestEnvironment
}