I'm running a test using waffle in hardhat.
import { assert, expect } from "chai"
.
.
.
it("can only be changed through governance", async () => {
await expect(box.store(55)).to.be.revertedWith("Nope, you bad")
})
However when I run tests, I run into:
test/unit/testflow.test.ts:31:39 - error TS2339: Property 'revertedWith' does not exist on type 'Assertion'.
I have the package imported in my hardhat.config.ts
import "@nomiclabs/hardhat-waffle"
And I have the package installed:
package.json
"@nomiclabs/hardhat-waffle": "^2.0.2",
What am I missing?
Best Answer
Pre June 2022
You need to also add
ethereum-waffle
to your package, not just the nomiclabs one@nomiclabs/hardhat-waffle
. you need bothyou just only need to install it, other than that in the hardhat.config.js file this will not be "require" or "import". menas in
hardhat.config.js
only this will be importedPost Just 2022
Hardhat has released a new package named hardhat-toolbox to replace hardhat-waffle.
Install it with
npm install --save-dev @nomicfoundation/hardhat-toolbox
oryarn add --dev @nomicfoundation/hardhat-toolbox
and then import it in yourhardhat.config.js
like this:Once done, you'll be able to use
revertWith
like this: