gmh5225 / wagmi-testing-wagmi

Example of how to write tests for wagmi

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

testing wagmi

Quick example of how to write tests for wagmi using React Testing Library and Playwright.

Getting started

  1. Clone repository and install dependencies:
pnpm install
  1. Install Anvil to run local Ethereum node.
  2. Add environment variables from .env.example (recommened to use direnv)
  3. Run dev server
pnpm dev

Unit/integration tests

Unit 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.

Run

  1. Start Anvil in terminal session
pnpm anvil
  1. Start Vitest in watch mode in different terminal session
pnpm test

End-to-end tests

End-to-end tests use Playwright. See test/pages/index.test.ts for more info.

Run

  1. Start Anvil in terminal session
pnpm anvil
  1. Start dev server in different terminal session (make sure NEXT_PUBLIC_PLAYWRIGHT_ENABLED is set to true)
pnpm dev
  1. Start Playwright test runner
pnpm test:e2e

About

Example of how to write tests for wagmi


Languages

Language:TypeScript 91.3%Language:CSS 7.7%Language:JavaScript 0.5%Language:Shell 0.4%