-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjest.setup.ts
46 lines (38 loc) · 1.41 KB
/
jest.setup.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
43
44
45
46
import { useDescribe, useTest } from "./src/utils/apply-formatting.jest-plugin";
declare global {
function feature(name: JestFnInput, fn: jest.EmptyFunction): void;
function scenario(name: JestFnInput, fn: jest.EmptyFunction): void;
function given(name: JestFnInput, fn: jest.EmptyFunction): void;
function when(name: JestFnInput, fn: jest.EmptyFunction): void;
function then(
name: string,
fn?: jest.ProvidesCallback,
timeout?: number
): void;
}
type JestFnInput = string | number | Function | jest.FunctionLike;
globalThis.feature = useDescribe(describe, ({ color, bold, description }) =>
color("magenta", `Feature: 🚀 ${bold(description)}`)
);
globalThis.scenario = useDescribe(describe, ({ color, bold, description }) =>
color("cyan", `Scenario: ${bold(description)}`)
);
globalThis.given = useDescribe(describe, ({ color, bold, description }) =>
color("blue", `Given ${bold(description)}`)
);
globalThis.when = useDescribe(describe, ({ color, bold, description }) =>
color("yellow", `When ⚡ ${bold(description)}`)
);
globalThis.then = useTest(
it,
({ color, bold, description }) =>
"\x1b[0m" + color("green", `Then ${bold(description)}`)
);
globalThis.describe = useDescribe(describe, ({ color, bold, description }) =>
color("yellow", `${bold(description)}`)
);
globalThis.it = useTest(
it,
({ color, bold, description }) =>
"\x1b[0m" + color("green", `${bold(description)}`)
);