/playwright:playwright-fixturesfrom playwright
This skill should be used when writing Playwright fixtures for dApp tests — test.extend, mergeTests, wallet fixtures, Anvil clients, and page.evaluate helpers.
Ships in playwright. 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.
Fixtures establish the environment for each test: wallet connection, Anvil RPC client, time control. Prefer fixtures over copy-pasted setup in every spec.
// tests/fixtures/wallet.ts
import { test as base, type Page } from '@playwright/test'
export class WalletFixture {
address?: `0x${string}`
constructor(private page: Page) {}
async connect(name: 'alice' | 'bob') {
// setup mock account / click connect — app-specific
}
}
export const test = base.extend<{ wallet: WalletFixture }>({
wallet: async ({ page }, use) => {
await use(new WalletFixture(page))
},
})
// tests/fixtures/index.ts
import { mergeTests } from '@playwright/test'
import { test as walletTest } from './wallet'
import { test as anvilTest } from './anvil'
export * from '@playwright/test'
export const test = mergeTests(walletTest, anvilTest)
// tests/smoke.spec.ts
import { expect, test } from './fixtures'
test('connect', async ({ page, wallet }) => {
await page.goto('/')
await wallet.connect('alice')
await expect(page.getByText(`Connected: ${wallet.address}`)).toBeVisible()
})
// tests/fixtures/anvil.ts
import { test as base } from '@playwright/test'
import { createTestClient, http, publicActions, walletActions } from 'viem'
import { foundry } from 'viem/chains'
const anvil = 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 })
},
}))
export const test = base.extend<{ anvil: typeof anvil }>({
anvil: async ({}, use) => {
await use(anvil)
},
})
let snapshotId: `0x${string}` | undefined
test.beforeAll(async ({ anvil }) => {
snapshotId = await anvil.snapshot()
})
test.afterAll(async ({ anvil }) => {
if (snapshotId) await anvil.revert({ id: snapshotId })
})
Required when tests advance chain time — Anvil cannot go backwards without revert/snapshot.
page.evaluate and waitForFunctionCall in-page test hooks (e.g. Wagmi mock config):
await page.waitForFunction(() => (window as any)._setupAccount)
await page.evaluate(
(args) => (window as any)._setupAccount(...args),
[privateKey, features] as const
)
addInitScript for browser Dateawait page.addInitScript(`Date = class extends Date { /* patch */ }`)
await page.evaluate(() => { /* same patch without reload */ })
beforeEach without fixtures (hard to compose)expect(...).toBeVisible() / chain waitsdefi-ui-mock-connector — full wallet fixture with Wagmi mockdefi-ui-anvil-fixtures — time travel + multi-account patternsWhat SKILL.md sets; muted values are Claude Code's defaults
4 skills in this plugin
/playwright-configThis skill should be used when configuring Playwright for dApp/DeFi E2E — fullyParallel, workers, webServer, Chromium-only projects, baseURL, retries, and CI settings./playwright-overviewThis skill should be used when the user asks about "Playwright", "E2E browser tests", "@playwright/test", "playwright config", or needs to set up or run browser end-to-end tests for a web or dApp UI./playwright-webserverThis skill should be used when orchestrating Anvil, Hardhat node, or frontend servers from Playwright webServer config for DeFi E2E tests.Other plugins' skills for the same job
playwright@cyotee is listed by cyotee/cyotee-claude-plugins — review the source before installing
npx claudepluginhub cyotee/cyotee-claude-plugins --plugin playwright