From 726e0a2dd94bd34309b1ca1f24fc3f5496db6058 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Tue, 14 May 2024 11:42:03 -0500 Subject: [PATCH] fix(runtime-utils): use `tryUseNuxtApp` rather than `buildId` override --- src/config.ts | 1 - src/runtime-utils/mount.ts | 5 ++--- src/runtime-utils/render.ts | 5 ++--- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/config.ts b/src/config.ts index 96e7b1be8..ac93f2eaa 100644 --- a/src/config.ts +++ b/src/config.ts @@ -34,7 +34,6 @@ async function startNuxtAndGetViteConfig( }), overrides: defu( { - buildId: 'nuxt-app', ssr: false, test: true, modules: ['@nuxt/test-utils/module'], diff --git a/src/runtime-utils/mount.ts b/src/runtime-utils/mount.ts index 9c8bc53a2..815619e93 100644 --- a/src/runtime-utils/mount.ts +++ b/src/runtime-utils/mount.ts @@ -9,7 +9,7 @@ import { RouterLink } from './components/RouterLink' // @ts-expect-error virtual file import NuxtRoot from '#build/root-component.mjs' -import { useRouter } from '#imports' +import { tryUseNuxtApp, useRouter } from '#imports' export type MountSuspendedOptions = ComponentMountingOptions & { route?: RouteLocationRaw @@ -57,8 +57,7 @@ export async function mountSuspended( ..._options } = options || {} - // @ts-expect-error untyped global __unctx__ - const vueApp = globalThis.__unctx__.get('nuxt-app').tryUse().vueApp + const vueApp = tryUseNuxtApp()!.vueApp const { render, setup } = component as DefineComponent, Record> let setupContext: SetupContext diff --git a/src/runtime-utils/render.ts b/src/runtime-utils/render.ts index fcab02801..dac44b5ef 100644 --- a/src/runtime-utils/render.ts +++ b/src/runtime-utils/render.ts @@ -8,7 +8,7 @@ import { RouterLink } from './components/RouterLink' // @ts-expect-error virtual file import NuxtRoot from '#build/root-component.mjs' -import { useRouter } from '#imports' +import { tryUseNuxtApp, useRouter } from '#imports' export type RenderOptions = TestingLibraryRenderOptions & { route?: RouteLocationRaw @@ -62,8 +62,7 @@ export async function renderSuspended( '@testing-library/vue' ) - // @ts-expect-error untyped global __unctx__ - const { vueApp } = globalThis.__unctx__.get('nuxt-app').tryUse() + const vueApp = tryUseNuxtApp()!.vueApp const { render, setup } = component as DefineComponent, Record > // cleanup previously mounted test wrappers