@nomicfoundation/hardhat-ethers-chai-matchers 3.0.0-next.26 → 3.0.0-next.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -26
- package/package.json +8 -8
package/README.md
CHANGED
@@ -1,31 +1,24 @@
|
|
1
|
-
#
|
1
|
+
# hardhat-ethers-chai-matchers
|
2
2
|
|
3
3
|
This plugin adds Ethereum-specific matchers to the [Chai](https://chaijs.com/) assertion library that integrate with [ethers.js](https://ethers.org/), making your smart contract tests easy to write and read.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
7
|
+
> This plugin is part of the [Ethers+Mocha Hardhat Toolbox](/v-next/hardhat-toolbox-mocha-ethers/). If you are using that toolbox, there's nothing else you need to do.
|
8
|
+
|
7
9
|
To install this plugin, run the following command:
|
8
10
|
|
9
11
|
```bash
|
10
|
-
npm install --save-dev @nomicfoundation/hardhat-ethers-chai-matchers
|
12
|
+
npm install --save-dev @nomicfoundation/hardhat-ethers-chai-matchers
|
11
13
|
```
|
12
14
|
|
13
|
-
|
14
|
-
|
15
|
-
```typescript
|
16
|
-
// ...
|
17
|
-
import ethersChaiMatchersPlugin from "@nomicfoundation/hardhat-ethers-chai-matchers";
|
15
|
+
In your `hardhat.config.ts` file, import the plugin and add it to the `plugins` array:
|
18
16
|
|
19
|
-
|
17
|
+
```ts
|
18
|
+
import hardhatEthersChaiMatchers from "@nomicfoundation/hardhat-ethers-chai-matchers";
|
20
19
|
|
21
20
|
export default {
|
22
|
-
|
23
|
-
plugins: [
|
24
|
-
// ...
|
25
|
-
ethersChaiMatchersPlugin,
|
26
|
-
],
|
27
|
-
|
28
|
-
// ...
|
21
|
+
plugins: [hardhatEthersChaiMatchers],
|
29
22
|
};
|
30
23
|
```
|
31
24
|
|
@@ -33,20 +26,16 @@ export default {
|
|
33
26
|
|
34
27
|
You don't need to do anything else to use this plugin. Whenever you run your tests with Hardhat, it will automatically add the matchers.
|
35
28
|
|
36
|
-
Here is an example of using the `
|
29
|
+
Here is an example of using the `emit` matcher:
|
37
30
|
|
38
31
|
```ts
|
39
32
|
import { expect } from "chai";
|
40
33
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
const amount = ethers.utils.parseEther("1");
|
34
|
+
it("some test", async function () {
|
35
|
+
const contract = await ethers.deployContract("SomeContract");
|
45
36
|
|
46
|
-
await expect(()
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
}),
|
51
|
-
).to.changeEtherBalances(provider, [sender, contract], [-AMOUNT, AMOUNT]);
|
37
|
+
await expect(contract.someFunction())
|
38
|
+
.to.emit(contract, "SomeEvent")
|
39
|
+
.withArgs("0x...", 3);
|
40
|
+
});
|
52
41
|
```
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@nomicfoundation/hardhat-ethers-chai-matchers",
|
3
|
-
"version": "3.0.0-next.
|
3
|
+
"version": "3.0.0-next.28",
|
4
4
|
"description": "Hardhat utils for testing",
|
5
5
|
"homepage": "https://github.com/nomicfoundation/hardhat/tree/v-next/v-next/hardhat-ethers-chai-matchers",
|
6
6
|
"repository": {
|
@@ -31,8 +31,8 @@
|
|
31
31
|
"README.md"
|
32
32
|
],
|
33
33
|
"devDependencies": {
|
34
|
-
"@nomicfoundation/hardhat-mocha": "^3.0.0-next.
|
35
|
-
"@nomicfoundation/hardhat-node-test-reporter": "^3.0.0-next.
|
34
|
+
"@nomicfoundation/hardhat-mocha": "^3.0.0-next.28",
|
35
|
+
"@nomicfoundation/hardhat-node-test-reporter": "^3.0.0-next.28",
|
36
36
|
"@types/chai": "^4.2.0",
|
37
37
|
"@types/debug": "^4.1.7",
|
38
38
|
"@types/deep-eql": "^4.0.2",
|
@@ -46,18 +46,18 @@
|
|
46
46
|
"rimraf": "^5.0.5",
|
47
47
|
"tsx": "^4.19.3",
|
48
48
|
"typescript": "~5.8.0",
|
49
|
-
"@nomicfoundation/hardhat-test-utils": "^3.0.0-next.
|
49
|
+
"@nomicfoundation/hardhat-test-utils": "^3.0.0-next.28"
|
50
50
|
},
|
51
51
|
"dependencies": {
|
52
|
-
"@nomicfoundation/hardhat-errors": "^3.0.0-next.
|
53
|
-
"@nomicfoundation/hardhat-utils": "^3.0.0-next.
|
52
|
+
"@nomicfoundation/hardhat-errors": "^3.0.0-next.28",
|
53
|
+
"@nomicfoundation/hardhat-utils": "^3.0.0-next.28",
|
54
54
|
"@types/chai-as-promised": "^8.0.1",
|
55
55
|
"chai-as-promised": "^8.0.0",
|
56
56
|
"deep-eql": "^5.0.1"
|
57
57
|
},
|
58
58
|
"peerDependencies": {
|
59
|
-
"hardhat": "^3.0.0-next.
|
60
|
-
"@nomicfoundation/hardhat-ethers": "^4.0.0-next.
|
59
|
+
"hardhat": "^3.0.0-next.28",
|
60
|
+
"@nomicfoundation/hardhat-ethers": "^4.0.0-next.28",
|
61
61
|
"chai": "^5.1.2",
|
62
62
|
"ethers": "^6.14.0"
|
63
63
|
},
|