-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvitest.unit.setup.ts
More file actions
29 lines (26 loc) · 919 Bytes
/
vitest.unit.setup.ts
File metadata and controls
29 lines (26 loc) · 919 Bytes
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
/**
* Setup file for unit tests
* Provides a mock window object for browser API simulation
*/
// Create a minimal mock window object for unit tests
// The namespace is a singleton, so we don't reset it between tests
if (typeof global.window === "undefined") {
global.window = {} as unknown as Window & typeof globalThis;
}
// Suppress expected error logs from error isolation tests
// These tests intentionally throw errors to verify error handling
const originalError = console.error;
console.error = (...args: unknown[]) => {
// Filter out expected error logs from error isolation pattern
const message = args[0];
if (
typeof message === "string" &&
(message === "[__web_sqlite] Event callback error:" ||
message === "[LogDispatcher] Callback error:")
) {
// Suppress these expected error logs during tests
return;
}
// Pass through other errors
originalError(...args);
};