Skip to content

Commit f14eb56

Browse files
pguilbertposva
authored andcommitted
test: improve tests
1 parent f78f59e commit f14eb56

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

packages/nuxt/playground/pages/usage-after-await.vue

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ const useFancyCounter = async () => {
66
return useCounter()
77
}
88
9+
const event = useRequestEvent()
10+
useNuxtApp().hook('vue:error', (error) => {
11+
if (event) {
12+
setResponseStatus(event, 500, String(error))
13+
}
14+
})
15+
916
const counter = await useFancyCounter()
1017
</script>
1118

packages/nuxt/test/nuxt.spec.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ describe('Nuxt', async () => {
3939
})
4040

4141
it('throws an error server-side when the nuxt context is not available', async () => {
42-
await expect($fetch('/usage-after-await')).rejects.toThrow()
42+
await expect($fetch('/usage-after-await')).rejects.toThrowError(
43+
'[nuxt] instance unavailable'
44+
)
4345
})
4446
})

0 commit comments

Comments
 (0)