Before running the tests, ensure you have:
- Node.js 20.x or later installed
- Network access to download Playwright browsers
- Port 3000 available for dev server
- Port 8545 available for Hardhat node (full tests only)
# Install project dependencies
npm install
# Install Playwright browsers
npx playwright install chromiumRun basic UI tests against the dev server only:
# Run all tests with simple config
npx playwright test --config=playwright.config.simple.jsRun complete integration tests with local blockchain:
# Run all tests with full setup
npm run test:e2e# Launch Playwright UI for test development
npm run test:e2e:ui# Run tests with visible browser
npm run test:e2e:headed# Run tests with debugger
npm run test:e2e:debug# Run single test file
npx playwright test test/e2e/specs/explorer.spec.js
# Run tests matching pattern
npx playwright test --grep "theme"After running tests, view the HTML report:
npm run test:e2e:reportOr open directly:
open playwright-report/index.htmlTests generate several artifacts:
- Screenshots:
screenshots/e2e/*.png - Videos:
test-results/*/video.webm(on failure) - Traces:
test-results/*/trace.zip(on failure) - Reports:
playwright-report/index.html
Install Playwright browsers:
npx playwright install chromiumStop existing dev server or set reuseExistingServer: true in config.
Ensure port 8545 is free:
lsof -ti:8545 | xargs kill -9Increase timeout in test files or config:
test.setTimeout(60000); // 60 secondsUse simple config to skip Hardhat:
npx playwright test --config=playwright.config.simple.js- Create spec file in
test/e2e/specs/ - Import helpers:
const { test, expect } = require('@playwright/test'); const { setupWallet, connectWallet } = require('../helpers/test-helpers');
- Add test:
test('my test', async ({ page }) => { await setupWallet(page); await page.goto('/'); await connectWallet(page); // Your test code });
For continuous integration:
# Set CI environment variable
CI=true npm run test:e2e
# This enables:
# - 2 retries on failure
# - No server reuse
# - Strict failure modeAfter running tests:
- Review test report
- Check screenshots for visual issues
- Fix any failing tests
- Update tests as features change
- Add new tests for new features
- See
test/e2e/README.mdfor detailed documentation - Check
TEST_REPORT.mdfor implementation details - Review test files for examples
Ready to test? Run npm run test:e2e to start!