E576 fix(config): also call `sync()` in initial setup · nuxt/test-utils@ec55519 · GitHub
[go: up one dir, main page]

Skip to content

Commit ec55519

Browse files
committed
fix(config): also call sync() in initial setup
1 parent 2b3c869 commit ec55519

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

src/runtime/shared/nuxt.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,14 @@ export async function setupNuxt() {
22
const { useRouter } = await import('#app/composables/router')
33
// @ts-expect-error alias to allow us to transform the entrypoint
44
await import('#app/nuxt-vitest-app-entry').then(r => r.default())
5-
// We must manually call `page:finish` to snc route after navigation
5+
// We must manually call `page:finish` to sync route after navigation
66
// as there is no `<NuxtPage>` instantiated by default.
77
const nuxtApp = useNuxtApp()
8-
await nuxtApp.callHook('page:finish')
9-
useRouter().afterEach(() => {
10-
if ('sync' in nuxtApp._route) {
11-
nuxtApp._route.sync?.()
12-
}
13-
else {
14-
return nuxtApp.callHook('page:finish')
15-
}
16-
})
8+
function sync() {
9+
return nuxtApp._route.sync
10+
? nuxtApp._route.sync()
11+
: nuxtApp.callHook('page:finish')
12+
}
13+
useRouter().afterEach(() => sync())
14+
return sync()
1715
}

0 commit comments

Comments
 (0)
0