| 78 | } |
| 79 | }, |
| 80 | toFailRequireWith( |
| 81 | transaction: Debuggable, |
| 82 | match: RegExp | string, |
| 83 | ) { |
| 84 | try { |
| 85 | transaction.debug(); |
| 86 | const matcherHint = this.utils.matcherHint('.toFailRequireWith', undefined, match.toString(), { isNot: this.isNot }); |
| 87 | const message = (): string => `${matcherHint}\n\nContract function did not fail a require statement.`; |
| 88 | return { message, pass: false }; |
| 89 | } catch (transactionError: any) { |
| 90 | const matcherHint = this.utils.matcherHint('toFailRequireWith', 'received', 'expected', { isNot: this.isNot }); |
| 91 | const expectedText = `Expected pattern: ${this.isNot ? 'not ' : ''}${this.utils.printExpected(match)}`; |
| 92 | const receivedText = `Received string: ${this.utils.printReceived(transactionError?.message ?? '')}`; |
| 93 | const message = (): string => `${matcherHint}\n\n${expectedText}\n${receivedText}`; |
| 94 | |
| 95 | try { |
| 96 | expect(transactionError?.message ?? '').toMatch(match); |
| 97 | return { message, pass: true }; |
| 98 | } catch { |
| 99 | return { message, pass: false }; |
| 100 | } |
| 101 | } |
| 102 | }, |
| 103 | }); |
| 104 | |
| 105 | export { }; |