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
expectedType
RequiredClarityType
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
expected
RequiredClarityValue
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
expected
RequiredClarityValue
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
expected
RequiredClarityValue
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
expected
Requiredboolean
The boolean
that the expected value should have.
toBeInt
Asserts the value of a Clarity integer.
Parameters
expected
Requiredboolean
The integer
that the expected value should have.
toBeUint
Asserts the value of a Clarity unsigned integer.
Parameters
expected
Requiredboolean
The unsigned integer
that the expected value should have.
toBeAscii
Asserts the value of a Clarity string-ascii.
Parameters
expected
Requiredstring
The string
that the expected value should have.
toBeUtf8
Asserts the value of a Clarity string-utf8.
Parameters
expected
Requiredstring
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
expected
Requiredstring
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:
bufferFromAscii
bufferFromUtf8
bufferFromHex
Parameters
expected
RequiredUint8Array
The Uint8Array
buffer that the expected value should have.
toBeList
Asserts the value of a Clarity list containing an array of Clarity values.
Parameters
expected
RequiredClarityValue[]
The Uint8Array
buffer that the expected value should have.
toBeTuple
Asserts the value of a Clarity tuple.
Parameters
expected
Requiredobject
The object
of Clarity values that the expected value should have.