import { within } from './context'; import { spyContext, SpyHandle } from './jest'; const errorMatcher = /Error: Not implemented: navigation/; export function silenceNavigationErrors( fn: (waitForNavigation: () => Promise) => TResult, ): TResult { return within( spyContext(console, 'error'), (spy: SpyHandle) => { spy.mockImplementation((...args: Parameters) => { if (!errorMatcher.test(args[0])) { spy.original(...args); } }); return fn(() => spy.waitForCall(([msg]: Parameters) => errorMatcher.test(msg), ), ); }, ); }