Testing
Running tests
Execute the test suite with:
This command performs the following actions:
- Builds the project (
yarn build)
- Runs Jest tests against the compiled output in
./dist
Test configuration
Jest testing is configured through package.json:
{
"jest": {
"automock": false,
"resetMocks": false,
"collectCoverageFrom": [
"src/**/*.{ts,tsx}"
],
"coveragePathIgnorePatterns": [
"abi",
"types"
]
}
}
Test structure
Test files are colocated with source files using the .spec.ts extension:
src/
├── utils/
│ ├── utils.ts
│ └── utils.spec.ts
└── ...
Coverage collection
Jest collects coverage metrics from all TypeScript files in src, while excluding:
abi/ directory (contract ABIs)
types/ directory (generated types)
Testing considerations
Integration tests
For blockchain interaction testing:
- Tests execute against compiled JavaScript in
./dist
- Build the project before running tests
- Mock RPC calls in unit tests
Test isolation
Configuration settings for test isolation:
automock: false - Requires manual mock setup
resetMocks: false - Mocks carry between tests unless reset explicitly
Running specific tests
Execute an individual test file:
yarn test path/to/test.spec.ts
For development iteration with watch mode:
Last modified on March 4, 2026