Skip to content

Commit a9a5281

Browse files
committed
fix: resolve vitest webidl-conversions errors
Fix unhandled errors with webidl-conversions and whatwg-url: - Add pool: "forks" to vitest config for better process isolation - Add global polyfills for Set, Map, WeakMap, WeakSet in test setup This resolves the "Cannot read properties of undefined" errors that were occurring during module loading in the test environment. All 292 tests now pass successfully.
1 parent 9f58e4b commit a9a5281

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/test/setup.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,15 @@
11
import "@testing-library/jest-dom/vitest";
2+
3+
// Polyfill for webidl-conversions and whatwg-url
4+
if (typeof global.Set === "undefined") {
5+
global.Set = Set;
6+
}
7+
if (typeof global.Map === "undefined") {
8+
global.Map = Map;
9+
}
10+
if (typeof global.WeakMap === "undefined") {
11+
global.WeakMap = WeakMap;
12+
}
13+
if (typeof global.WeakSet === "undefined") {
14+
global.WeakSet = WeakSet;
15+
}

vite.config.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export default defineConfig({
88
globals: true,
99
environment: "jsdom",
1010
setupFiles: ["./src/test/setup.ts"],
11+
pool: "forks",
1112
exclude: [
1213
"**/node_modules/**",
1314
"**/dist/**",

0 commit comments

Comments
 (0)