File tree Expand file tree Collapse file tree 2 files changed +13
-8
lines changed Expand file tree Collapse file tree 2 files changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -514,8 +514,9 @@ declare namespace expect {
514
514
*
515
515
* @returns assertion chain object.
516
516
*/
517
- reject ( type : Function , message ?: string | RegExp ) : Assertion < T > ;
518
- reject ( message ?: string | RegExp ) : Assertion < T > ;
517
+ reject < E extends { } > ( type : Function & { new ( ) : E } , message ?: string | RegExp ) : Promise < E > ;
518
+ reject < E = unknown > ( message : string | RegExp ) : Promise < E > ;
519
+ reject ( ) : Promise < null > ;
519
520
520
521
/**
521
522
* Asserts that the Promise reference value rejects with an exception when called.
@@ -525,8 +526,9 @@ declare namespace expect {
525
526
*
526
527
* @returns assertion chain object.
527
528
*/
528
- rejects ( type : Function , message ?: string | RegExp ) : Assertion < T > ;
529
- rejects ( message ?: string | RegExp ) : Assertion < T > ;
529
+ rejects < E extends { } > ( type : Function & { new ( ) : E } , message ?: string | RegExp ) : Promise < E > ;
530
+ rejects < E = unknown > ( message : string | RegExp ) : Promise < E > ;
531
+ rejects ( ) : Promise < null > ;
530
532
531
533
/**
532
534
* Asserts that the reference value satisfies the provided validator function.
Original file line number Diff line number Diff line change @@ -178,8 +178,9 @@ Code.expect(1).to.match(/^\d$/);
178
178
Code . expect ( 'x' ) . to . satisfy ( value => value === 'x' ) ;
179
179
180
180
const rejection = Promise . reject ( new Error ( 'Oh no!' ) ) ;
181
- await Code . expect ( rejection ) . to . reject ( 'Oh no!' ) ;
182
- await Code . expect ( rejection ) . rejects ( 'Oh no!' ) ;
181
+
182
+ await expect . type < Promise < any > > ( Code . expect ( rejection ) . to . reject ( 'Oh no!' ) ) ;
183
+ await expect . type < Promise < any > > ( Code . expect ( rejection ) . rejects ( 'Oh no!' ) ) ;
183
184
184
185
class CustomError extends Error { }
185
186
@@ -191,5 +192,7 @@ const throws = () => {
191
192
Code . expect ( throws ) . to . throw ( CustomError , 'Oh no!' ) ;
192
193
193
194
const typedRejection = Promise . reject ( new CustomError ( 'Oh no!' ) ) ;
194
- await Code . expect ( typedRejection ) . to . reject ( CustomError , 'Oh no!' ) ;
195
- await Code . expect ( typedRejection ) . rejects ( CustomError , 'Oh no!' ) ;
195
+ await expect . type < Promise < CustomError > > ( Code . expect ( typedRejection ) . to . reject ( CustomError , 'Oh no!' ) ) ;
196
+ await expect . type < Promise < CustomError > > ( Code . expect ( typedRejection ) . rejects ( CustomError , 'Oh no!' ) ) ;
197
+
198
+ await expect . type < Promise < null > > ( Code . expect ( Promise . resolve ( true ) ) . to . not . reject ( ) ) ;
You can’t perform that action at this time.
0 commit comments