From 307f72678a3daa8bdaae4bbf0937741ccac0d0ee Mon Sep 17 00:00:00 2001 From: Przemyslaw Rzad Date: Fri, 16 Sep 2022 15:37:21 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=9B=B6=20Extend=20regexp=20for=20new=20fo?= =?UTF-8?q?rmat=20of=20hardhat=20errors=20(#793)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .changeset/perfect-keys-peel.md | 5 +++++ waffle-chai/src/matchers/revertedWith.ts | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 .changeset/perfect-keys-peel.md diff --git a/.changeset/perfect-keys-peel.md b/.changeset/perfect-keys-peel.md new file mode 100644 index 000000000..400c135d9 --- /dev/null +++ b/.changeset/perfect-keys-peel.md @@ -0,0 +1,5 @@ +--- +"@ethereum-waffle/chai": patch +--- + +🛶 Extend regexp for new format of hardhat errors diff --git a/waffle-chai/src/matchers/revertedWith.ts b/waffle-chai/src/matchers/revertedWith.ts index 0a6aed82d..611b5ca18 100644 --- a/waffle-chai/src/matchers/revertedWith.ts +++ b/waffle-chai/src/matchers/revertedWith.ts @@ -86,11 +86,11 @@ const decodeHardhatError = (error: any, context: any) => { } } { - const regexp = new RegExp('reverted with reason string "(.*?)"'); + const regexp = new RegExp('revert(ed)? with reason (string )?"(.*?)"'); const matches = regexp.exec(errorString); if (matches && matches.length >= 1) { - return matches[1]; + return matches[matches.length - 1]; } } return undefined;