NomicFoundation / hardhat

Hardhat is a development environment to compile, deploy, test, and debug your Ethereum software.
https://hardhat.org
Other
7.29k stars 1.41k forks source link

Support vitest including custom Hardhat matchers #4200

Open volodymyrprokopyuk opened 1 year ago

volodymyrprokopyuk commented 1 year ago

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:

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

fvictorio commented 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.

volodymyrprokopyuk commented 1 year ago

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.

Thank you!