Add callback test

pull/31/head
Samuel Lippert 2022-08-12 14:33:42 -05:00
parent e412336577
commit 3d3e3a319c
No known key found for this signature in database
GPG Key ID: 3762857AF8948B2C
1 changed files with 3 additions and 1 deletions

View File

@ -13,11 +13,12 @@ class Context implements ExecutionContext {
const captureException = jest.fn()
jest.mock('toucan-js', () => jest.fn().mockImplementation(() => ({ captureException })))
const callback = jest.fn()
describe('Sentry middleware', () => {
const app = new Hono()
app.use('/sentry/*', sentry())
app.use('/sentry/*', sentry(undefined, callback))
app.get('/sentry/foo', (c) => c.text('foo'))
app.get('/sentry/error', () => {
throw new Error('a catastrophic error')
@ -28,6 +29,7 @@ describe('Sentry middleware', () => {
const res = await app.fetch(req, {}, new Context())
expect(res).not.toBeNull()
expect(res.status).toBe(200)
expect(callback).toHaveBeenCalled()
})
it('Should report errors', async () => {