Skip to content

Commit

Permalink
🥋 Update docs with chaining emit matchers (#693)
Browse files Browse the repository at this point in the history
  • Loading branch information
yivlad authored Apr 12, 2022
1 parent 501351f commit 4ed0cc5
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/tricky-spiders-invite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ethereum-waffle/chai": patch
---

Allow to chain emit matchers
10 changes: 10 additions & 0 deletions docs/source/matchers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@ Testing with indexed bytes or string parameters. These two examples are equivale
.to.emit(contract, 'AddAddress')
.withArgs(hashedStreet, hashedCity);
If you are using Waffle version :code:`3.4.4` or lower, you can't chain :code:`emit` matchers like in example below.

.. code-block:: ts
await expect(tx)
.to.emit(contract, 'One')
.to.emit(contract, 'Two');
This feature will be available in Waffle version 4.

Called on contract
------------------

Expand Down
19 changes: 19 additions & 0 deletions docs/source/migration-guides.rst
Original file line number Diff line number Diff line change
Expand Up @@ -435,3 +435,22 @@ In the new Ganache, you should not override the wallet config, otherwise you mig
}
}
})
Chaining :code:`emit` matchers
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Now when testing events on a smart contract you can conveniently chain :code:`emit` matchers.

.. code-block:: ts
const tx = await contract.emitEventsOneAndTwo();
await expect(tx)
.to.emit(contract, 'One').withArgs(
1,
'One'
)
.to.emit(contract, 'Two').withArgs(
2,
'Two'
)
.to.not.emit(contract, 'Three');

0 comments on commit 4ed0cc5

Please sign in to comment.