clarinet
clarinet copied to clipboard
Improve event assertion functions failed test error message
Sometimes when debugging tests it is hard to understand why a given test fails when using the events assertion functions. For example, while writing tests I created an assertion that looked something like this:
block.receipts[0].events.expectNonFungibleTokenMintEvent(
"token-id"
caller.address,
contractAddress,
"1",
);
This test failed with the error Error: Unable to retrieve expected NonFungibleTokenMintEvent
, but there was no explanation of why it was failing and what it was expecting, making it hard to debug the test.
Ideally, every assertion would have a more detailed message. In my case, I mixed the token id with the asset id, plus, I wasn't using the right type for the asset id. I'd expect the error message to read something like this:
Unable to retrieve expected NonFungibleTokenMintEvent:
- expected token id to be "token-id", but it was "1" instead;
- expected asset id to be u1, but it was "token-id" instead;
Hello @vicnicius, It will be part of the new test framework, see here: https://github.com/hirosystems/clarinet/issues/1109 We can keep this issue open since it gives more details 👌
Great to hear. I'll follow #1109 closely. Thanks!