This repository was archived by the owner on Mar 21, 2026. It is now read-only.
forked from Dreamlinerm/Netflix-Prime-Auto-Skip
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvitest.setup.ts
More file actions
63 lines (59 loc) · 1.31 KB
/
vitest.setup.ts
File metadata and controls
63 lines (59 loc) · 1.31 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
import { vi } from "vitest"
vi.mock("webext-bridge/content-script", () => {
console.log("Global mock for webext-bridge applied")
return {
sendMessage: vi.fn(),
onMessage: {
addListener: vi.fn(),
},
}
})
vi.mock("webextension-polyfill", () => {
console.log("Global mock for webextension-polyfill applied")
return {
runtime: {
sendMessage: vi.fn(),
},
storage: {
local: {
get: vi.fn(),
set: vi.fn(),
onChanged: {
addListener: vi.fn(),
},
},
},
}
})
const chromeMock = {
tabs: {
create: vi.fn(),
},
runtime: {
getURL: vi.fn((path) => `chrome-extension://mock/${path}`),
},
storage: {
local: {
get: vi.fn((key, callback) => callback({ [key]: "mockValue" })),
set: vi.fn((items, callback) => callback && callback()),
onChanged: {
addListener: vi.fn((callback) => {
// Simulate a change event
callback({ key: { newValue: "mockValue" } })
}),
},
},
sync: {
get: vi.fn((key, callback) => callback({ [key]: "mockValue" })),
set: vi.fn((items, callback) => callback && callback()),
onChanged: {
addListener: vi.fn((callback) => {
// Simulate a change event
callback({ key: { newValue: "mockValue" } })
}),
},
},
},
}
global.chrome = chromeMock
global.$t = (key) => key // Mock the $t function to return the key itself