All packages should have a __test__
directory with unit tests for the package.
All platforms should also have the tests broken into __test__/integration
, __tests__/mocks
, __test__/unit
directories.
The __test__/integration
directory should contain tests that test the calls using RPCs to the blockchain. The RPC calls may be mocked using nock.
The __test__/mocks
directory should contain mocks for things like RPCs and Signers that are Platform specific
Each platform should have a __test__/integration/fixtures
directory that contains fixtures for complex blockchain data structures
Using nock, we can gather the requests/responses and use jest.mock, mock the RPC calls to return the fixtures. This allows us to test the code without having to make RPC calls to the blockchain.
The root __tests__
directory should contain end-to-end tests with things like balance checks before and after using Tilt to stand up chains, deploy contracts and run the Guardian