Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/brickheadjohnny/wagmi-playwright-example
Testing wagmi apps with Playwright and Anvil
https://github.com/brickheadjohnny/wagmi-playwright-example
anvil playwright wagmi
Last synced: 6 days ago
JSON representation
Testing wagmi apps with Playwright and Anvil
- Host: GitHub
- URL: https://github.com/brickheadjohnny/wagmi-playwright-example
- Owner: BrickheadJohnny
- Created: 2024-07-25T10:25:42.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2024-07-26T17:22:37.000Z (3 months ago)
- Last Synced: 2024-10-10T11:21:33.389Z (27 days ago)
- Topics: anvil, playwright, wagmi
- Language: TypeScript
- Homepage:
- Size: 133 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Wagmi & Playwright example
This is an example repository for writing E2E tests for [wagmi](https://wagmi.sh) apps with [Playwright](https://playwright.dev).
## Getting started
We've created a [Test Client](https://viem.sh/docs/clients/test#test-client), passed it to the `wagmiConfig` & used the [Mock connector](https://wagmi.sh/core/api/connectors/mock) in the tests. Before running the tests we spin up an Anvil node, so we can use it in our tests for onchain interactions (see the `webServer` property in `playwright.config.ts`).
1. [Install Foundry](https://book.getfoundry.sh/getting-started/installation)
2. Install the dependencies with `npm install`
3. Define the required environment variables in an `.env` file
4. Run the dev server with `npm run dev` (or it with `npm run build`)
5. Run the tests with `npm run test` (you can also run tests in ui or debug mode with the `test:ui` or `test:debug` scripts)## Credits
This solution is heavily inspired by [Thiago Brezinski's](https://www.callstack.com/blog/testing-expo-web3-apps-with-wagmi-and-anvil#connecting-to-the-local-blockchain) and [Rommert Zijlstra's](https://medium.com/renftlabs/end-to-end-testing-dapps-with-playwright-rainbowkit-wagmi-and-anvil-90d1d143512c) solution. I highly recommend reading these articles!