Skip to content

Commit 6e7f877

Browse files
committed
test: fix error spy
1 parent 81c1412 commit 6e7f877

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

__tests__/lazyLoading.spec.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,15 @@ function createLazyComponent() {
2626

2727
describe('Lazy Loading', () => {
2828
mockWarn()
29+
let consoleErrorSpy: jest.SpyInstance
30+
beforeEach(() => {
31+
consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation(() => {})
32+
})
33+
34+
afterEach(() => {
35+
consoleErrorSpy.mockRestore()
36+
})
37+
2938
it('works', async () => {
3039
const { component, resolve } = createLazyComponent()
3140
const { router } = newRouter({
@@ -250,11 +259,12 @@ describe('Lazy Loading', () => {
250259

251260
const spy = jest.fn()
252261

253-
reject(new Error('fail'))
262+
const error = new Error('fail')
263+
reject(error)
254264
await router.push('/foo').catch(spy)
255265

256266
expect(spy).toHaveBeenCalled()
257-
expect('fail').toHaveBeenWarned()
267+
expect(console.error).toHaveBeenCalledWith(error)
258268

259269
expect(router.currentRoute.value).toMatchObject({
260270
path: '/',

0 commit comments

Comments
 (0)