
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
visual-diff-tool
Advanced tools
Visual regression testing tool for comparing two URLs of the same app by capturing screenshots, performing pixel-by-pixel image comparisons, and highlighting visual differences. Ideal for detecting UI changes after deployments or updates.
Visual Diff Tool is a simple Node.js utility to capture screenshots of two web pages, compare them pixel-by-pixel, and detect visual differences.
Built using Puppeteer and Pixelmatch.
Good for UI regression testing and visual validation during your development or deployment processes.
npm install visual-diff-tool
const visualCompare = require('visual-diff-tool');
visualCompare('https://example.com')
.and('https://example.org')
.setLabel('homepage-compare')
.setViewport(1280, 720)
.setThreshold(0.05)
.compare()
.then(result => {
console.log(result);
});
Result format:
{
"diffPixels": 152,
"diffPath": "path/to/generated/diff-image.png",
"isDifferent": true
}
| Method | Description |
|---|---|
visualCompare(url1) | Initialize comparison with the first URL. |
.and(url2) | Set the second URL to compare against. |
.setLabel(label) | Set a custom label for screenshots and diff images. |
.setViewport(width, height) | Set browser viewport dimensions. |
.setThreshold(value) | Set pixel difference sensitivity threshold (default 0.1). |
.click(selector) | Perform a click action on the page before capturing. |
.type(selector, text) | Type text into a field before capturing. |
.waitForSelector(selector, options) | Wait for an element to appear before capturing. |
.compare() | Execute the comparison and return the result. |
visual-compare/
├── node_modules/
├── screenshots/ # Saved screenshots and diffs
├── src/
│ ├── actions/
│ │ └── actionHandler.js
│ ├── browsers/
│ │ ├── headlessBrowser.js
│ │ └── puppeteerBrowser.js
│ ├── utils/
│ │ ├── autoScroll.js
│ │ └── screenshotComparison.js
│ ├── index.js
│ ├── sample.js
│ └── visualCompare.js
├── tests/
│ └── index.test.js
├── .gitignore
├── package.json
├── package-lock.json
└── README.md
Perform actions like login and navigate through screens before comparison:
visualCompare('https://myapp.com/login')
.and('https://staging.myapp.com/login')
.click('#login-button')
.type('#username', 'testuser')
.type('#password', 'password123')
.waitForSelector('.dashboard')
.setViewport(1440, 900)
.setLabel('login-dashboard')
.setThreshold(0.02)
.compare()
.then(result => {
if (result.isDifferent) {
console.log(`Found differences! See: ${result.diffPath}`);
} else {
console.log('No visual differences detected.');
}
});
/screenshots/ directory.Example:
screenshots/
├── login-dashboard-screen1-1714384823945.png
├── login-dashboard-screen2-1714384823957.png
├── login-dashboard-diff-1714384823988.png
This tool is designed to be modular:
screenshotComparison.js if needed.Future enhancements (e.g., ignoring dynamic elements) can be added easily without breaking the core.
This project is licensed under the MIT License.
We welcome contributions!
Feel free to open issues, suggest new features, or submit a pull request to improve this project.
FAQs
Visual regression testing tool for comparing two URLs of the same app by capturing screenshots, performing pixel-by-pixel image comparisons, and highlighting visual differences. Ideal for detecting UI changes after deployments or updates.
We found that visual-diff-tool demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.