Skip to content

Commit

Permalink
fix(runtime-utils): use appId fallback after tryUseNuxtApp (#849)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe authored May 20, 2024
1 parent 25e081e commit 81a9a72
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ async function startNuxtAndGetViteConfig(
}),
overrides: defu(
{
appId: 'nuxt-app',
buildId: 'test',
ssr: false,
test: true,
Expand Down
4 changes: 3 additions & 1 deletion src/runtime-utils/mount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ export async function mountSuspended<T>(
..._options
} = options || {}

const vueApp = tryUseNuxtApp()!.vueApp
const vueApp = tryUseNuxtApp()?.vueApp
// @ts-expect-error untyped global __unctx__
|| globalThis.__unctx__.get('nuxt-app').tryUse().vueApp
const { render, setup } = component as DefineComponent<Record<string, unknown>, Record<string, unknown>>

let setupContext: SetupContext
Expand Down
4 changes: 3 additions & 1 deletion src/runtime-utils/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ export async function renderSuspended<T>(
'@testing-library/vue'
)

const vueApp = tryUseNuxtApp()!.vueApp
const vueApp = tryUseNuxtApp()?.vueApp
// @ts-expect-error untyped global __unctx__
|| globalThis.__unctx__.get('nuxt-app').tryUse().vueApp
const { render, setup } = component as DefineComponent<Record<string, unknown>, Record <string, unknown>>

// cleanup previously mounted test wrappers
Expand Down

0 comments on commit 81a9a72

Please sign in to comment.