File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -74,6 +74,13 @@ describe("koa middlewares", () => {
7474
7575 }
7676
77+ class TestCustomAsyncMiddlewareWhichThrows implements KoaMiddlewareInterface {
78+
79+ async use ( context : any , next ?: Function ) : Promise < any > {
80+ throw new NotAcceptableError ( "TestCustomAsyncMiddlewareWhichThrows" ) ;
81+ }
82+
83+ }
7784 @Controller ( )
7885 class KoaMiddlewareController {
7986
@@ -133,6 +140,12 @@ describe("koa middlewares", () => {
133140 return "1234" ;
134141 }
135142
143+ @Get ( "/customAsyncMiddlewareWhichThrows" )
144+ @UseBefore ( TestCustomAsyncMiddlewareWhichThrows )
145+ TestCustomAsyncMiddlewareWhichThrows ( ) {
146+ return "1234" ;
147+ }
148+
136149 }
137150 } ) ;
138151
@@ -199,4 +212,11 @@ describe("koa middlewares", () => {
199212 } ) ;
200213 } ) ;
201214
202- } ) ;
215+ it ( "should handle errors in custom async middlewares" , ( ) => {
216+ return chakram
217+ . get ( "http://127.0.0.1:3001/customAsyncMiddlewareWhichThrows" )
218+ . then ( ( response : any ) => {
219+ expect ( response ) . to . have . status ( 406 ) ;
220+ } ) ;
221+ } ) ;
222+ } ) ;
You can’t perform that action at this time.
0 commit comments