Use Clarigen with Clarinet-SDK
Clarigen provides the @clarigen/test
library to help make it easier to write unit tests for your Clarity contracts. You'll still use Clarinet SDK
to execute and interact with your contracts. Clarigen will just provide a more ergonomic way to write your tests.
Getting started
Once you have a Clarinet project setup, you'll want to install a few Clarigen libraries:
Next, generate a Clarigen configuration file:
In your Clarigen.toml
file, you can update the output
field to specify where you want the auto-generated Clarigen code to be saved. For example:
Finally, run the Clarigen CLI to generate types for your contracts:
Writing tests
Now that you have Clarigen types, you can write unit tests that utilize them. Here's an example of a basic test that uses @clarigen/test
.