Chapter 8

Testing dApps

dApp testing spans smart contracts and frontend integration. Contracts need unit tests, fuzzing, and fork simulations; frontends need mocked wallet states and end-to-end flows against testnets or local forks.

Foundry runs fast Solidity tests in a Rust-based framework; Hardhat offers a JavaScript ecosystem with network forking built in. Fork mainnet state locally to interact with real Uniswap pools and tokens without mainnet cost.

Mock wagmi hooks in CI so tests run without a browser wallet. End-to-end tests with Playwright on testnet are slow but catch full-flow bugs — from connect wallet through sign, broadcast, and confirmation.