wangzhibo
2026-05-09 53418655c061ac26f66058253f39200aced1ab1d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/* global test, expect */
'use strict'
 
const build = require('..')
 
test('works with jest', done => {
  const { create, emit, emitted } = build()
 
  create('FastifyDeprecation', 'CODE', 'Hello %s')
  emit('CODE', 'world')
 
  // we cannot actually listen to process warning event
  // because jest messes with it (that's the point of this test)
  // we can only test it was emitted indirectly
  // and test no exception is raised
  setImmediate(() => {
    expect(emitted.get('CODE')).toBeTruthy()
    done()
  })
})