canton-test-generator

Generate Vitest-based TypeScript tests from Daml scripts for Canton workflows.

1|1|Updated Nov 4, 2025
One-click install
npx skills add https://github.com/Moonsong-Labs/canton-dev --skill canton-test-generator
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: canton-test-generator
Source: https://github.com/Moonsong-Labs/canton-dev/tree/main/packages/canton-devenv-start/templates/.claude/skills/canton-test-generator
Command: npx skills add https://github.com/Moonsong-Labs/canton-dev --skill canton-test-generator

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Manually translating Daml test scripts into TypeScript tests is time-consuming and error-prone. This Skill automates the translation process by generating Vitest-compatible tests that exercise the Canton SDK against the same workflows described in Daml scripts.

Core Features & Use Cases

  • Daml-to-TypeScript translation: Converts Daml Scripts into TypeScript tests that validate the same business logic.
  • SDK-driven testing: Uses the Canton SDK to create contracts, exercise choices, and query ledger state in tests.
  • Structured, independent tests: Each Daml script yields a standalone test file with setup verification and clear assertions.
  • Quick-start workflow: Ideal for teams adopting Canton for contract testing and regression suites.

Quick Start

After adding your Daml project, run the skill to generate tests and then execute them with vitest against a running Canton ledger.

Frequently Asked Questions about canton-test-generator

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I convert Daml scripts to TypeScript tests automatically?

You can convert Daml scripts to TypeScript tests by scanning Daml Script tests and translating each workflow into SDK-backed Vitest files. This generates independent test files with setup verification, descriptive assertions, and Canton type safety for Id, Numeric, and Asset keys.

What is the best way to validate Canton workflows using Vitest?

The best way to validate Canton workflows is generating Vitest-compatible TypeScript tests that use the Canton SDK to create contracts, exercise choices, and query ledger state. Tests align outcomes with Daml script expectations using QuerySpec destructuring.

Does the generated TypeScript test enforce Canton type safety for ledger queries?

Yes, the generated TypeScript tests enforce Canton type safety for Id, Numeric, and Asset keys. They use QuerySpec destructuring for ledger queries to ensure type-safe interactions when exercising choices and validating contract state through the SDK.

How do I run generated Vitest tests against a Canton ledger?

After adding your Daml project and generating the test files, execute the Vitest tests against a running Canton ledger. The generated tests use the Canton SDK to create contracts, exercise choices, and perform setup verification before running assertions.

Why are my manually translated Daml tests failing in TypeScript?

Manually translating Daml test scripts into TypeScript is error-prone due to mismatched type handling and ledger query logic. Automating translation ensures Canton type safety, QuerySpec destructuring, and SDK-driven contract creation align with original Daml script expectations.

Can I use this approach for regression testing Daml contract logic?

Yes, this approach is ideal for teams adopting Canton for contract testing and regression suites. Each Daml script yields a standalone test file with setup verification and clear assertions, ensuring test outcomes align with corresponding Daml script expectations.