Skip to content

Commit bfe0176

Browse files
author
ntwigg
committed
Use WXT's testing harness, don't reinvent the wheel.
1 parent 728dbc0 commit bfe0176

File tree

2 files changed

+2
-45
lines changed

2 files changed

+2
-45
lines changed

browser-extension/tests/setup.ts

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1 @@
11
import '@testing-library/jest-dom/vitest'
2-
import { vi } from 'vitest'
3-
4-
// Mock browser APIs
5-
interface GlobalWithBrowser {
6-
browser: {
7-
runtime: {
8-
sendMessage: ReturnType<typeof vi.fn>
9-
onMessage: {
10-
addListener: ReturnType<typeof vi.fn>
11-
}
12-
}
13-
}
14-
chrome: GlobalWithBrowser['browser']
15-
}
16-
17-
const globalWithBrowser = global as unknown as GlobalWithBrowser
18-
19-
globalWithBrowser.browser = {
20-
runtime: {
21-
onMessage: {
22-
addListener: vi.fn(),
23-
},
24-
sendMessage: vi.fn(),
25-
},
26-
}
27-
28-
globalWithBrowser.chrome = globalWithBrowser.browser
29-
30-
// Mock console methods to reduce noise in tests
31-
global.console = {
32-
...console,
33-
debug: vi.fn(),
34-
error: vi.fn(),
35-
info: vi.fn(),
36-
log: vi.fn(),
37-
warn: vi.fn(),
38-
}

browser-extension/vitest.config.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
1-
import path from 'node:path'
21
import { defineConfig } from 'vitest/config'
2+
import { WxtVitest } from 'wxt/testing'
33

44
export default defineConfig({
5-
resolve: {
6-
alias: {
7-
'@': path.resolve(__dirname, './entrypoints'),
8-
'@content': path.resolve(__dirname, './entrypoints/content'),
9-
'@utils': path.resolve(__dirname, './entrypoints/content/utils'),
10-
},
11-
},
5+
plugins: [WxtVitest()],
126
test: {
137
coverage: {
148
exclude: [

0 commit comments

Comments
 (0)