@anguske/playwright-visual-test
A visual regression testing tool based on Playwright, supporting UI screenshot comparison and automated testing.
Installation
npm install @anguske/playwright-visual-test
# or
yarn add @anguske/playwright-visual-test
# or
pnpm add @anguske/playwright-visual-test
Features
- Support for multiple viewport size testing
- Configurable comparison threshold
- Support for ignoring dynamic content areas
- Automatic comparison report generation
- Integration with MCP protocol
API Documentation
runTest(options)
Main test function, accepts the following parameters:
url: Target page URLviewport: Viewport size configuration{ width: number, height: number }waitForSelector?: Optional, wait for specific element to appearignoreSelectors?: Optional, array of selectors to ignorethreshold?: Optional, pixel comparison threshold (0-1)
License
MIT
MCP Playwright Visual Test Tool Configuration Guide
In mcp.json, you can configure the Playwright visual test tool as follows:
{
"mcp-playwright": {
"command": "npx",
"args": [
"-y",
"@anguske/mcp-playwright-visual-test"
],
"env": {
// Auto login configuration
"AUTO_LOGIN_USERNAME": "your-username",
"AUTO_LOGIN_PASSWORD": "your-password",
"AUTO_LOGIN_USERNAME_SELECTOR": "#userNameSignIn",
"AUTO_LOGIN_PASSWORD_SELECTOR": "#passwordSignIn",
"AUTO_LOGIN_SUBMIT_SELECTOR": "input[type="submit"]",
"AUTO_LOGIN_SUCCESS_SELECTOR": "", // Optional, element selector after successful login
"AUTO_LOGIN_URL_PATTERN": "login|signin|auth", // Login page URL match pattern
// Visual test configuration
"TEST_SELECTOR": "", // Optional, selector for element to screenshot
"TEST_WAIT_FOR_SELECTOR": "", // Optional, wait for specific element
"TEST_WAIT_TIMEOUT": 10000, // Optional, wait timeout in milliseconds
"TEST_THRESHOLD": 20, // Optional, pixel comparison threshold (0-100)
"TEST_IGNORE_SELECTORS": ".dynamic-content,.ads", // Optional, selectors to ignore, comma separated
"TEST_VIEWPORT_WIDTH": 1440, // Optional, viewport width, default 1280
"TEST_VIEWPORT_HEIGHT": 800, // Optional, viewport height, default 720
// Project configuration
"PROJECT_ROOT": "D:/myProject/quickstart-resources/weather-server-typescript" // Project root path
}
}
}
Configuration Details
Auto Login Configuration
AUTO_LOGIN_USERNAME: Login usernameAUTO_LOGIN_PASSWORD: Login passwordAUTO_LOGIN_USERNAME_SELECTOR: Username input field selectorAUTO_LOGIN_PASSWORD_SELECTOR: Password input field selectorAUTO_LOGIN_SUBMIT_SELECTOR: Login button selectorAUTO_LOGIN_SUCCESS_SELECTOR: Element selector after successful login (optional)AUTO_LOGIN_URL_PATTERN: Login page URL match pattern for auto-detecting login page redirects
Visual Test Configuration
TEST_SELECTOR: Selector for element to screenshot, captures entire page if not setTEST_WAIT_FOR_SELECTOR: Wait for specific element before taking screenshotTEST_WAIT_TIMEOUT: Timeout for waiting for element (milliseconds)TEST_THRESHOLD: Pixel difference threshold for image comparison (0-100), default 100TEST_IGNORE_SELECTORS: List of selectors to ignore during comparison, comma separatedTEST_VIEWPORT_WIDTH: Browser viewport width, default 1280TEST_VIEWPORT_HEIGHT: Browser viewport height, default 720
Project Configuration
PROJECT_ROOT: Absolute path to project root directory for storing screenshots and files
Notes
- All configuration items are optional, but it’s recommended to configure essential login information and viewport size
- Screenshots will be saved in the
screenshotsfolder in the project root directory - Comparison results will generate three files:
current.png: Current test screenshotbaseline.png: Baseline screenshotdiff.png: Difference comparison image
- On first run, the current screenshot will automatically be set as the baseline image
Playwright Visual Test
by pengqiAngus
219
Project Details
- pengqiAngus/playwright-mcp
- Last Updated: 4/17/2025
Recomended MCP Servers
Firecrawl Web Scraping Server
Official Firecrawl MCP Server - Adds powerful web scraping to Cursor, Claude and any other LLM clients.
Code Assistant
Vite MCP Server
MCP Server for Frontend dev environment (formerly known as vite-mcp-server)
🧩
Kube MCP Server
TIDAL Integration
🧩
PostgreSQL Advanced MCP Server
Full access postgres mcp server
Spotify MCP Server
🧩
ServiceTitan MCP Server
Cursor
Brian Knows
Unofficial MCP to use BrianKnows API for DeFI knowledge
JSON Document Collection Server
Use Model Context Protocol with multiple Fireproof JSON document databases
Rootly MCP Server
Rootly MCP server





