Skip to content

Commit

Permalink
better test for errors before yield
Browse files Browse the repository at this point in the history
  • Loading branch information
remorses committed Jul 30, 2024
1 parent 36dd638 commit 9329516
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions test/response/stream.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,15 @@ describe('Stream', () => {
'event: message\ndata: "a"\n\nevent: error\ndata: "an error"\n\n'
)
})

it('handle errors before yield', async () => {
const app = new Elysia().get('/', async function* () {
throw new Error('an error')
})
const app = new Elysia()
.onError(({ error }) => {
return new Response(error.message)
})
.get('/', async function* () {
throw new Error('an error')
})

const response = await app.handle(req('/')).then((x) => x.text())

Expand Down

0 comments on commit 9329516

Please sign in to comment.