web-e2e
Run, create, and debug Playwright e2e tests for the web app. ALWAYS invoke this skill using the SlashCommand tool (i.e., `/web-e2e`) BEFORE attempting to run any e2e tests, playwright tests, anvil tests, or debug test failures. DO NOT run `bun playwright test` or other e2e commands directly - you must invoke this skill first to learn the correct commands and test architecture.
Install
mkdir -p .claude/skills/web-e2e && curl -L -o skill.zip "https://mcp.directory/api/skills/download/155" && unzip -o skill.zip -d .claude/skills/web-e2e && rm skill.zipInstalls to .claude/skills/web-e2e
About this skill
Web E2E Testing Skill
This skill helps you create and run end-to-end (e2e) Playwright tests for the Uniswap web application.
Test Architecture
Test Location
- All e2e tests live in
apps/web/src/directory structure - Test files use the naming convention:
*.e2e.test.ts - Anvil-specific tests (requiring local blockchain):
*.anvil.e2e.test.ts
Automatic Wallet Connection
Important: When running Playwright tests, the app automatically connects to a test wallet:
- Address:
0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266(constant:TEST_WALLET_ADDRESS) - Display name:
test0(the Unitag associated with this address) - Connection: Happens automatically via
wagmiAutoConnect.tswhen in Playwright environment
This means:
- Tests start with a wallet already connected
- You can immediately test wallet-dependent features
- The wallet button will show "test0" instead of "Connect wallet"
When using Playwright MCP: To enable automatic wallet connection when browsing via MCP tools, set the environment variable REACT_APP_IS_PLAYWRIGHT_ENV=true before starting the dev server. This makes the app behave identically to how it does in automated tests, with the test wallet auto-connected.
Custom Fixtures
The web app uses custom Playwright fixtures and mocks that extend base Playwright functionality.
They are located in apps/web/src/playwright/fixtures/* and apps/web/src/playwright/mocks/*.
Import Pattern
import { expect, getTest } from 'playwright/fixtures'
// For regular tests (no blockchain)
const test = getTest()
// For anvil tests (with blockchain)
const test = getTest({ withAnvil: true })
Available Fixtures
-
graphql - Mock GraphQL responses
await graphql.intercept('OperationName', Mocks.Path.to_mock) await graphql.waitForResponse('OperationName') -
anvil - Local blockchain client (only in anvil tests)
// Set token balances await anvil.setErc20Balance({ address, balance }) // Check balances await anvil.getBalance({ address }) await anvil.getErc20Balance(tokenAddress, ownerAddress) // Manage allowances await anvil.setErc20Allowance({ address, spender, amount }) await anvil.setPermit2Allowance({ token, spender, amount }) // Mining blocks await anvil.mine({ blocks: 1 }) // Snapshots for isolation const snapshotId = await anvil.takeSnapshot() await anvil.revertToSnapshot(snapshotId) -
tradingApi - Mock Trading API responses
await stubTradingApiEndpoint({ page, endpoint: uniswapUrls.tradingApiPaths.swap }) -
amplitude - Analytics mocking (automatic)
Test Structure
import { expect, getTest } from 'playwright/fixtures'
import { TestID } from 'uniswap/src/test/fixtures/testIDs'
const test = getTest({ withAnvil: true }) // or getTest() for non-anvil
test.describe('Feature Name', () => {
test.beforeEach(async ({ page }) => {
// Setup before each test
})
test('should do something', async ({ page, anvil, graphql }) => {
// Setup mocks
await graphql.intercept('Operation', Mocks.Path.mock)
// Setup blockchain state (if anvil test)
await anvil.setErc20Balance({ address, balance })
// Navigate to page
await page.goto('/path')
// Interact with UI using TestIDs
await page.getByTestId(TestID.SomeButton).click()
// Make assertions
await expect(page.getByText('Expected Text')).toBeVisible()
})
})
Best Practices
-
Use TestIDs - Always use the TestID enum for selectors (not string literals)
// Good await page.getByTestId(TestID.ReviewSwap) // Bad await page.getByTestId('review-swap') -
Mock External Services - Use fixtures to mock GraphQL, Trading API, REST API etc.
await graphql.intercept('PortfolioBalances', Mocks.PortfolioBalances.test_wallet) await stubTradingApiEndpoint({ page, endpoint: uniswapUrls.tradingApiPaths.quote }) -
Use Mocks Helper - Import mock paths from
playwright/mocks/mocks.tsimport { Mocks } from 'playwright/mocks/mocks' await graphql.intercept('Token', Mocks.Token.uni_token) -
Test Constants - Use constants from the codebase
import { USDT, DAI } from 'uniswap/src/constants/tokens' import { TEST_WALLET_ADDRESS } from 'playwright/fixtures/wallets' // TEST_WALLET_ADDRESS is the automatically connected wallet // It displays as "test0" in the UI -
Anvil State Management - Set up blockchain state properly
// Always set token balances before testing swaps await anvil.setErc20Balance({ address: assume0xAddress(USDT.address), balance: 100_000_000n })
Running Tests
The following commands must be run from the apps/web/ folder.
⚠️ PREREQUISITE: Playwright tests require the Vite preview server to be running at http://localhost:3000 BEFORE tests start. The bun e2e commands handle this automatically, but if running tests directly you must start the server first.
Development Commands
The e2e commands handle all requisite setup tasks for the playwright tests. These include building the app for production and running the Vite preview server.
# Run all e2e tests (starts anvil, builds, and runs tests)
bun e2e
# Run only non-anvil tests (faster, no blockchain required)
bun e2e:no-anvil
# Run only anvil tests (blockchain tests only)
bun e2e:anvil
# Run specific test file
bun e2e TokenSelector.e2e.test
Direct Playwright Commands
In some cases it may be helpful to run the commands more directly with the different tasks in different terminals.
# Step 1: Build the web app for e2e
bun build:e2e
# Step 2: Start the Vite preview server (REQUIRED - must be running before tests)
bun preview:e2e
# Wait for "Local: http://localhost:3000" message
# (Optional) Step 3: Start Anvil (note, Anvil tests can start this themselves)
bun anvil:mainnet
# Wait for "Listening on 127.0.0.1:8545" message
# Step 4: Run the playwright tests (only after servers are ready)
bun playwright:test
Test Modes
# Headed mode (see browser)
bun playwright test --headed
# Debug mode with Playwright Inspector
bun playwright test --debug
# UI mode (interactive)
bun playwright test --ui
Configuration
Playwright Config (playwright.config.ts)
Key settings:
testDir:./srctestMatch:**/*.e2e.test.tsworkers: 1 (configured in CI)fullyParallel: falsebaseURL:http://localhost:3000
Common Patterns
Navigation and URL Testing
await page.goto('/swap?inputCurrency=ETH&outputCurrency=USDT')
await expect(page.getByTestId(TestID.ChooseInputToken + '-label')).toHaveText('ETH')
Form Interactions
await page.getByTestId(TestID.AmountInputIn).fill('0.01')
await page.getByTestId(TestID.AmountInputIn).clear()
Token Selection
await page.getByTestId(TestID.ChooseOutputToken).click()
await page.getByTestId('token-option-1-USDT').first().click()
Waiting for Transaction Completion
await page.getByTestId(TestID.Swap).click()
await expect(page.getByText('Swapped')).toBeVisible()
Blockchain Verification
const balance = await anvil.getBalance({ address: TEST_WALLET_ADDRESS })
await expect(balance).toBeLessThan(parseEther('10000'))
Troubleshooting
Tests Timeout
- Check if Anvil is running:
bun anvil:mainnet - Ensure preview server is running:
bun preview:e2e
Anvil Issues
- Tests automatically manage Anvil snapshots for isolation
- Anvil restarts automatically if unhealthy
- For manual restart: stop the e2e command and run again
Mock Not Working
- Ensure mock path is correct in
Mocksobject - Check GraphQL operation name matches exactly
- Verify timing - intercept before the request is made
Test Flakiness
- Use proper waiting:
await expect(element).toBeVisible() - Don't use fixed
setTimeout- use Playwright's auto-waiting - Check for race conditions with network requests
Debugging
- Run tests with
--headedflag to watch the browser - Use
--debugflag to step through with Playwright Inspector - Add
await page.pause()in your test to stop at a specific point - Check test output and error messages carefully
- Review screenshots/videos in
test-results/directory after failures
Playwright Documentation References
For more details on Playwright features, refer to:
- Writing Tests - Test structure, actions, assertions
- Test Fixtures - Creating custom fixtures (like our anvil/graphql fixtures)
- Running Tests - Command line options, filtering, debugging
- API Testing - Mocking and intercepting network requests
- Locators - Finding elements (we use
getByTestIdprimarily) - Assertions - Available expect matchers
- Test Hooks - beforeEach, afterEach, beforeAll, afterAll
- Test Configuration - playwright.config.ts options
- Debugging Tests - UI mode, inspector, trace viewer
Playwright MCP Integration (Optional but Recommended)
The Playwright MCP (Model Context Protocol) provides browser automation capabilities that make test development and debugging easier:
- Interactive debugging - Navigate the app in a real browser to understand behavior
- Creating tests - Explore the UI to identify selectors and interactions
- Debugging failures - Inspect pag
Content truncated.
You might also like
flutter-development
aj-geddes
Build beautiful cross-platform mobile apps with Flutter and Dart. Covers widgets, state management with Provider/BLoC, navigation, API integration, and material design.
ui-ux-pro-max
nextlevelbuilder
"UI/UX design intelligence. 50 styles, 21 palettes, 50 font pairings, 20 charts, 8 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient."
drawio-diagrams-enhanced
jgtolentino
Create professional draw.io (diagrams.net) diagrams in XML format (.drawio files) with integrated PMP/PMBOK methodologies, extensive visual asset libraries, and industry-standard professional templates. Use this skill when users ask to create flowcharts, swimlane diagrams, cross-functional flowcharts, org charts, network diagrams, UML diagrams, BPMN, project management diagrams (WBS, Gantt, PERT, RACI), risk matrices, stakeholder maps, or any other visual diagram in draw.io format. This skill includes access to custom shape libraries for icons, clipart, and professional symbols.
godot
bfollington
This skill should be used when working on Godot Engine projects. It provides specialized knowledge of Godot's file formats (.gd, .tscn, .tres), architecture patterns (component-based, signal-driven, resource-based), common pitfalls, validation tools, code templates, and CLI workflows. The `godot` command is available for running the game, validating scripts, importing resources, and exporting builds. Use this skill for tasks involving Godot game development, debugging scene/resource files, implementing game systems, or creating new Godot components.
nano-banana-pro
garg-aayush
Generate and edit images using Google's Nano Banana Pro (Gemini 3 Pro Image) API. Use when the user asks to generate, create, edit, modify, change, alter, or update images. Also use when user references an existing image file and asks to modify it in any way (e.g., "modify this image", "change the background", "replace X with Y"). Supports both text-to-image generation and image-to-image editing with configurable resolution (1K default, 2K, or 4K for high resolution). DO NOT read the image file first - use this skill directly with the --input-image parameter.
pdf-to-markdown
aliceisjustplaying
Convert entire PDF documents to clean, structured Markdown for full context loading. Use this skill when the user wants to extract ALL text from a PDF into context (not grep/search), when discussing or analyzing PDF content in full, when the user mentions "load the whole PDF", "bring the PDF into context", "read the entire PDF", or when partial extraction/grepping would miss important context. This is the preferred method for PDF text extraction over page-by-page or grep approaches.
Related MCP Servers
Browse all serversEmpower your CLI agents with NotebookLM—connect AI tools for citation-backed answers from your docs, grounded in your ow
Enhance software testing with Playwright MCP: Fast, reliable browser automation, an innovative alternative to Selenium s
AI-driven control of live Chrome via Chrome DevTools: browser automation, debugging, performance analysis and network mo
Use Chrome DevTools for web site test speed, debugging, and performance analysis. The essential chrome developer tools f
Connect Blender to Claude AI for seamless 3D modeling. Use AI 3D model generator tools for faster, intuitive, interactiv
Supercharge browser tasks with Browser MCP—AI-driven, local browser automation for powerful, private testing. Inspired b
Stay ahead of the MCP ecosystem
Get weekly updates on new skills and servers.