Writing and Running Contract Tests
Write automated tests for your smart contracts so you can catch bugs before deploying to a live network.
Why Test Smart Contracts?
Deployed contract code is immutable and often holds real value. A bug can be unfixable and costly. Automated tests let you verify behavior repeatedly and safely before any deployment.
The Test Toolkit
Hardhat and Truffle integrate test runners. Hardhat commonly uses Mocha with the Chai assertion library and ethers.js to deploy and call contracts in tests.
All lessons in this course
- Setting Up Hardhat or Truffle
- Compiling and Deploying Contracts
- Interacting with Deployed Contracts
- Writing and Running Contract Tests