Skip to content

Commit 4ed0cc5

Browse files
authoredApr 12, 2022
🥋 Update docs with chaining emit matchers (#693)
1 parent 501351f commit 4ed0cc5

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed
 
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@ethereum-waffle/chai": patch
3+
---
4+
5+
Allow to chain emit matchers

‎docs/source/matchers.rst

+10
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,16 @@ Testing with indexed bytes or string parameters. These two examples are equivale
5757
.to.emit(contract, 'AddAddress')
5858
.withArgs(hashedStreet, hashedCity);
5959
60+
If you are using Waffle version :code:`3.4.4` or lower, you can't chain :code:`emit` matchers like in example below.
61+
62+
.. code-block:: ts
63+
64+
await expect(tx)
65+
.to.emit(contract, 'One')
66+
.to.emit(contract, 'Two');
67+
68+
This feature will be available in Waffle version 4.
69+
6070
Called on contract
6171
------------------
6272

‎docs/source/migration-guides.rst

+19
Original file line numberDiff line numberDiff line change
@@ -435,3 +435,22 @@ In the new Ganache, you should not override the wallet config, otherwise you mig
435435
}
436436
}
437437
})
438+
439+
Chaining :code:`emit` matchers
440+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
441+
442+
Now when testing events on a smart contract you can conveniently chain :code:`emit` matchers.
443+
444+
.. code-block:: ts
445+
446+
const tx = await contract.emitEventsOneAndTwo();
447+
await expect(tx)
448+
.to.emit(contract, 'One').withArgs(
449+
1,
450+
'One'
451+
)
452+
.to.emit(contract, 'Two').withArgs(
453+
2,
454+
'Two'
455+
)
456+
.to.not.emit(contract, 'Three');

0 commit comments

Comments
 (0)
Please sign in to comment.