-
Notifications
You must be signed in to change notification settings - Fork 0
/
vitest.setup.ts
104 lines (89 loc) · 2.24 KB
/
vitest.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import { vi } from "vitest";
vi.stubEnv("GITHUB_WORKSPACE", "/github/workspace");
vi.mock("@actions/artifact");
vi.mock("@actions/core");
vi.mock("@actions/github", () => ({
default: {
context: {
repo: {
owner: "owner",
repo: "repo",
},
eventName: "push",
payload: {
pull_request: {
head: {
sha: "the_head_sha",
},
},
},
},
getOctokit: vi.fn(() => ({
rest: {
issues: {
listComments: vi.fn(() => Promise.resolve({ data: [] })),
updateComment: vi.fn(),
createComment: vi.fn(),
},
},
})),
},
}));
vi.mock("./src/lib/getInputs.js", () => ({
default: vi.fn(() => ({
sitemapUrl: "the_sitemap-url",
find: "the_find",
replace: "the_replace",
include: "",
ignore: "",
configPath: "",
})),
}));
vi.mock("./src/lib/getUrls.js", () => ({
default: vi.fn(() => Promise.resolve(["url1", "url2"])),
}));
vi.mock("./src/lib/readCsv.js", () => ({
default: vi.fn(() => Promise.resolve([])),
}));
vi.mock("./src/lib/sleep.js", () => ({
default: vi.fn(() => Promise.resolve(undefined)),
}));
vi.mock("./src/lib/writeCsv.js");
vi.mock("./src/services/github/downloadArtifact.js");
vi.mock("./src/services/github/findArtifact.js");
vi.mock("./src/services/github/findPr.js", () => ({
default: vi.fn(() =>
Promise.resolve({ number: 1, base: { sha: "the_base_sha" } })
),
}));
vi.mock("./src/services/github/getArtifact.js", () => ({
default: vi.fn(() => Promise.resolve({ url: "the_artifact_url" })),
}));
vi.mock("./src/services/github/upsertComment.js", () => ({
default: vi.fn(() => Promise.resolve(undefined)),
}));
vi.mock("fast-csv", () => ({
format: vi.fn(() => ({
pipe: vi.fn(),
write: vi.fn(),
end: vi.fn(),
})),
}));
vi.mock("fs", () => ({
createWriteStream: vi.fn(() => ({
write: vi.fn(),
end: vi.fn(),
on: vi.fn(),
once: vi.fn(),
emit: vi.fn(),
})),
existsSync: vi.fn(() => false),
unlinkSync: vi.fn(),
readFileSync: vi.fn(() => ""),
}));
vi.mock("node-fetch", () => ({
default: vi.fn(() => Promise.resolve({ text: vi.fn(() => "") })),
}));
vi.mock("pa11y", () => ({
default: vi.fn(() => Promise.resolve({ issues: [] })),
}));