Quick example of how to write tests for wagmi using React Testing Library and Playwright.
- Clone repository and install dependencies:
pnpm install- Install Anvil to run local Ethereum node.
- Add environment variables from
.env.example(recommened to use direnv) - Run dev server
pnpm devUnit and integration tests are run by Vitest and rendered with a custom render function from React Testing Library. See components/Connect.test.tsx and components/SendTip.test.tsx for more info.
- Start Anvil in terminal session
pnpm anvil- Start Vitest in watch mode in different terminal session
pnpm testEnd-to-end tests use Playwright. See test/pages/index.test.ts for more info.
- Start Anvil in terminal session
pnpm anvil- Start dev server in different terminal session (make sure
NEXT_PUBLIC_PLAYWRIGHT_ENABLEDis set totrue)
pnpm dev- Start Playwright test runner
pnpm test:e2e