Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve event assertion functions failed test error message #1128

Open
vini-btc opened this issue Aug 15, 2023 · 2 comments
Open

Improve event assertion functions failed test error message #1128

vini-btc opened this issue Aug 15, 2023 · 2 comments
Assignees

Comments

@vini-btc
Copy link

vini-btc commented Aug 15, 2023

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;
@github-project-automation github-project-automation bot moved this to 🆕 New in DevTools Aug 15, 2023
@hugocaillard hugocaillard self-assigned this Aug 16, 2023
@hugocaillard hugocaillard moved this from 🆕 New to 📋 Backlog in DevTools Aug 16, 2023
@hugocaillard
Copy link
Collaborator

Hello @vicnicius,
It will be part of the new test framework, see here: #1109
We can keep this issue open since it gives more details 👌

@vini-btc
Copy link
Author

Great to hear. I'll follow #1109 closely. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 📋 Backlog
Development

No branches or pull requests

2 participants