Hardhat 3 Setup
Hardhat 3 setup with node:test runner explorer in VSCode
# add hardhat alias as hh to .zshrcalias hh="npx hardhat"1. Create Hardhat 3 project
Section titled “1. Create Hardhat 3 project”mkdir hardhat-example
cd hardhat-example
pnpm dlx hardhat --initHardhat options while initialization
👷 Welcome to Hardhat v3.0.9 👷
✔ Which version of Hardhat would you like to use? · hardhat-3✔ Where would you like to initialize the project?
Please provide either a relative or an absolute path: · .✔ What type of project would you like to initialize? · node-test-runner-viem✨ Template files copied ✨✔ You need to install the necessary dependencies using the following command:pnpm add --save-dev "hardhat@^3.0.9" "@nomicfoundation/hardhat-toolbox-viem@^5.0.0" "@nomicfoundation/hardhat-ignition@^3.0.0" "@types/node@^22.8.5" "forge-std@foundry-rs/forge-std#v1.9.4" "typescript@~5.8.0" "viem@^2.30.0"
Do you want to run it now? (Y/n) · true
pnpm add --save-dev "hardhat@^3.0.9" "@nomicfoundation/hardhat-toolbox-viem@^5.0.0" "@nomicfoundation/hardhat-ignition@^3.0.0" "@types/node@^22.8.5" "forge-std@foundry-rs/forge-std#v1.9.4" "typescript@~5.8.0" "viem@^2.30.0"2. Test setup for Hardhat 3 project
Section titled “2. Test setup for Hardhat 3 project”Add required VSCode extension for test explorer
Section titled “Add required VSCode extension for test explorer”Add required settings in settings.json of VSCode
Section titled “Add required settings in settings.json of VSCode”{ "nodejs-testing.extensions": [ { "extensions": ["mjs", "cjs", "js"], "parameters": [] }, { "extensions": ["mts", "cts", "ts"], "parameters": ["--import", "tsx"] } ]}Add required dependencies
Section titled “Add required dependencies” pnpm add -D tsx
# Don't forget to build before running tests using the explorer hh build
#Run tests from command line hh test