Testing
A comprehensive testing guide for the CoW Protocol smart contracts project, covering test execution, debugging, gas reporting, and code coverage analysis.Test Framework
Tests leverage:- Hardhat - Development environment
- Waffle - Smart contract testing library
- Chai - Assertion library
- ethers.js - Ethereum interaction library
Running Tests
Standard Suite
Run the complete test battery:Excluded Tests
Execute tests that skip coverage analysis:Coverage Reports
Generate detailed instrumentation metrics:Debugging
Enable verbose output to track contract deployments, transaction details, state changes, and event emissions:Gas Reporting
Activate gas tracking to produce consumption tables showing costs per operation and deployment expenses:Coverage Analysis
Theyarn coverage command instruments contracts and generates:
- Terminal summary with coverage percentages
- Interactive HTML report at
coverage/index.html
Coverage Color Coding
Configuration
TheMOCHA_CONF environment variable controls test scope across different execution contexts: