generated from freeCodeCamp/template
-
-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathtest-evaluator.ts
More file actions
66 lines (58 loc) · 1.35 KB
/
test-evaluator.ts
File metadata and controls
66 lines (58 loc) · 1.35 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
type Level = "log" | "warn" | "error" | "info" | "debug" | "trace";
interface Logged {
logs?: { level: Level; msg: string }[];
}
export interface Pass extends Logged {
pass: true;
}
export interface TestError {
message: string;
stack?: string;
// TODO: enforce string for expected and actual?
expected?: unknown;
actual?: unknown;
type?: string;
name?: string;
}
export interface Fail extends Logged {
err: TestError;
}
export type TestEvent = MessageEvent<{ type: "test"; value: string }>;
export type CodeEvent = MessageEvent<{ type: "code"; value: string }>;
export type InitEvent<Data> = MessageEvent<{
type: "init";
value: Data;
}>;
export interface InitTestFrameOptions {
code?: {
contents?: string;
editableContents?: string;
};
loadEnzyme?: boolean;
source?: string;
hooks?: {
beforeAll?: string;
beforeEach?: string;
afterEach?: string;
afterAll?: string;
};
allowAnimations?: boolean;
}
export interface InitWorkerOptions {
code?: {
contents?: string;
editableContents?: string;
};
source?: string;
hooks?: {
beforeEach?: string;
beforeAll?: string;
afterEach?: string;
afterAll?: string;
};
}
export interface TestEvaluator {
init(opts: unknown): Promise<void> | void;
runTest(test: string): Promise<Pass | Fail>;
handleMessage(e: MessageEvent): Promise<void>;
}