1 | const { test } = require('tap')
|
2 | const Fastify = require('..')
|
3 |
|
4 | test('Should accept a custom genReqId function', t => {
|
5 | t.plan(4)
|
6 |
|
7 | const fastify = Fastify({
|
8 | genReqId: function () {
|
9 | return 'a'
|
10 | }
|
11 | })
|
12 |
|
13 | fastify.get('/', (req, reply) => {
|
14 | t.ok(req.raw.id)
|
15 | reply.send({ id: req.raw.id })
|
16 | })
|
17 |
|
18 | fastify.listen(0, err => {
|
19 | t.error(err)
|
20 | fastify.inject({
|
21 | method: 'GET',
|
22 | url: 'http://localhost:' + fastify.server.address().port
|
23 | }, (err, res) => {
|
24 | t.error(err)
|
25 | const payload = JSON.parse(res.payload)
|
26 | t.equal(payload.id, 'a')
|
27 | fastify.close()
|
28 | })
|
29 | })
|
30 | })
|