anza-xyz / wallet-adapter

Modular TypeScript wallet adapters and components for Solana applications.
https://anza-xyz.github.io/wallet-adapter/
Apache License 2.0
1.61k stars 962 forks source link

Documentation on how to unit test with creating a mock wallet provider. #1014

Open LukasDeco opened 3 months ago

LukasDeco commented 3 months ago

Is your feature request related to a problem? Please describe. I have had a lot of difficulty testing components that rely on useWallet and I haven't been able to figure out how to setup a mock wallet context with a dummy publicKey that I can test with. An example of how to do this(if it's possible given the current package exports) would be really helpful I think for the dev community.

Describe the solution you'd like A documented example of running a unit test with some test provider component like a <MockWalletProvider /> which shows how to setup such a component so that it has the publicKey of your choice, and it would be really nice to even show how to create a mock wallet that can send transactions.

Describe alternatives you've considered When I google search or look in the docs, I haven't seen anything about how to do this. I actually think if we exported WalletProviderBase we might be able to do this.