Skip to content

Commit 78f9d37

Browse files
committed
Add types
1 parent 7b0c55b commit 78f9d37

8 files changed

+185
-0
lines changed

entrypoints/internal.cjs

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = {};

entrypoints/internal.d.cts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "./internal"

entrypoints/internal.d.mts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "./internal"

entrypoints/internal.d.ts

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import type {StateChangeEvent} from '../types/state-change-events.d.cts';
2+
3+
export type RunEvent = {
4+
type: 'stateChange';
5+
stateChange: StateChangeEvent;
6+
} | {
7+
type: 'run';
8+
plan: {
9+
bailWithoutReporting: boolean;
10+
debug: boolean;
11+
failFastEnabled: boolean;
12+
filePathPrefix: string;
13+
files: string[];
14+
matching: boolean;
15+
previousFailures: number;
16+
runOnlyExclusive: boolean;
17+
firstRun: boolean;
18+
};
19+
};
20+
21+
export type {StateChangeEvent} from '../types/state-change-events.d.cts';
22+
23+
export type Run = {
24+
events: AsyncIterableIterator<RunEvent>;
25+
};

entrypoints/internal.mjs

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export {};

internal.d.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// For compatibility with resolution algorithms other than Node16.
2+
3+
export * from './entrypoints/internal.cjs';

package.json

+10
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,16 @@
2929
"types": "./entrypoints/plugin.d.cts",
3030
"default": "./entrypoints/plugin.cjs"
3131
}
32+
},
33+
"./internal": {
34+
"import": {
35+
"types": "./entrypoints/internal.d.mts",
36+
"default": "./entrypoints/internal.mjs"
37+
},
38+
"require": {
39+
"types": "./entrypoints/internal.d.cts",
40+
"default": "./entrypoints/internal.cjs"
41+
}
3242
}
3343
},
3444
"type": "module",

types/state-change-events.d.cts

+143
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
type ErrorSource = {
2+
isDependency: boolean
3+
isWithinProject: boolean
4+
file: string
5+
line: number
6+
}
7+
8+
type SerializedErrorBase = {
9+
message: string
10+
name: string,
11+
originalError: unknown,
12+
stack: string
13+
}
14+
15+
type AggregateSerializedError = SerializedErrorBase & {
16+
type: "aggregate"
17+
errors: SerializedError[]
18+
}
19+
20+
type NativeSerializedError = SerializedErrorBase & {
21+
type: "native"
22+
source: ErrorSource | null
23+
}
24+
25+
type AVASerializedError = SerializedErrorBase & {
26+
type: "ava"
27+
assertion: string
28+
improperUsage: unknown | null
29+
formattedCause: unknown | null
30+
formattedDetails: unknown | unknown[]
31+
source: ErrorSource | null
32+
}
33+
34+
type SerializedError = AggregateSerializedError | NativeSerializedError | AVASerializedError
35+
36+
export type StateChangeEvent = {
37+
type: "starting",
38+
testFile: string
39+
} | {
40+
type: "stats",
41+
stats: {
42+
byFile: Map<string, {
43+
declaredTests: number
44+
failedHooks: number,
45+
failedTests: number,
46+
internalErrors: number
47+
remainingTests: number,
48+
passedKnownFailingTests: number,
49+
passedTests: number,
50+
selectedTests: number,
51+
selectingLines: boolean,
52+
skippedTests: number,
53+
todoTests: number,
54+
uncaughtExceptions: number,
55+
unhandledRejections: number,
56+
}>
57+
declaredTests: number
58+
failedHooks: number,
59+
failedTests: number,
60+
failedWorkers: number,
61+
files: number,
62+
parallelRuns: {
63+
currentIndex: number,
64+
totalRuns: number
65+
} | null
66+
finishedWorkers: number,
67+
internalErrors: number
68+
remainingTests: number,
69+
passedKnownFailingTests: number,
70+
passedTests: number,
71+
selectedTests: number,
72+
sharedWorkerErrors: number,
73+
skippedTests: number,
74+
timedOutTests: number,
75+
timeouts: number,
76+
todoTests: number,
77+
uncaughtExceptions: number,
78+
unhandledRejections: number,
79+
}
80+
} | {
81+
type: "declared-test"
82+
title: string
83+
knownFailing: boolean
84+
todo: boolean
85+
testFile: string
86+
} | {
87+
type: "selected-test"
88+
title: string
89+
knownFailing: boolean
90+
skip: boolean
91+
todo: boolean
92+
testFile: string
93+
} | {
94+
type: "test-register-log-reference"
95+
title: string
96+
logs: string[]
97+
testFile: string
98+
} | {
99+
type: "test-passed",
100+
title: string
101+
duration: number
102+
knownFailing: boolean
103+
logs: string[]
104+
testFile: string
105+
} | {
106+
type: "test-failed",
107+
title: string
108+
err: SerializedError,
109+
duration: number
110+
knownFailing: boolean
111+
logs: string[]
112+
testFile: string
113+
} | {
114+
type: "worker-finished",
115+
forcedExit: boolean,
116+
testFile: string
117+
} | {
118+
type: "worker-failed",
119+
nonZeroExitCode?: boolean,
120+
signal?: string,
121+
err?: SerializedError
122+
} | {
123+
type: "touched-files",
124+
files: {
125+
changedFiles: string[],
126+
temporaryFiles: string[]
127+
}
128+
} | {
129+
type: 'worker-stdout',
130+
chunk: Uint8Array
131+
testFile: string
132+
} | {
133+
type: 'worker-stderr',
134+
chunk: Uint8Array
135+
testFile: string
136+
} | {
137+
type: "timeout",
138+
period: number,
139+
pendingTests: Map<string, Set<string>>
140+
}
141+
| {
142+
type: "end"
143+
}

0 commit comments

Comments
 (0)