Custom Matchers
A set of Vitest matchers that can be used to make assertions on Clarity values with the Clarinet JS SDK.
Installation
toHaveClarityType
Check that a value has the right Clarity type, without checking its value.
Parameters
expectedTypeRequiredClarityType
The Clarity type that the expected value should have.
toBeOk
Check that a response is (ok <ok-type>) and has the expected value. Any Clarity value can be passed.
Parameters
expectedRequiredClarityValue
The ClarityValue that the expected value should have.
toBeErr
Check that a response is (err <error-type>) and has the expected value. Any Clarity value can be passed.
Parameters
expectedRequiredClarityValue
The ClarityValue that the expected value should have.
toBeSome
Check that a response is (some <value>) and has the expected value. Any Clarity value can be passed.
Parameters
expectedRequiredClarityValue
The ClarityValue that the expected value should have.
toBeNone
Check that a response is (none).
toBeBool
Asserts the value of Clarity boolean (true or false).
Parameters
expectedRequiredboolean
The boolean that the expected value should have.
toBeInt
Asserts the value of a Clarity integer.
Parameters
expectedRequiredboolean
The integer that the expected value should have.
toBeUint
Asserts the value of a Clarity unsigned integer.
Parameters
expectedRequiredboolean
The unsigned integer that the expected value should have.
toBeAscii
Asserts the value of a Clarity string-ascii.
Parameters
expectedRequiredstring
The string that the expected value should have.
toBeUtf8
Asserts the value of a Clarity string-utf8.
Parameters
expectedRequiredstring
The string that the expected value should have.
toBePrincipal
Asserts the value of a Clarity principal.
The principal can be a standard or a contract principal.
Parameters
expectedRequiredstring
The string that the expected value should have.
toBeBuff
Asserts the value of a Clarity buffer. It takes an ArrayBuffer as an input.
For building a buffer, @stacks/transactions provides some helper functions:
bufferFromAsciibufferFromUtf8bufferFromHex
Parameters
expectedRequiredUint8Array
The Uint8Array buffer that the expected value should have.
toBeList
Asserts the value of a Clarity list containing an array of Clarity values.
Parameters
expectedRequiredClarityValue[]
The Uint8Array buffer that the expected value should have.
toBeTuple
Asserts the value of a Clarity tuple.
Parameters
expectedRequiredobject
The object of Clarity values that the expected value should have.