@ton/sandbox tests.
Easy way
When using blueprint, the only thing you need to collect coverage is to runcoverage/ directory as HTML files with reports for each of your contracts.
Customizable way
There might be some reasons why you don’t want to simply use--coverage.
- You don’t want to collect coverage for all contracts.
- You use
@ton/sandboxbut don’t use@ton/blueprint. - Not all contracts have source code. (For example, for each transaction you deploy a new contract, and you don’t have wrappers for it).
- You want to get the raw data and customize the output.
1. Enable coverage collection
Before running tests, addblockchain.enableCoverage() to collect coverage data:
2. Collect coverage after tests
3. Generate reports
Understanding coverage data
Coverage summary
The coverage summary provides key metrics about your test coverage:Coverage reports
- HTML Report: Interactive report with highlighting and line-by-line coverage details
- Text Report: Console-friendly report with coverage information and marked code
Advanced usage patterns
Multiple test suites
When running multiple test files, you might want to merge coverage data:Coverage for multiple contracts
When testing systems with multiple contracts:not runnable