UNPKG

@joellesenne/express-async-handler

Version:

Simple Middleware to manage exceptions within express routes in asynchronous

19 lines (15 loc) 388 B
const chai = require('chai') /** * @load modules UTILS */ const asyncHandler = require('../lib/index') const { expect } = chai describe('asyncHandler', () => { it('should catch exceptions of a function passed into it', async () => { const error = new Error('catch me!', 404) const foo = asyncHandler(() => { throw error }) expect(foo).to.throw(error) }) })