From: Eduardo San Martin Morote Date: Thu, 18 Feb 2021 21:53:23 +0000 (+0100) Subject: test: fix error spy X-Git-Tag: v4.0.4~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6e7f877127ce2c52da3542c8142f9e5f35b372bc;p=thirdparty%2Fvuejs%2Frouter.git test: fix error spy --- diff --git a/__tests__/lazyLoading.spec.ts b/__tests__/lazyLoading.spec.ts index 62a4c3b9..54bfffe8 100644 --- a/__tests__/lazyLoading.spec.ts +++ b/__tests__/lazyLoading.spec.ts @@ -26,6 +26,15 @@ function createLazyComponent() { describe('Lazy Loading', () => { mockWarn() + let consoleErrorSpy: jest.SpyInstance + beforeEach(() => { + consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation(() => {}) + }) + + afterEach(() => { + consoleErrorSpy.mockRestore() + }) + it('works', async () => { const { component, resolve } = createLazyComponent() const { router } = newRouter({ @@ -250,11 +259,12 @@ describe('Lazy Loading', () => { const spy = jest.fn() - reject(new Error('fail')) + const error = new Error('fail') + reject(error) await router.push('/foo').catch(spy) expect(spy).toHaveBeenCalled() - expect('fail').toHaveBeenWarned() + expect(console.error).toHaveBeenCalledWith(error) expect(router.currentRoute.value).toMatchObject({ path: '/',