Testing Wagmi with a MockedProvider #1298
jasperverbeet
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I use Wagmi for all my Ethereum(-like) projects, and I love the library.
However, one thing that isn't optimal in my opinion is testing my implementations. Currently, this repository itself is testing against an Anvil instance, but I prefer fully isolated (unit) tests without depending on external service for speed and reliability reasons. I couldn't find a way to do that...
That's why I created an alternative called MockEth, which provides a MockProvider for Ethers that intercepts and returns mocked data instead of performing the actual call.
Currently, it supports reading contract data and watching for events, but I'll be working on adding more features soon.
Here is an example:
I've also included a Wagmi example here: https://github.com/Byont-Ventures/mocketh/tree/main/examples/1-wagmi.
It would be super cool if someone could check it out and let me know what you think!
Again, thanks for providing such an awesome library!
~ Jasper
Beta Was this translation helpful? Give feedback.
All reactions