Visual Regression Testing
FlutterProbe includes screenshot-based visual regression testing that compares current screenshots against baseline images to detect unintended visual changes.
How It Works
Section titled “How It Works”- Baseline capture — On the first run, screenshots are saved as baseline images
- Comparison — On subsequent runs, new screenshots are compared pixel-by-pixel against the baselines
- Diff reporting — If the difference exceeds the configured threshold, the test fails with a visual diff
Taking Screenshots
Section titled “Taking Screenshots”Use the take screenshot command in your tests:
test "checkout page looks correct" open the app tap "Cart" tap "Checkout" wait for the page to load take screenshot "checkout_page"Screenshots are saved as PNG files in the reports/screenshots/ directory.
Configuration
Section titled “Configuration”Threshold
Section titled “Threshold”The maximum allowed pixel difference as a percentage. If the diff exceeds this value, the test fails.
visual: threshold: 0.5 # 0.5% — defaultOr via CLI flag:
probe test tests/ --visual-threshold 0.5Pixel Delta
Section titled “Pixel Delta”The per-pixel color delta tolerance. Small differences (e.g., anti-aliasing) below this value are ignored.
visual: pixel_delta: 8 # defaultOr via CLI flag:
probe test tests/ --visual-pixel-delta 8Typical Workflow
Section titled “Typical Workflow”- Create baseline — Run tests the first time to capture baseline screenshots
- Make changes — Update your app UI
- Run tests — Visual regression detects differences against the baseline
- Review diffs — Check if changes are intentional
- Update baseline — If changes are expected, re-run to update the baselines
- Use a consistent device/simulator for baselines (different screen sizes produce different screenshots)
- Set a reasonable threshold — too low causes false positives from rendering differences, too high misses real regressions
- Run visual regression tests on a single platform first, then expand
- Screenshots are captured by the Dart agent directly (no external tools needed)