@@ -937,13 +937,18 @@ test('.throws()', gather(t => {
937937 } , null ) ;
938938 } ) ;
939939
940- // Regression test for https://github.com/avajs/ava/issues/1676
941- fails ( t , ( ) => {
940+ passes ( t , ( ) => {
942941 assertions . throws ( ( ) => {
943942 throw new Error ( 'foo' ) ;
944943 } , undefined ) ;
945944 } ) ;
946945
946+ passes ( t , async ( ) => {
947+ await assertions . throwsAsync ( ( ) => {
948+ return Promise . reject ( new Error ( 'foo' ) ) ;
949+ } , undefined ) ;
950+ } ) ;
951+
947952 failsWith ( t , ( ) => {
948953 assertions . throws ( ( ) => { } , null , null ) ;
949954 } , {
@@ -1085,47 +1090,47 @@ test('.throws() fails if passed a bad expectation', t => {
10851090 assertions . throws ( ( ) => { } , true ) ;
10861091 } , {
10871092 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 `' ,
10891094 values : [ { label : 'Called with:' , formatted : / t r u e / } ]
10901095 } ) ;
10911096
10921097 failsWith ( t , ( ) => {
10931098 assertions . throws ( ( ) => { } , 'foo' ) ;
10941099 } , {
10951100 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 `' ,
10971102 values : [ { label : 'Called with:' , formatted : / f o o / } ]
10981103 } ) ;
10991104
11001105 failsWith ( t , ( ) => {
11011106 assertions . throws ( ( ) => { } , / b a z / ) ;
11021107 } , {
11031108 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 `' ,
11051110 values : [ { label : 'Called with:' , formatted : / b a z / } ]
11061111 } ) ;
11071112
11081113 failsWith ( t , ( ) => {
11091114 assertions . throws ( ( ) => { } , class Bar { } ) ;
11101115 } , {
11111116 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 `' ,
11131118 values : [ { label : 'Called with:' , formatted : / B a r / } ]
11141119 } ) ;
11151120
11161121 failsWith ( t , ( ) => {
11171122 assertions . throws ( ( ) => { } , { } ) ;
11181123 } , {
11191124 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 `' ,
11211126 values : [ { label : 'Called with:' , formatted : / \{ \} / } ]
11221127 } ) ;
11231128
11241129 failsWith ( t , ( ) => {
11251130 assertions . throws ( ( ) => { } , [ ] ) ;
11261131 } , {
11271132 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 `' ,
11291134 values : [ { label : 'Called with:' , formatted : / \[ \] / } ]
11301135 } ) ;
11311136
@@ -1177,47 +1182,47 @@ test('.throwsAsync() fails if passed a bad expectation', t => {
11771182 assertions . throwsAsync ( ( ) => { } , true ) ;
11781183 } , {
11791184 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 `' ,
11811186 values : [ { label : 'Called with:' , formatted : / t r u e / } ]
11821187 } ) ;
11831188
11841189 failsWith ( t , ( ) => {
11851190 assertions . throwsAsync ( ( ) => { } , 'foo' ) ;
11861191 } , {
11871192 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 `' ,
11891194 values : [ { label : 'Called with:' , formatted : / f o o / } ]
11901195 } ) ;
11911196
11921197 failsWith ( t , ( ) => {
11931198 assertions . throwsAsync ( ( ) => { } , / b a z / ) ;
11941199 } , {
11951200 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 `' ,
11971202 values : [ { label : 'Called with:' , formatted : / b a z / } ]
11981203 } ) ;
11991204
12001205 failsWith ( t , ( ) => {
12011206 assertions . throwsAsync ( ( ) => { } , class Bar { } ) ;
12021207 } , {
12031208 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 `' ,
12051210 values : [ { label : 'Called with:' , formatted : / B a r / } ]
12061211 } ) ;
12071212
12081213 failsWith ( t , ( ) => {
12091214 assertions . throwsAsync ( ( ) => { } , { } ) ;
12101215 } , {
12111216 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 `' ,
12131218 values : [ { label : 'Called with:' , formatted : / \{ \} / } ]
12141219 } ) ;
12151220
12161221 failsWith ( t , ( ) => {
12171222 assertions . throwsAsync ( ( ) => { } , [ ] ) ;
12181223 } , {
12191224 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 `' ,
12211226 values : [ { label : 'Called with:' , formatted : / \[ \] / } ]
12221227 } ) ;
12231228
0 commit comments