File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -125,6 +125,14 @@ Test.prototype.run = function () {
125
125
self . exit ( ) ;
126
126
} )
127
127
. catch ( function ( err ) {
128
+ if ( ! ( err instanceof Error ) ) {
129
+ err = new assert . AssertionError ( {
130
+ actual : err ,
131
+ message : 'Promise rejected with "' + err + '"' ,
132
+ operator : 'promise'
133
+ } ) ;
134
+ }
135
+
128
136
self . _setAssertError ( err ) ;
129
137
self . exit ( ) ;
130
138
} ) ;
Original file line number Diff line number Diff line change @@ -250,3 +250,14 @@ test('reject', function (t) {
250
250
t . end ( ) ;
251
251
} ) ;
252
252
} ) ;
253
+
254
+ test ( 'reject with non-Error' , function ( t ) {
255
+ ava ( function ( ) {
256
+ return Promise . reject ( 'failure' ) ;
257
+ } ) . run ( ) . catch ( function ( err ) {
258
+ t . ok ( err ) ;
259
+ t . is ( err . name , 'AssertionError' ) ;
260
+ t . is ( err . message , 'Promise rejected with "failure"' ) ;
261
+ t . end ( ) ;
262
+ } ) ;
263
+ } ) ;
You can’t perform that action at this time.
0 commit comments