@@ -10,6 +10,7 @@ declare global {
10
10
interface Matchers < R > {
11
11
toLog ( value ?: RegExp | string ) : Promise < void > ;
12
12
toFailRequireWith ( value : RegExp | string ) : Promise < void > ;
13
+ toFailRequire ( ) : Promise < void > ;
13
14
}
14
15
}
15
16
}
@@ -57,7 +58,7 @@ expect.extend({
57
58
await transaction . debug ( ) ;
58
59
59
60
const matcherHint = this . utils . matcherHint ( '.toFailRequireWith' , undefined , match . toString ( ) , { isNot : this . isNot } ) ;
60
- const message = ( ) : string => `${ matcherHint } \n\nContract function did not fail a require statement` ;
61
+ const message = ( ) : string => `${ matcherHint } \n\nContract function did not fail a require statement. ` ;
61
62
return { message, pass : false } ;
62
63
} catch ( transactionError : any ) {
63
64
const matcherHint = this . utils . matcherHint ( 'toFailRequireWith' , 'received' , 'expected' , { isNot : this . isNot } ) ;
@@ -73,4 +74,18 @@ expect.extend({
73
74
}
74
75
}
75
76
} ,
77
+ async toFailRequire (
78
+ this : MatcherContext ,
79
+ transaction : Transaction ,
80
+ ) : Promise < SyncExpectationResult > {
81
+ try {
82
+ await transaction . debug ( ) ;
83
+ const message = ( ) : string => 'Contract function did not fail a require statement.' ;
84
+ return { message, pass : false } ;
85
+ } catch ( transactionError : any ) {
86
+ const receivedText = `Received string: ${ this . utils . printReceived ( transactionError ?. message ?? '' ) } ` ;
87
+ const message = ( ) : string => `Contract function failed a require statement.\n${ receivedText } ` ;
88
+ return { message, pass : true } ;
89
+ }
90
+ } ,
76
91
} ) ;
0 commit comments