EagleDiff 以校準流程穩定動態網站的視覺回歸測試
EagleDiff: visual regression testing that sets up in minutes and gives the same answer every run
EagleDiff 是一款命令列視覺回歸測試工具,會在真實瀏覽器擷取網頁並與參考截圖比較,處理動畫及延遲載入等動態內容,以減少誤報。EagleDiff 在 Drupal Umami、WordPress with Elementor 及 Svelte with GSAP 基準中分別找出 26/27、15/18、11/12 個已知問題,且三者均無誤報。
Visual regression testing that sets up in minutes, gives the same answer every run, handles modern animated sites with sensible defaults, and lets you add your own capture rules when a site needs them. EagleDiff screenshots your pages in a real browser, compares them with your references and shows exactly what changed. When nothing changed, it says so: no false alarms from carousels, animations or images that load late.
A one-letter typo ("supermaket") in a heading, caught on a phone-sized screenshot of a long page.
What is it?
EagleDiff is a command-line tool. You point it at a site, and it:
- finds pages to test (up to 25 by default) and writes a
config.json; - captures every page, full length, at phone, tablet and desktop sizes;
- compares new captures with the references, using reg-suit under the hood;
- opens an HTML report with each change side by side, and exits with
0when everything passes and1when something changed, so it fits a CI pipeline.
Why I built it
I've used BackstopJS for years at work, on the sites we build and maintain. It's a great tool and it inspired a lot of EagleDiff. But on many of our sites it kept giving me different results on different runs of the same pages.
The obvious test for any visual regression tool is to compare a site with itself: take the references, capture the same pages again straight away, and expect everything to pass, because nothing changed. Far too often that didn't happen.
It wasn't really the screenshot technique that was at fault. The web has changed. A typical page today keeps moving after it has "loaded":
- images load lazily as you scroll, and web fonts arrive late;
- carousels autoplay, counters count up, testimonials rotate on a timer;
- JavaScript libraries such as GSAP run entrance animations and endless logo marquees;
- videos play, GIFs animate, and cookie banners slide in;
- scripts wait for jQuery or Drupal to finish starting up before they add content.
Take a screenshot at a slightly different moment and you get a slightly different page. The tool reports a "change", someone has to look at it, and it turns out to be nothing.
I still wanted a tool that gives consistent answers on these sites. So I set out to build one that compensates for the quirks of modern pages before it takes the screenshot.
That's where the name comes from. An eagle spots the smallest movement from far away, and that's the job I wanted done: notice the one-pixel shift and the one-letter typo, and ignore everything that doesn't matter. EagleDiff: an eagle's eye for differences.
Calibration comes first
The step I care most about is the one that comes before any real test. I call it calibration: compare the site with itself and make sure the tool passes.
eaglediff reference # save screenshots of the site as it is now
eaglediff calibrate # capture the same site again and compare
If calibration fails, nothing has changed on the site: something on the page moves between visits, and the tool isn't handling it yet. That's when you find out which pages need attention, before those false alarms reach your pipeline.
This matters most in CI. A visual check in a pipeline is only useful if it is reliable in both directions: it passes when nothing visible changed, and it fails when something did. A check that fails now and then for no reason soon becomes a burden. Someone has to open every report to see whether the failure is real, and eventually people stop looking. A tool you can't calibrate to a clean pass isn't ready for your pipeline.
Calibrate when you set up a project, and again at the start of a testing session: the live site may have changed since you took the references.
What it does for you by default
Out of the box, before each screenshot, EagleDiff:
- waits for lazy images (scrolling the page to trigger them), web fonts, background images, jQuery and Drupal start-up, network activity and count-up counters;
- steadies carousels (Swiper, Slick and others), CSS and Web Animations, JavaScript animations such as GSAP timelines and marquees, timer-driven rotators, SVG animations, animated GIFs, and videos and YouTube or Vimeo embeds;
- handles common cookie banners;
- fails loudly when an image or font is broken, instead of comparing a page with a hole in it, while still comparing the other pages;
- keeps responsive scripts still while it takes full-page screenshots, so menus and animations don't restart mid-capture.
Each of these is a small hook you can switch off, reorder, or replace with your own. Site-specific needs go in your config: hide a live chat widget, wait for a selector, pin a random image. If you test many sites, a team defaults file merges your agency's common settings into every project.
A first test in a minute
Let's try it on https://example.com. The commands below work exactly as they are, so you can paste them into a terminal, then swap in your own site's address when you're ready. You need Node.js 22.12 or newer and Chrome or Chromium.
npm install -g eaglediff
mkdir -p tests/eaglediff
cd tests/eaglediff
eaglediff config --ref=https://example.com # create config.json
eaglediff reference # save the references
eaglediff calibrate # compare with itself
example.com has a single page, captured at three sizes:
[eaglediff] Wrote config.json with 1 discovered scenarios
[eaglediff] Promoted 3 screenshots from .reg/actual to .reg/reference
[eaglediff] reference completed in 4s
...
[results] current 2026/11/23 14:45:04 | run=3 | passed=3 | dur=5s | workers=10
[eaglediff] calibrate completed in 5s
Calibration passed. Now set testBaseURL in config.json to your staging or local site and run the real comparison:
eaglediff test # exit code 1 if anything changed
eaglediff report # review the differences
eaglediff approve # accept the changes as the new references
Coming from BackstopJS? eaglediff import --backstop=path/to/backstop.json brings over your scenarios and supported settings.
A harder test: sites that move
example.com proves the workflow, not the tool. To test Eaglediff honestly, I built three benchmarks anyone can install and run, with any tool. Each one adds known visual bugs to a demo site, one per page, and keeps a few pages unchanged as controls. The bugs live in the site, not in EagleDiff:
- Drupal 11 Umami: the official Drupal demo, with responsive and lazy images, web fonts, two languages and an accented URL;
- WordPress with Elementor: carousels, counters, progress bars, entrance animations and lazy backgrounds;
- Svelte with GSAP: an animation-heavy agency template with smooth scrolling, an endless logo marquee, scroll-triggered reveals and a rotating testimonial.
The bugs are the kind that slip through review: a 1px shift, a 2px button move, a faded colour, a one-letter typo, a missing menu item on phones only, a broken lazy image below the fold, a missing web font file, a notice bar added by JavaScript two seconds after load, a page that answers with a server error.
With EagleDff's default settings and no site-specific configuration:
| Site | Calibration | Bugs found | False alarms |
|---|---|---|---|
| Drupal Umami | passed every run | 26 of 27 | 0 |
| WordPress with Elementor | passed every run | 15 of 18 | 0 |
| Svelte with GSAP | passed 10 of 10 runs | 11 of 12 | 0 |
The misses are all changes smaller than the default thresholds allow: image corners rounded by 8px, one digit or letter changed in small text, and a button colour shifted by a few shades. That's the trade-off that keeps real sites from failing on harmless rendering noise.
These are also changes that other kinds of tests catch better. A wrong digit in a price or in opening hours is a content bug: an end-to-end test that checks the text, for example with Playwright, finds it every time. A different corner radius or a slightly different brand colour is a design detail: component-level visual tests at strict thresholds, such as snapshot tools for Storybook, are made for that. Full-page visual regression testing is strongest at catching visible breakage across whole pages: layout shifts, missing or broken elements, wrong fonts and images, typos in headings. If you need more, you can still tighten the thresholds for your own project.
The Svelte site was the most useful of the three: on its first run, the unchanged site failed calibration on almost every attempt. It led to three fixes in EagleDiff:
- endless JavaScript animations are now held at their starting position;
- repeating timers, which rotate testimonials and tickers, are paused;
- full-page screenshots no longer make responsive scripts restart their animations.
Every fix became a default, so the next site like it should calibrate cleanly without any configuration.
And BackstopJS?
Because the bugs live in the sites, the same benchmarks run with any tool. Here is BackstopJS 6.3.25 with the defaults backstop init creates, on the same sites on the same day. The scripts to reproduce it are in the repository too.
| Site | Calibration | Bugs found |
|---|---|---|
| Drupal Umami | passed (0 of 99 screenshots flagged) | 19 of 27 |
| WordPress with Elementor | failed (15 of 66 flagged) | not meaningful |
| Svelte with GSAP | failed (42 to 45 of 48 flagged) | not meaningful |
On Umami, Backstop is steady but misses content added after load and the smaller changes. On the two animated sites, it flags pages that didn't change, run after run, so a flagged bug page tells you nothing. That is exactly the problem I started with.
To be fair to BackstopJS: these are its defaults, without tuning. Delays, hide selectors and custom scripts can steady many of these pages, and that's what we used to do, page by page and site by site. EagleDiff's aim is to make that work unnecessary for the common cases.
Where it stands
EagleDiff has been tested extensively on the projects I work on, and there it is far more consistent than what I used before. I'll keep improving it as I meet new kinds of sites, and keep turning fixes into defaults where they make sense.
It hasn't been tested by a wider audience yet. You'll find sites where it needs refining. It's tested on Linux; macOS and Windows should work, but I haven't tried them. Not every BackstopJS feature is there either; I'll add what people ask for.
I built EagleDiff with the help of AI coding assistants, OpenAI's Codex and Anthropic's Claude Code.
Try it
- GitHub: https://github.com/GiorgosK/EagleDiff
- npm:
npm install -g eaglediff - Benchmarks:
benchmark/in the repository; run them with your favourite tool and compare.
Try it on your own sites and start with eaglediff calibrate. If it doesn't pass, please open an issue with the page and what moved. That's exactly the feedback that makes the defaults better. Pull requests are very welcome.
I'm releasing EagleDiff in the hope that it saves other people the hours I spent opening reports that turned out to show nothing at all.
來源:DEV Community · dev.to
