global vikePageContext

This commit is contained in:
Ulf Gebhardt 2024-01-09 22:40:08 +01:00
parent e3633865b0
commit 7d88532aaf
Signed by: ulfgebhardt
GPG Key ID: DA6B843E748679C9
3 changed files with 9 additions and 4 deletions

View File

@ -0,0 +1,8 @@
import { config } from '@vue/test-utils'
import { vikePageContext } from '#context/usePageContext'
config.global.provide = {
...config.global.provide,
[vikePageContext as symbol]: { urlPathname: '/some-url' },
}

View File

@ -2,8 +2,6 @@ import { mount } from '@vue/test-utils'
import { navigate } from 'vike/client/router'
import { describe, it, expect, beforeEach, vi } from 'vitest'
import { vikePageContext } from '#context/usePageContext'
import VikeBtn from './VikeBtn.vue'
vi.mock('vike/client/router')
@ -12,7 +10,6 @@ vi.mocked(navigate).mockResolvedValue()
describe('VikeBtn', () => {
const Wrapper = () => {
return mount(VikeBtn, {
global: { provide: { [vikePageContext as symbol]: { urlPathname: '/some-url' } } },
attrs: { href: '/some-path' },
})
}

View File

@ -8,7 +8,7 @@ export default mergeConfig(
test: {
globals: true,
environment: 'happy-dom',
setupFiles: ['scripts/tests/mock.$t.ts', 'scripts/tests/plugin.vuetify.ts'],
setupFiles: ['scripts/tests/mock.$t.ts', 'scripts/tests/mock.vikePageContext.ts', 'scripts/tests/plugin.vuetify.ts'],
coverage: {
all: true,
include: ['src/**/*.{js,jsx,ts,tsx,vue}'],