Closed megamattron closed 2 years ago
web3-mock
does only match mocks with the correct value (see test case here) and it rejects
the transaction request with asking you to mock the transaction correctly (with the correct value).
Problem usually is that due to javascripts async nature, nothing "raises" as the reject might not be catched in your application or in web3js.
What you e.g. could try is to check cypress console for that test if you see any "Web3Mock: Please mock the transaction XYZ"
And there is even an internal call counter compliant with test helpers like .toHaveBeenCalled()
see here
You could also check the call count of the mockedTransaction at the end of your test directly like:
expect(mockTransaction.calls.count() > 0).equal(true)
Which would proof that the transaction has not been matched/called (due to the wrong value).
You are correct, it was a mistake on my end. Sorry about that!
It would be great to verify that the 'value' of a mock transaction is also being specified as expected, for example: https://github.com/larvalabs/cryptopunksmarket/blob/cypresstests/cypress/integration/bidder-actions.spec.js#L111
As it stands now I can have any number specified for 'value', or value can be missing entirely and web3-mock won't warn that a mock is missing (and thereby cause my test to fail, as I was hoping).