0.0.73 • Published 2 months ago

wookashwackomytest-polkahat-chai-matchers v0.0.73

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

npm

Polkahat Chai Matchers

This plugin adds various capabilities to the Chai assertion library, making your smart contract tests easy to write and read.

Installation

npm install --save-dev wookashwackomytest-polkahat-chai-matchers

If you are using yarn:

yarn add --dev wookashwackomytest-polkahat-chai-matchers

Usage

After installing it, import the config in:

import "wookashwackomytest-polkahat-chai-matchers";

Then you'll be able to use the matchers in your tests:

expect(await token.totalSupply()).to.equal(1_000_000);

await expect(token.transfer(token, 1000)).to.be.revertedWith(
  "Cannot transfer to the contract itself"
);

await expect(token.transfer(recipient, 1000))
  .to.emit(token, "Transfer")
  .withArgs(owner, recipient, 1000);

Known issues

Chaining Async Matchers

Currently, the following matchers do not support chaining:

  • reverted
  • revertedWith
  • revertedWithCustomError
  • revertedWithoutReason
  • revertedWithPanic
  • changeEtherBalance
  • changeEtherBalances
  • changeTokenBalance
  • changePSP22Balances
  • emit (with the only exception of chaining multiple emit matchers)

Which means you can't do:

await expect(contract.f(...))
  .to.changeEtherBalance(...)
  .and.to.changeTokenBalance(...)

To work around this limitation, write separate assertions for each matcher:

const tx = contract.f(...);
await expect(tx).to.changeEtherBalance(...)
await expect(tx).to.changeTokenBalance(...)
0.0.73

2 months ago

0.0.70

2 months ago

0.0.71

2 months ago

0.0.72

2 months ago

0.0.65

2 months ago

0.0.66

2 months ago

0.0.67

2 months ago

0.0.68

2 months ago

0.0.69

2 months ago

0.0.62

2 months ago

0.0.63

2 months ago

0.0.64

2 months ago

0.0.61

2 months ago

0.0.60

2 months ago

0.0.59

2 months ago

0.0.55

2 months ago

0.0.56

2 months ago

0.0.57

2 months ago

0.0.58

2 months ago

0.0.51

2 months ago

0.0.52

2 months ago

0.0.50

2 months ago

0.0.40

3 months ago

0.0.41

3 months ago

0.0.42

3 months ago

0.0.43

3 months ago

0.0.44

3 months ago

0.0.45

3 months ago

0.0.46

3 months ago

0.0.47

3 months ago

0.0.37

3 months ago

0.0.39

3 months ago

0.0.30

3 months ago

0.0.31

3 months ago

0.0.32

3 months ago

0.0.33

3 months ago

0.0.34

3 months ago

0.0.35

3 months ago

0.0.36

3 months ago

0.0.29

3 months ago

0.0.48

3 months ago

0.0.49

3 months ago

0.0.28

3 months ago

0.0.27

3 months ago

0.0.26

3 months ago

0.0.25

3 months ago

0.0.24

3 months ago

0.0.23

3 months ago

0.0.22

3 months ago

0.0.21

3 months ago

0.0.20

3 months ago

0.0.19

3 months ago

0.0.18

3 months ago

0.0.17

3 months ago

0.0.16

3 months ago

0.0.15

3 months ago

0.0.14

3 months ago

0.0.13

3 months ago

0.0.12

3 months ago

0.0.11

3 months ago

0.0.10

3 months ago

0.0.9

3 months ago

0.0.8

3 months ago

0.0.7

3 months ago

0.0.6

3 months ago

0.0.5

3 months ago

0.0.4

3 months ago

0.0.3

3 months ago

0.0.2

3 months ago

0.0.1

3 months ago