Open volodymyrprokopyuk opened 1 year ago
Thank you @volodymyrprokopyuk. Our plan is to decouple Hardhat more from mocha and chai, so that other test runners/assertions libraries are easy to use with it. This is one of the main things we want to do in the next major version, but there are certain things that we can do before that.
After few experiments, I can confirm that all Hardhat Chai matchers (emit
, changeTokenBalances
, revertedWith
) work correctly with vitest
. The missing part is minor: adapt matchers' names to follow jest style by providing aliases to matcher functions e. g.
await expect(...).revertedWith(...)
await expect(...).toRevertWith(...)
Thank you!
Describe the feature
Hi,
It seems that vitest is not fully supported by Hardhat: some tests from the tutorial run successfully with vitest, while others fail, probably due to the fact that Hardhat Chai matchers are not adapted to work with vitest. It is worth to support the Jest style of matchers as vitest supports them:
expect(...).toEmit(...)
,expect(...).not.toRevertWith(...)
expect(...).to.emit(...)
,expect(...).not.to.be.revertedWith(...)
What is the current level of vitest support in Hardhat? Is is partially supported or it just works by chance? What are the plans to support vitest in Hardhat? Is it planned to adapt the Hardhat Chai matchers to work with vitest using the Jest style?I'm aware of the issue to document vitest ussage with Hardhat, but I feel that the Hardhat Chai matchers are not all working well with vitest.
Thank you, Vlad
Search terms
vitest hardhat matchers