From 3d3e3a319c5d721426770fdc6426e54df145ffc4 Mon Sep 17 00:00:00 2001 From: Samuel Lippert Date: Fri, 12 Aug 2022 14:33:42 -0500 Subject: [PATCH] Add callback test --- test/index.test.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/index.test.ts b/test/index.test.ts index ed31ef56..29a11e2e 100644 --- a/test/index.test.ts +++ b/test/index.test.ts @@ -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 () => {