UNPKG

485 BJavaScriptView Raw
1'use strict'
2
3const t = require('tap')
4const Fastify = require('..')
5const fastify = Fastify()
6
7fastify.route({
8 method: 'POST',
9 path: '/jsonBody',
10 handler: function (req, reply) {
11 throw new Error('kaboom')
12 }
13})
14
15const reqOpts = {
16 method: 'POST',
17 url: '/jsonBody',
18 payload: {
19 hello: 'world'
20 }
21}
22
23process.on('uncaughtException', (err) => {
24 t.equal(err.message, 'kaboom')
25})
26
27fastify.inject(reqOpts, (e, res) => {
28 t.plan(1)
29 t.fail('should not be called')
30})