hirosystems / clarinet

Write, test and deploy high-quality smart contracts to the Stacks blockchain and Bitcoin.
https://hiro.so/clarinet
GNU General Public License v3.0
290 stars 129 forks source link

fix: improve error message in sdk custom matchers #1417

Closed hugocaillard closed 2 months ago

hugocaillard commented 2 months ago

Description

When using the sdk with vitest, if the custom matcher expects the wrong types, we keep error messages short (eg: expect(Cl.uint(1)).toBeOk(Cl.uint(1)) will throw actual value must be a Clarity "UInt", received "ResponseOk")

This should be improved to display a more detailed error diff, but it requires some more work so that the error message remain readable, even when the test is handling big set of data (such as big lists or buffers).

This PR simply handle a quick fix for the common case were expectOk actually receive a ResponseError. We should display the received error

hugocaillard commented 2 months ago

cc @friedger