Skip to content

Commit

Permalink
fix(runtime-utils): use tryUseNuxtApp rather than buildId override
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed May 14, 2024
1 parent c5f7773 commit 726e0a2
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
1 change: 0 additions & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ async function startNuxtAndGetViteConfig(
}),
overrides: defu(
{
buildId: 'nuxt-app',
ssr: false,
test: true,
modules: ['@nuxt/test-utils/module'],
Expand Down
5 changes: 2 additions & 3 deletions src/runtime-utils/mount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> = ComponentMountingOptions<T> & {
route?: RouteLocationRaw
Expand Down Expand Up @@ -57,8 +57,7 @@ export async function mountSuspended<T>(
..._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<string, unknown>, Record<string, unknown>>

let setupContext: SetupContext
Expand Down
5 changes: 2 additions & 3 deletions src/runtime-utils/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -62,8 +62,7 @@ export async function renderSuspended<T>(
'@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<string, unknown>, Record <string, unknown>>

// cleanup previously mounted test wrappers
Expand Down

0 comments on commit 726e0a2

Please sign in to comment.