File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -123,6 +123,39 @@ describe('json_error_handler', function() {
123123 } ) ;
124124 } ) ;
125125 } ) ;
126+
127+ describe ( 'includeErrStack:true' , function ( ) {
128+
129+ var context ;
130+ beforeEach ( function ( ) {
131+ var err = new Error ( 'this is a test' ) ;
132+ err . statusCode = 401 ;
133+ err . someAttr = 'value' ;
134+ context = {
135+ headers : { } ,
136+ error : err
137+ } ;
138+ } ) ;
139+
140+ it ( 'should allow the stack in the response body' , function ( done ) {
141+
142+ var jsonErrorHandler = json_error_handler ( { includeErrStack : true } ) ;
143+
144+ jsonErrorHandler ( context , function ( err , output ) {
145+ should . not . exist ( err ) ;
146+ should . not . exist ( context . error ) ;
147+
148+ var e ;
149+ try {
150+ var body = JSON . parse ( output ) ;
151+ body . should . have . property ( 'message' , 'this is a test' ) ;
152+ body . should . have . property ( 'someAttr' , 'value' ) ;
153+ body . should . have . property ( 'stack' )
154+ } catch ( x ) { e = x }
155+ done ( e )
156+ } ) ;
157+ } )
158+ } )
126159
127160 describe ( 'handle500Errors:true and error fails to stringify' , function ( ) {
128161 var jsonErrorHandler ;
You can’t perform that action at this time.
0 commit comments