Add to Deno test

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

View File

@ -1,3 +1,4 @@
import { assertNotEquals } from 'https://deno.land/std@0.148.0/testing/asserts.ts'
import { sentry } from '../deno_dist/mod.ts'
import { assertEquals, Hono } from './deps.ts'
@ -18,8 +19,17 @@ Deno.test('Sentry Middleware', async () => {
const app = new Hono()
app.use('/sentry/*', sentry())
app.get('/sentry/foo', (c) => c.text('foo'))
app.get('/sentry/error', () => {
throw new Error('a catastrophic error')
})
const req = new Request('http://localhost/sentry/foo')
const res = await app.fetch(req, {}, new Context())
let req = new Request('http://localhost/sentry/foo')
let res = await app.fetch(req, {}, new Context())
assertNotEquals(res, null)
assertEquals(res.status, 200)
req = new Request('http://localhost/sentry/error')
res = await app.fetch(req, {}, new Context())
assertNotEquals(res, null)
assertEquals(res.status, 500)
})