Open adrianmcli opened 4 years ago
Oh, wow! I had no idea that jest was THAT popular.
Thanks for creating this issue and taking the time to analyze how to use it with Buidler.
Hi @adrianmcli, any updates for us?
@BnWng I've been swamped lately since I started at UMA. That being said, I have a side project idea that I might try next weekend and I'll be using Jest w/ Buidler. Hopefully I'll have something to show for it by then!
@BnWng I made some Jest matchers for Waffle to test: https://github.com/EthWorks/Waffle/pull/321
Would be cool to get your input. I have a feeling it still needs a lot of work though. I'm curious about how people use Buidler with Jest. That could help inform how to write a guide for Buidler.
Looks great @adrianmcli . However, I'm now using mocha and chai for my current project. But it looks like you've recreated all the crucial functionality with the chai matchers (which was why I switched away from Jest). I'll make sure to try it out with Jest when I get around to it. Thanks!
I have started building a Jest plugin for Hardhat: https://github.com/rryter/hardhat-jest-plugin
The most basic use-case does work, meaning you can run hardhat test:jest
and the tests run once. Obviously I want to support the watch mode too, without loosing the stack traces and so on. I'm currently looking into that.
If anyone wants to help, it's greatly appreciated.
Hi there
I would like to reopen this issue (sorry) Is there a possibly that hardhat can be using the JEST testing suite?
Hi there
I would like to reopen this issue (sorry) Is there a possibly that hardhat can be using the JEST testing suite?
Hi @yannickrocks
Yeah, it's definitely possible, If you want to use Jest in your Hardhat projects, I've developed a Hardhat plugin called hardhat-jest
that basically lets you run your Jest tests seamlessly only by running the command npx hardhat jest
and I also have written an article on Medium about it "How to use Jest in Hardhat Projects" that you can check it out for more details if you want, providing an in-depth guide to use Jest in your projects,
Hope that it will help you,
and I also appreciate your feedback, contributions, and help if you'd like to.
Thanks.
Hi there
I would like to reopen this issue (sorry) Is there a possibly that hardhat can be using the JEST testing suite?
Hi @yannickrocks
Yeah, it's definitely possible, If you want to use Jest in your Hardhat projects, I've developed a Hardhat plugin called
hardhat-jest
that basically lets you run your Jest tests seamlessly only by running the commandnpx hardhat jest
and I also have written an article on Medium about it "How to use Jest in Hardhat Projects" that you can check it out for more details if you want, providing an in-depth guide to use Jest in your projects,Hope that it will help you,
and I also appreciate your feedback, contributions, and help if you'd like to.
Thanks.
Hey Ryan
Will give this a go. Thank you!
@RyanHosseini Thank you for the package recommendation. Works like a charm 👍
I have a question though. Does Hardhat coverage only show coverage on the solidity files?
If so, does that mean I would still need to run jest --coverage
just to see the coverage on other tests files?
@RyanHosseini Thank you for the package recommendation. Works like a charm +1
I have a question though. Does Hardhat coverage only show coverage on the solidity files? If so, does that mean I would still need to run
jest --coverage
just to see the coverage on other tests files?
@yannickrocks I'm so glad it was helpful for you! 😃 Don't forget to star the repo as well 😇
Unfortunately, Hardhat coverage uses solidity-coverage
plugin under the hood which is only compatible with Mocha yet, So it seems like it's a little bit challenging to see the coverage in Jest test files.
Pleaes let me know if there's any other thing that I can help you.
@RyanHosseini Thank you for the package recommendation. Works like a charm +1 I have a question though. Does Hardhat coverage only show coverage on the solidity files? If so, does that mean I would still need to run
jest --coverage
just to see the coverage on other tests files?@yannickrocks I'm so glad it was helpful for you! 😃 Don't forget to star the repo as well 😇
Unfortunately, Hardhat coverage uses
solidity-coverage
plugin under the hood which is only compatible with Mocha yet, So it seems like it's a little bit challenging to see the coverage in Jest test files.Pleaes let me know if there's any other thing that I can help you.
@RyanHosseini Thanks and will do 😄
Do you know how many workers are used in the hardhat jest
package and how we can set them?
Issue I was having were tests were passing locally but failing on a github pipeline. Seems like the deploy scripts would struggle to initialise contracts and would throw a VM Exception error.
Is it recommended to use the snapshot functionality for the tests?
Buidler is a great framework, but it lacks official support or documentation for Jest. I've talked about this with @alcuadrado before and he agrees that maybe a guide would be helpful, so I created this issue to track this.
Note that Jest is by far the most popular framework, but most of the crypto world is not aware. My theory is because most crypto people are from the backend world. And Jest is largely a frontend-driven phenomenon:
Source: https://npmcharts.com/compare/mocha,jest,chai
I will try to take some time to experiment with different setups and report back here.