28 lines
656 B
JavaScript
28 lines
656 B
JavaScript
import 'fake-indexeddb/auto'
|
|
|
|
// jsdom does not provide crypto.subtle — polyfill it with the real Web Crypto API
|
|
if (typeof globalThis.crypto === 'undefined' || !globalThis.crypto.subtle) {
|
|
const { webcrypto } = await import('node:crypto')
|
|
globalThis.crypto = webcrypto
|
|
}
|
|
|
|
// Mock window/document APIs
|
|
Object.defineProperty(globalThis, 'navigator', {
|
|
value: {
|
|
userAgent: 'node',
|
|
geolocation: {
|
|
getCurrentPosition: () => {},
|
|
},
|
|
},
|
|
writable: true,
|
|
})
|
|
|
|
// Mock matchMedia
|
|
globalThis.matchMedia = globalThis.matchMedia || function () {
|
|
return {
|
|
matches: false,
|
|
addListener: () => {},
|
|
removeListener: () => {},
|
|
}
|
|
}
|