Quality-centric = There are a few examples showing approaches for testing contract-related functionality in isolation-GREAT!! However, the same cannot be said if searching the web for mocking BeaconWallet and TezosToolkit. I also had a look at at just constructing something in the tests but the type doc definitions are a 404. Any help much appreciated thanks in advance!
2 Answers
If you want to unit test components that use beacon, I suggest that you create a stub for the DAppClient
or BeaconWallet
instance, and then either return a successful or error response when submitting a transaction. You can do this using your testing framework of choice, there is nothing beacon specific to it.
Feel free to include an example of what you are trying to achieve so we can give you a more detailed answer.
if you are looking to mock responses for the TezosToolkit, I can direct you to our unit tests in the Taquito repository https://github.com/ecadlabs/taquito/tree/master/packages/taquito/test Mocking the toolkit itself is also possible; however, we do not have any tests that represent that high of a level of testing. But you can see the use of the TezosToolkit with the appropriate mocks for the inner classes that the toolkit wraps around and depends on.
I hope this helps, and if not, please don't hesitate to ask more about it.