UNPKG

express-async-wrapper

Version:

Wrap async express routes so exceptions can be caught by middleware.

21 lines (16 loc) 431 B
const chai = require('chai') const wrapper = require('./index') chai.use(require('chai-as-promised')) const expect = chai.expect describe('express-async-wrapper', () => { it('should wrap provided function and catch any exceptions', async () => { const error = new Error('catch me!') return expect( wrapper( async () => { throw error } )() ).to.be.rejectedWith(error) }) })