]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
test: fix error spy
authorEduardo San Martin Morote <posva13@gmail.com>
Thu, 18 Feb 2021 21:53:23 +0000 (22:53 +0100)
committerEduardo San Martin Morote <posva13@gmail.com>
Thu, 18 Feb 2021 21:53:23 +0000 (22:53 +0100)
__tests__/lazyLoading.spec.ts

index 62a4c3b928067100b9f658b35131a2a825618883..54bfffe8e806a0605122a842dff88a2b91c7a16a 100644 (file)
@@ -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: '/',