/defi-ui-testing:defi-ui-anvil-fixturesfrom defi-ui-testing
This skill should be used when building Anvil-backed Playwright fixtures for DeFi UI tests — snapshots, time travel, mining, impersonation, and multi-account chain helpers.
Ships in defi-ui-testing. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Shared chain control for both Method A and Method B.
// tests/fixtures/anvil.ts
import { test as base } from '@playwright/test'
import { createTestClient, http, parseEther, publicActions, walletActions } from 'viem'
import { foundry } from 'viem/chains'
export const anvilClient = createTestClient({
chain: foundry,
mode: 'anvil',
transport: http('http://127.0.0.1:8545'),
})
.extend(publicActions)
.extend(walletActions)
.extend((client) => ({
async syncDate(date: Date) {
await client.setNextBlockTimestamp({
timestamp: BigInt(Math.round(date.getTime() / 1000)),
})
return client.mine({ blocks: 1 })
},
async deal(address: `0x${string}`, eth: string) {
return client.setBalance({
address,
value: parseEther(eth),
})
},
}))
export const test = base.extend<{ anvil: typeof anvilClient }>({
anvil: async ({}, use) => {
await use(anvilClient)
},
})
Anvil cannot move block time backwards. Snapshot before suite; revert after.
let id: `0x${string}` | undefined
test.beforeAll(async ({ anvil }) => {
id = await anvil.snapshot()
})
test.afterAll(async ({ anvil }) => {
if (id) await anvil.revert({ id })
})
Or per-test:
test.beforeEach(async ({ anvil }) => {
// snapshot
})
test.afterEach(async ({ anvil }) => {
// revert
})
// date fixture uses anvil.syncDate + page.addInitScript Date patch
await date.set('2069-04-20')
await page.goto('/')
await expect(page.getByText(/Block time/)).toContainText('2069')
Use for vesting, funding periods, epoch-based emissions UIs.
anvil --fork-url $MAINNET_RPC_URL --fork-block-number 19000000
Impersonate whales:
await anvil.impersonateAccount({ address: WHALE })
await anvil.setBalance({ address: WHALE, value: parseEther('100') })
// send txs as whale via wallet client with impersonation
Method A can point mock account at whale address for read paths; writes may need real impersonation RPC.
Shared Anvil + fullyParallel: true ⇒ races. Prefer:
fullyParallel: false, orwebServer: [
{
command: 'anvil',
url: 'http://127.0.0.1:8545',
reuseExistingServer: !process.env.CI,
},
{
command: 'npm run dev',
url: 'http://127.0.0.1:3000',
reuseExistingServer: !process.env.CI,
},
],
playwright-webserver, playwright-fixturesanvil-node (foundry plugin)What SKILL.md sets; muted values are Claude Code's defaults
5 skills in this plugin
/defi-ui-mock-connectorThis skill should be used when implementing DeFi UI E2E with Playwright, Anvil, and Wagmi mock connector — window._setupAccount, fixtures, error features, without MetaMask extension./defi-ui-synpress-metamaskThis skill should be used when implementing DeFi UI E2E with Synpress, Playwright, MetaMask, and Hardhat/Anvil — wallet setup cache, connect, approve, deposit/borrow/liquidate flows./defi-ui-testing-overviewThis skill should be used when planning or implementing DeFi UI E2E tests — choosing between Wagmi mock connector vs Synpress MetaMask, stack layout with Anvil, and test strategy for dApps.Other plugins' skills for the same job
defi-ui-testing@cyotee is listed by cyotee/cyotee-claude-plugins — review the source before installing
npx claudepluginhub cyotee/cyotee-claude-plugins --plugin defi-ui-testing