Prerequisites
Before you begin, ensure you have:- Node.js ≥ 14
- npm, yarn, or bun (this guide uses yarn)
- Foundry installed for Anvil local node
Need to install Foundry? Run:
Quick Setup
1
Install dependencies
Install OnchainTestKit and Playwright:
2
Download wallet extensions
Prepare the wallet extensions for testing:
3
Create environment variables
Create a
.env
file in your project root:.env
This is a test seed phrase. Never use your real wallet seed phrase in tests!
4
Create your first test
Create
e2e/connectWallet.spec.ts
:e2e/connectWallet.spec.ts
5
Run your test
Execute your test:To see the browser in action:
Want to see more real-world examples? Check out the comprehensive test examples in the OnchainTestKit repository. These examples cover:
- Token swaps
- NFT minting
- Multiple wallet interactions
- Complex transaction flows
- And much more!
What’s Next?
Installation Guide
Detailed installation instructions and troubleshooting
Configuration
Learn about advanced configuration options
Writing Tests
Deep dive into writing comprehensive tests
Smart Contracts
Test smart contract interactions
Common Issues
Wallet extension not found
Wallet extension not found
Make sure you’ve run the prepare commands:
Tests timing out
Tests timing out
Increase the test timeout in your config:
Port already in use
Port already in use
The local node might be using a port that’s already taken. OnchainTestKit automatically handles port allocation for parallel tests.