42 lines
1.4 KiB
TypeScript
42 lines
1.4 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.
|
|
*/
|
|
|
|
import { configure } from '@testing-library/react-native'
|
|
import { installTrpcNetworkMock } from './mocks/trpc-client'
|
|
|
|
// The real tRPC client + React Query settle over several ticks. Under the full
|
|
// parallel suite a 1s `waitFor` budget is too tight, so give async utils 5s.
|
|
configure({ asyncUtilTimeout: 5000 })
|
|
|
|
// The REAL tRPC client runs in tests; only the network response is faked.
|
|
// This replaces `global.fetch` with the tRPC batch-aware registry mock.
|
|
installTrpcNetworkMock()
|
|
|
|
// 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()
|
|
})
|