diff --git a/packages/nuxt/playground/pages/usage-after-await.vue b/packages/nuxt/playground/pages/usage-after-await.vue index adc86268d0..64af35d2ed 100644 --- a/packages/nuxt/playground/pages/usage-after-await.vue +++ b/packages/nuxt/playground/pages/usage-after-await.vue @@ -6,6 +6,13 @@ const useFancyCounter = async () => { return useCounter() } +const event = useRequestEvent() +useNuxtApp().hook('vue:error', (error) => { + if (event) { + setResponseStatus(event, 500, String(error)) + } +}) + const counter = await useFancyCounter() diff --git a/packages/nuxt/test/nuxt.spec.ts b/packages/nuxt/test/nuxt.spec.ts index a1bd848258..1e082e4b8c 100644 --- a/packages/nuxt/test/nuxt.spec.ts +++ b/packages/nuxt/test/nuxt.spec.ts @@ -35,6 +35,8 @@ describe('works with nuxt', async () => { }) it('throws an error server-side when the nuxt context is not available', async () => { - await expect($fetch('/usage-after-await')).rejects.toThrow() + await expect($fetch('/usage-after-await')).rejects.toThrowError( + '[nuxt] instance unavailable' + ) }) })