MOBILE-3674 tests: Fail on unhandled errors

main
Noel De Martin 2021-05-25 11:49:09 +02:00
parent 86a279c72f
commit 39c0570b4a
2 changed files with 8 additions and 0 deletions

View File

@ -22,6 +22,7 @@ import { Network, Platform, NgZone } from '@singletons';
import { mockSingleton, renderComponent } from '@/testing/utils'; import { mockSingleton, renderComponent } from '@/testing/utils';
import { CoreNavigator, CoreNavigatorService } from '@services/navigator'; import { CoreNavigator, CoreNavigatorService } from '@services/navigator';
import { CoreSitePlugins } from '@features/siteplugins/services/siteplugins';
describe('AppComponent', () => { describe('AppComponent', () => {
@ -33,6 +34,7 @@ describe('AppComponent', () => {
mockSingleton(Network, { onChange: () => new Observable() }); mockSingleton(Network, { onChange: () => new Observable() });
mockSingleton(Platform, { ready: () => Promise.resolve(), resume: new Subject<void>() }); mockSingleton(Platform, { ready: () => Promise.resolve(), resume: new Subject<void>() });
mockSingleton(NgZone, { run: jest.fn() }); mockSingleton(NgZone, { run: jest.fn() });
mockSingleton(CoreSitePlugins, { hasSitePluginsLoaded: false });
navigator = mockSingleton(CoreNavigator, ['navigate']); navigator = mockSingleton(CoreNavigator, ['navigate']);
langProvider = mockSingleton(CoreLang, ['clearCustomStrings']); langProvider = mockSingleton(CoreLang, ['clearCustomStrings']);

View File

@ -21,6 +21,12 @@ console.debug = () => {
// Silence. // Silence.
}; };
// eslint-disable-next-line no-console, jest/no-jasmine-globals, @typescript-eslint/no-explicit-any
console.error = (...args: any[]) => fail(args.map(a => a.toString()).join(''));
// eslint-disable-next-line jest/no-jasmine-globals
process.on('unhandledRejection', error => fail(error));
// Override the method to create singleton method proxies in order to facilitate setting up // Override the method to create singleton method proxies in order to facilitate setting up
// test expectations about method calls. // test expectations about method calls.
setCreateSingletonMethodProxy( setCreateSingletonMethodProxy(