Add to Deno test
parent
3d3e3a319c
commit
2b2d05dd16
|
@ -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 { sentry } from '../deno_dist/mod.ts'
|
||||||
import { assertEquals, Hono } from './deps.ts'
|
import { assertEquals, Hono } from './deps.ts'
|
||||||
|
|
||||||
|
@ -18,8 +19,17 @@ Deno.test('Sentry Middleware', async () => {
|
||||||
const app = new Hono()
|
const app = new Hono()
|
||||||
app.use('/sentry/*', sentry())
|
app.use('/sentry/*', sentry())
|
||||||
app.get('/sentry/foo', (c) => c.text('foo'))
|
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')
|
let req = new Request('http://localhost/sentry/foo')
|
||||||
const res = await app.fetch(req, {}, new Context())
|
let res = await app.fetch(req, {}, new Context())
|
||||||
|
assertNotEquals(res, null)
|
||||||
assertEquals(res.status, 200)
|
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)
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue