Skip to content

Commit 1f3d17a

Browse files
committed
test: improve tests
1 parent 5b6c66d commit 1f3d17a

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
@@ -35,6 +35,8 @@ describe('works with nuxt', async () => {
3535
})
3636

3737
it('throws an error server-side when the nuxt context is not available', async () => {
38-
await expect($fetch('/usage-after-await')).rejects.toThrow()
38+
await expect($fetch('/usage-after-await')).rejects.toThrowError(
39+
'[nuxt] instance unavailable'
40+
)
3941
})
4042
})

0 commit comments

Comments
 (0)