Skip to content

Commit

Permalink
test: improve tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pguilbert committed Dec 13, 2024
1 parent 6888374 commit d357d58
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 7 additions & 0 deletions packages/nuxt/playground/pages/usage-after-await.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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()
</script>

Expand Down
4 changes: 3 additions & 1 deletion packages/nuxt/test/nuxt.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
)
})
})

0 comments on commit d357d58

Please sign in to comment.