From d357d58153db7fb6e10bef94490c6ab9d0ae9e9a Mon Sep 17 00:00:00 2001 From: Paul Guilbert Date: Fri, 13 Dec 2024 18:02:00 +0100 Subject: [PATCH] test: improve tests --- packages/nuxt/playground/pages/usage-after-await.vue | 7 +++++++ packages/nuxt/test/nuxt.spec.ts | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) 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' + ) }) })