/test — Compile and Run Tests
Run the full compile + test cycle for SaThuCoin. This is the standard validation sequence.
Steps
- •Run
npm run compileto compile all Solidity contracts - •If compilation succeeds, run
npm testto execute the full test suite - •If
$ARGUMENTScontains--coverage, runnpm run coverageinstead ofnpm test
Output Requirements
- •Show compilation result (success or errors)
- •Show full test output with pass/fail counts
- •If any tests fail, clearly highlight which tests failed and the error messages
- •If compilation fails, do NOT attempt to run tests — report the compilation error and stop
Error Handling
- •If
npm run compilefails: report the Solidity compilation errors. Common causes:- •Missing
Ownable(msg.sender)(OZ v5 requires explicit initial owner) - •Wrong import paths (use named imports:
import {ERC20} from "...") - •Solidity version mismatch (must be ^0.8.20, compiled with 0.8.26)
- •Missing
- •If
npm testfails: report which tests failed with assertion details
Key Context
- •Tests are in
test/SaThuCoin.test.js(~25 tests, 7 describe blocks) - •Tests use
loadFixture(deployFixture)pattern - •Tests do NOT require
.env— they run on Hardhat's in-memory network - •Token amounts use
ethers.parseEther()(ethers v6) - •Custom error assertions use
.revertedWithCustomError(contract, "ErrorName")