visual-healer
Version:
Self-healing visual regression & selector suggestions for web UI tests.
198 lines (143 loc) โข 4.67 kB
Markdown
# ๐ Visual Healer
**Visual Test Auto-Healer** is a CLI tool that detects UI layout shifts, broken selectors, and visual changes โ then proposes automatic fixes and generates reports. Perfect for regression testing and CI pipelines.



## ๐ Features
* โ
Detect layout shifts using visual diffing
* โ
Compare DOM elements and bounding boxes
* โ
Auto-suggest updated selectors using smart heuristics
* โ
Generate:
* ๐ Markdown report
* ๐ HTML report
* ๐งช JUnit XML report (CI-ready)
* โ
Support for `--ci` mode to fail builds on detection
* โ
Custom `--fail-on` filters (`healing`, `layout-shift`, `invalid-selector`)
* โ
CI-safe Puppeteer launch to avoid sandbox errors
* โ
Easy integration with GitHub Actions, GitLab CI, Jenkins
## ๐ข What's New in v1.0.4
- **CI-safe Puppeteer launch** to prevent โNo usable sandbox!โ errors in CI environments.
- Updated **GitHub Actions workflow**:
- **Gating step**: fails the build only for layout shifts.
- **Non-blocking healing step**: runs auto-healing analysis without blocking merges.
- More reliable selector validation in CI environments.
## ๐ฆ Installation
Run directly with `npx`:
```bash
npx visual-healer analyze https://example.com
```
Or install globally:
```bash
npm install -g visual-healer
```
## ๐งช Usage
### Basic command
```bash
npx visual-healer analyze https://example.com
```
### With CI mode
```bash
npx visual-healer analyze https://example.com --ci
```
### Fail CI only on specific issue type
```bash
# Fail only if auto-healing triggered
npx visual-healer analyze https://example.com --ci --fail-on healing
# Fail only on layout shifts
npx visual-healer analyze https://example.com --ci --fail-on layout-shift
# Fail only if suggested selector is invalid
npx visual-healer analyze https://example.com --ci --fail-on invalid-selector
```
## ๐ Output
After running, the tool generates:
```
/reports
โโโ report.md - Human-readable summary
โโโ report.html - Rich visual report with screenshots
โโโ junit-report.xml - CI-compatible test results
โโโ diff.png - Visual difference snapshot
โโโ elements/*.png - Cropped UI element images
```
## ๐ป Local Example
```bash
# Install dependencies
npm install
# Run the example
node examples/run-example.js
```
This will:
* Capture screenshot & DOM metadata from a sample URL
* Compare against a baseline (if available)
* Generate HTML, Markdown, and JUnit reports in `/reports`
* Show healing suggestions and visual diffs
## ๐ GitHub Actions Example
`.github/workflows/visual-healer.yml`:
```yaml
name: Visual Healer
on:
pull_request:
branches: [ main ]
jobs:
heal-and-diff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm ci
# Gatekeeper: only fail PRs on layout shifts
- name: Check for layout shifts (gating)
run: |
npx visual-healer analyze https://example.com --ci --fail-on layout-shift
# Also run healing, but do not fail the job; still upload artifacts
- name: Run healing analysis (non-blocking)
continue-on-error: true
run: |
npx visual-healer analyze https://example.com --ci --fail-on healing
- name: Upload report
if: always()
uses: actions/upload-artifact@v4
with:
name: visual-healer-report
path: reports
```
## ๐ GitLab CI Example
`.gitlab-ci.yml`:
```yaml
visual-healer:
image: node:20
script:
- npm ci
- npx visual-healer analyze https://example.com --ci --fail-on healing
artifacts:
when: always
paths:
- reports/junit-report.xml
reports:
junit: reports/junit-report.xml
```
## ๐ก Roadmap
* [x] CLI mode
* [x] Visual diffing
* [x] Selector confidence + code snippets
* [x] CI filters
* [x] JUnit report output
* [ ] AI-powered selector generation
* [ ] Web dashboard (optional SaaS)
## ๐งโ๐ป Author
Made by **Kakha Kitiashvili**
[GitHub Repo](https://github.com/kaha3/visual-healer)
## ๐ License
MIT