jest.test.js 517 B

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