freshyo/apps/user-ui/tests/setup.ts
2026-10-18 21:51:01 +05:30

36 lines
1.1 KiB
TypeScript

/* eslint-disable @typescript-eslint/no-explicit-any */
/**
* Global test environment for apps/user-ui.
*
* Native / platform modules are redirected to shared shims through
* `jest.config.js#moduleNameMapper`; this file only installs process-wide
* globals that every suite needs.
*/
// Presigned uploads (useUploadToObjectStore) go through the global fetch.
if (typeof global.fetch !== 'function') {
;(global as any).fetch = jest.fn(async () => ({ ok: true, status: 200 }))
}
// Silence noisy console output that the app logs during render.
const IGNORED_CONSOLE = [
/location permission/,
/location coords/,
/essentialConsts request/,
/\[user-ui\]/,
]
const originalConsoleError = console.error
console.error = (...args: any[]) => {
const message = String(args[0] ?? '')
if (IGNORED_CONSOLE.some((pattern) => pattern.test(message))) return
originalConsoleError(...args)
}
console.log = jest.fn()
console.warn = jest.fn()
// React 19 + testing-library act() environment.
;(global as any).IS_REACT_ACT_ENVIRONMENT = true
afterEach(() => {
jest.clearAllTimers()
})