@@ -937,13 +937,18 @@ test('.throws()', gather(t => {
937
937
} , null ) ;
938
938
} ) ;
939
939
940
- // Regression test for https://github.com/avajs/ava/issues/1676
941
- fails ( t , ( ) => {
940
+ passes ( t , ( ) => {
942
941
assertions . throws ( ( ) => {
943
942
throw new Error ( 'foo' ) ;
944
943
} , undefined ) ;
945
944
} ) ;
946
945
946
+ passes ( t , async ( ) => {
947
+ await assertions . throwsAsync ( ( ) => {
948
+ return Promise . reject ( new Error ( 'foo' ) ) ;
949
+ } , undefined ) ;
950
+ } ) ;
951
+
947
952
failsWith ( t , ( ) => {
948
953
assertions . throws ( ( ) => { } , null , null ) ;
949
954
} , {
@@ -1085,47 +1090,47 @@ test('.throws() fails if passed a bad expectation', t => {
1085
1090
assertions . throws ( ( ) => { } , true ) ;
1086
1091
} , {
1087
1092
assertion : 'throws' ,
1088
- message : 'The second argument to `t.throws()` must be an expectation object or `null `' ,
1093
+ message : 'The second argument to `t.throws()` must be an expectation object, `null` or `undefined `' ,
1089
1094
values : [ { label : 'Called with:' , formatted : / t r u e / } ]
1090
1095
} ) ;
1091
1096
1092
1097
failsWith ( t , ( ) => {
1093
1098
assertions . throws ( ( ) => { } , 'foo' ) ;
1094
1099
} , {
1095
1100
assertion : 'throws' ,
1096
- message : 'The second argument to `t.throws()` must be an expectation object or `null `' ,
1101
+ message : 'The second argument to `t.throws()` must be an expectation object, `null` or `undefined `' ,
1097
1102
values : [ { label : 'Called with:' , formatted : / f o o / } ]
1098
1103
} ) ;
1099
1104
1100
1105
failsWith ( t , ( ) => {
1101
1106
assertions . throws ( ( ) => { } , / b a z / ) ;
1102
1107
} , {
1103
1108
assertion : 'throws' ,
1104
- message : 'The second argument to `t.throws()` must be an expectation object or `null `' ,
1109
+ message : 'The second argument to `t.throws()` must be an expectation object, `null` or `undefined `' ,
1105
1110
values : [ { label : 'Called with:' , formatted : / b a z / } ]
1106
1111
} ) ;
1107
1112
1108
1113
failsWith ( t , ( ) => {
1109
1114
assertions . throws ( ( ) => { } , class Bar { } ) ;
1110
1115
} , {
1111
1116
assertion : 'throws' ,
1112
- message : 'The second argument to `t.throws()` must be an expectation object or `null `' ,
1117
+ message : 'The second argument to `t.throws()` must be an expectation object, `null` or `undefined `' ,
1113
1118
values : [ { label : 'Called with:' , formatted : / B a r / } ]
1114
1119
} ) ;
1115
1120
1116
1121
failsWith ( t , ( ) => {
1117
1122
assertions . throws ( ( ) => { } , { } ) ;
1118
1123
} , {
1119
1124
assertion : 'throws' ,
1120
- message : 'The second argument to `t.throws()` must be an expectation object or `null `' ,
1125
+ message : 'The second argument to `t.throws()` must be an expectation object, `null` or `undefined `' ,
1121
1126
values : [ { label : 'Called with:' , formatted : / \{ \} / } ]
1122
1127
} ) ;
1123
1128
1124
1129
failsWith ( t , ( ) => {
1125
1130
assertions . throws ( ( ) => { } , [ ] ) ;
1126
1131
} , {
1127
1132
assertion : 'throws' ,
1128
- message : 'The second argument to `t.throws()` must be an expectation object or `null `' ,
1133
+ message : 'The second argument to `t.throws()` must be an expectation object, `null` or `undefined `' ,
1129
1134
values : [ { label : 'Called with:' , formatted : / \[ \] / } ]
1130
1135
} ) ;
1131
1136
@@ -1177,47 +1182,47 @@ test('.throwsAsync() fails if passed a bad expectation', t => {
1177
1182
assertions . throwsAsync ( ( ) => { } , true ) ;
1178
1183
} , {
1179
1184
assertion : 'throwsAsync' ,
1180
- message : 'The second argument to `t.throwsAsync()` must be an expectation object or `null `' ,
1185
+ message : 'The second argument to `t.throwsAsync()` must be an expectation object, `null` or `undefined `' ,
1181
1186
values : [ { label : 'Called with:' , formatted : / t r u e / } ]
1182
1187
} ) ;
1183
1188
1184
1189
failsWith ( t , ( ) => {
1185
1190
assertions . throwsAsync ( ( ) => { } , 'foo' ) ;
1186
1191
} , {
1187
1192
assertion : 'throwsAsync' ,
1188
- message : 'The second argument to `t.throwsAsync()` must be an expectation object or `null `' ,
1193
+ message : 'The second argument to `t.throwsAsync()` must be an expectation object, `null` or `undefined `' ,
1189
1194
values : [ { label : 'Called with:' , formatted : / f o o / } ]
1190
1195
} ) ;
1191
1196
1192
1197
failsWith ( t , ( ) => {
1193
1198
assertions . throwsAsync ( ( ) => { } , / b a z / ) ;
1194
1199
} , {
1195
1200
assertion : 'throwsAsync' ,
1196
- message : 'The second argument to `t.throwsAsync()` must be an expectation object or `null `' ,
1201
+ message : 'The second argument to `t.throwsAsync()` must be an expectation object, `null` or `undefined `' ,
1197
1202
values : [ { label : 'Called with:' , formatted : / b a z / } ]
1198
1203
} ) ;
1199
1204
1200
1205
failsWith ( t , ( ) => {
1201
1206
assertions . throwsAsync ( ( ) => { } , class Bar { } ) ;
1202
1207
} , {
1203
1208
assertion : 'throwsAsync' ,
1204
- message : 'The second argument to `t.throwsAsync()` must be an expectation object or `null `' ,
1209
+ message : 'The second argument to `t.throwsAsync()` must be an expectation object, `null` or `undefined `' ,
1205
1210
values : [ { label : 'Called with:' , formatted : / B a r / } ]
1206
1211
} ) ;
1207
1212
1208
1213
failsWith ( t , ( ) => {
1209
1214
assertions . throwsAsync ( ( ) => { } , { } ) ;
1210
1215
} , {
1211
1216
assertion : 'throwsAsync' ,
1212
- message : 'The second argument to `t.throwsAsync()` must be an expectation object or `null `' ,
1217
+ message : 'The second argument to `t.throwsAsync()` must be an expectation object, `null` or `undefined `' ,
1213
1218
values : [ { label : 'Called with:' , formatted : / \{ \} / } ]
1214
1219
} ) ;
1215
1220
1216
1221
failsWith ( t , ( ) => {
1217
1222
assertions . throwsAsync ( ( ) => { } , [ ] ) ;
1218
1223
} , {
1219
1224
assertion : 'throwsAsync' ,
1220
- message : 'The second argument to `t.throwsAsync()` must be an expectation object or `null `' ,
1225
+ message : 'The second argument to `t.throwsAsync()` must be an expectation object, `null` or `undefined `' ,
1221
1226
values : [ { label : 'Called with:' , formatted : / \[ \] / } ]
1222
1227
} ) ;
1223
1228
0 commit comments