diff --git a/examples/app-vitest-full/pages/router/route.vue b/examples/app-vitest-full/pages/router/route.vue new file mode 100644 index 000000000..88155934f --- /dev/null +++ b/examples/app-vitest-full/pages/router/route.vue @@ -0,0 +1,9 @@ + + + diff --git a/examples/app-vitest-full/tests/nuxt/__snapshots__/mock-vue-router.spec.ts.snap b/examples/app-vitest-full/tests/nuxt/__snapshots__/mock-vue-router.spec.ts.snap new file mode 100644 index 000000000..0ce07216d --- /dev/null +++ b/examples/app-vitest-full/tests/nuxt/__snapshots__/mock-vue-router.spec.ts.snap @@ -0,0 +1,3 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`Index > should render correctly 1`] = `"
Index page, path: /123
"`; diff --git a/examples/app-vitest-full/tests/nuxt/mock-vue-router.spec.ts b/examples/app-vitest-full/tests/nuxt/mock-vue-router.spec.ts new file mode 100644 index 000000000..250f199c6 --- /dev/null +++ b/examples/app-vitest-full/tests/nuxt/mock-vue-router.spec.ts @@ -0,0 +1,19 @@ +import { describe, expect, it, vi } from 'vitest' +import { mountSuspended } from '@nuxt/test-utils/runtime' +import Index from '~/pages/router/route.vue' + +vi.mock('vue-router', () => ({ + useRoute: vi.fn(() => ({ + meta: {}, + path: '/123', + query: {}, + })), +})) + +describe('Index', async () => { + const wrapper = await mountSuspended(Index) + + it('should render correctly', () => { + expect(wrapper.html()).toMatchSnapshot() + }) +})