Skip to content

Commit

Permalink
refactor: test setup router mock
Browse files Browse the repository at this point in the history
  • Loading branch information
cuixiaorui committed Jun 16, 2023
1 parent 854f527 commit 801c8b7
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions apps/frontend/vitest.setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,20 @@ import {
} from 'vue-router-mock'
import { beforeEach, vi } from 'vitest'

// init vue-router
const router = createRouterMock({
spy: {
create: fn => vi.fn(fn),
reset: spy => spy.mockReset(),
},
})
beforeEach(() => {
injectRouterMock(router)
})
function setupRouterMock() {
const router = createRouterMock({
spy: {
create: fn => vi.fn(fn),
reset: spy => spy.mockClear(),
},
})

config.plugins.VueWrapper.install(VueRouterMock)
beforeEach(() => {
router.reset()
injectRouterMock(router)
})

config.plugins.VueWrapper.install(VueRouterMock)
}

setupRouterMock()

1 comment on commit 801c8b7

@vercel
Copy link

@vercel vercel bot commented on 801c8b7 Jun 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.