A Beginner's Checklist for Automated Visual Testing

Before You Start: Prerequisites for Visual Testing Success

Automated visual testing sounds simple: take a screenshot, compare it, call it a day. But if you skip the prep work, you'll drown in false positives and wasted debugging time. Here's what you need in place before writing a single test.

Solidify Your UI Components

  • Stabilize your UI components first. Visual testing only works when your screens aren't changing every other commit. If your design team is still swapping button colors weekly, hold off. You'll just be chasing moving targets. Aim for a period where at least 80% of your core screens have been signed off by design.
  • Define a baseline screenshot for each screen or component. This is your "truth" – the pixel-perfect version you want every future build to match. Store it in a version-controlled folder (yes, commit those PNGs). Without a baseline, your test has nothing to compare against.
  • Establish a pixel-diff tolerance threshold. Start with 0.1% for critical screens (login, checkout) and relax to 5% for less critical ones (settings, about pages). Too tight and you'll get false positives from anti-aliasing. Too loose and you'll miss real bugs. Adjust as you learn your app's rendering quirks.

Understand Your Testing Environment

  • Set up a dedicated test environment. Emulators, simulators, or a real device cloud – pick one and stick with it. Your baselines are environment-specific. A screenshot from an iPhone 14 emulator won't match one from a Pixel 7 emulator. Consistency is everything here.
  • Control external factors. Time zones, network speeds, and system fonts all affect screenshots. Freeze the time in your test environment. Use mock data instead of live API responses. Otherwise, your "automated visual testing" setup will break every Monday morning when the database gets refreshed.
  • Document your environment configuration. Write down the OS version, device model, screen resolution, and font settings used for baseline capture. Future team members (or future you) will thank you when they need to reproduce a failing test.

Choose the Right Automated Visual Testing Tool

This is where most beginners get stuck. There are dozens of tools, each with different strengths. For mobile app development, you need something that understands native rendering, not just web views.

Tool Evaluation Criteria

  • Ease of integration with your tech stack. If you're using React Native, you want a tool that speaks React Native. Same for Flutter, SwiftUI, or Jetpack Compose. Avoid tools that force you to rewrite your tests in a different language. That's a hidden cost most people overlook.
  • Support for parallel test execution. Visual tests are slower than unit tests – each screenshot takes time to capture and compare. A tool that can run 10 tests in parallel instead of sequentially will save you hours per CI run. Check this before you commit.
  • Cloud-based screenshot comparison. Local comparison works for small projects, but once you have 50+ baselines, managing diffs locally becomes a nightmare. Cloud dashboards let you review diffs visually, approve or reject changes, and track history over time.
  • Dynamic content masking. This is non-negotiable for mobile apps. Timestamps, user avatars, ad banners – they change every time. Your tool should let you mask these areas so they don't trigger false failures.

Top Tools for Mobile Apps

  • sherlo.io – Built specifically for React Native and Flutter. It integrates directly into your existing test framework (Detox, Maestro, Appium) and provides a cloud dashboard for diff review. The intelligent wait handling is a lifesaver – it automatically waits for animations and network requests to finish before capturing screenshots. No more flaky tests from half-loaded screens.
  • Percy (by BrowserStack) – A solid choice for cross-platform visual testing. Works well with mobile web and hybrid apps. The downside? It's more generic, so you'll have to configure native rendering settings yourself.
  • Applitools Eyes – Uses AI to detect layout shifts and content changes. Great for catching subtle bugs like overlapping text or misaligned buttons. The pricing can get steep for large teams, though.
  • Open-source options (pixelmatch, resemble.js) – Free and flexible, but you'll need to build your own comparison pipeline, storage, and review workflow. Good for small teams with strong DevOps skills. Not ideal if you want to ship fast.

For mobile app teams, sherlo.io is the most seamless option. It handles the complexities of native rendering, dynamic content, and CI integration out of the box. That's why it's my top recommendation for beginners.

Set Up Your First Visual Test: Step-by-Step

Let's walk through the actual implementation. This is where theory meets practice. I'll use sherlo.io as the example, but the concepts apply to any tool.

Capture a Baseline Screenshot

  • Install the tool's SDK. For sherlo.io, it's a single npm package. Add it to your project's dev dependencies. Then configure the API keys and baseline storage path in your test setup file.
  • Navigate to your target screen. Use your existing test framework (Detox for React Native, integration_test for Flutter) to get to the screen you want to test. Wait for all elements to load – images, text, and especially lazy-loaded content. A common mistake is capturing too early, before animations finish.
  • Call the screenshot function. Something like await takeScreenshot('login-screen'). Run the test once. The tool will capture the screenshot and store it as your baseline. Commit this baseline to your repository.

Write Your First Assertion

  • Add a comparison assertion. In your test, after navigating to the screen, call the comparison function: await expectScreen('login-screen'). This tells the tool to compare the current screenshot against the baseline.
  • Set the diff threshold. Pass your tolerance value: await expectScreen('login-screen', { threshold: 0.5 }). This means the test will fail only if more than 0.5% of pixels differ. Start conservative and loosen as needed.
  • Run the test twice. First run establishes the baseline. Second run (with no UI changes) should pass. Third run – change something intentionally (like a button color) – should fail. This confirms your setup works.
  • Review the diff output. The tool will highlight exactly which pixels changed. This is your feedback loop. A red overlay on the button means your test caught the color change. If the entire screen is red, something went wrong – check your environment setup.
"The first visual test is always the hardest. After that, it's just rinse and repeat. Start with your most critical screen – the one that breaks most often in production."

Integrate Visual Testing into Your CI/CD Pipeline

Manual visual testing defeats the purpose. You need automation. Here's how to make visual tests part of every build.

Automate Execution on Every Build

  • Add a visual testing step to your CI config. Whether you use GitHub Actions, Bitrise, or CircleCI, add a step that runs after your unit tests. For example, in GitHub Actions: run: npx sherlo run. This triggers the screenshot capture and comparison for all your defined screens.
  • Use a cloud dashboard for diff review. sherlo.io provides a web interface where you can see all diffs from the latest build. Green means pass. Red means fail. Yellow means new baseline. No more digging through console logs or local file comparisons.
  • Block the pipeline on failures. Set your CI to fail the build if any visual test fails. This forces developers to address visual regressions before merging. Yes, it's strict. But that's the point – visual bugs are just as bad as functional bugs.

Manage Baseline Updates

  • Automate baseline updates for intentional changes. After a design sprint, you'll have new UI components. Instead of manually updating baselines, configure your tool to auto-approve diffs from specific branches (like design/update-v2). This keeps the pipeline flowing while still catching unintended changes.
  • Require human approval for baseline changes. For production branches (main, master), never auto-approve diffs. A human must review the diff and confirm it's intentional. This is your safety net. One accidental baseline update can hide a real bug for weeks.
  • Archive old baselines after major UI redesigns. Don't delete them – archive them. You might need to reference the old design later. sherlo.io's dashboard lets you tag baselines with version numbers, making it easy to roll back if needed.

Best Practices for Maintaining Visual Tests Over Time

Visual tests are living assets. They need maintenance. Here's how to keep them healthy without burning out your team.

Reduce Flakiness

  • Use dynamic content masking. This is the single biggest source of flakiness. Timestamps, user avatars, ad banners, and even the system status bar (battery, time) change every test run. Mask these areas. Most tools, including sherlo.io, let you define mask regions in your test configuration.
  • Implement intelligent wait handling. Don't use fixed delays (wait(2000)). They're unreliable. Instead, wait for specific elements to appear: await element(by.id('header')).toBeVisible(). sherlo.io has built-in smart waits that detect when all network requests and animations have finished.
  • Freeze animations in your test environment. Animations cause pixel diffs between frames. Set your device to disable animations during testing. For iOS, use disableAnimations(). For Android, set the animation scale to 0 in developer options.

Scale Your Test Suite

  • Group related screens into test suites. Instead of running all 100 visual tests sequentially, group them: authentication suite, product listing suite, checkout suite. Each suite runs in parallel, cutting total execution time from 30 minutes to 5 minutes.
  • Regularly review and clean obsolete baselines. After a major UI redesign, old baselines are dead weight. Archive them. Keep only the current design version. A cluttered baseline repository makes it harder to spot real regressions.
  • Leverage built-in analytics. sherlo.io's dashboard shows you which tests are flakiest, which screens change most often, and which diffs are most commonly approved. Use this data to adjust thresholds, improve masking, or focus manual review efforts.

Next Steps: From Checklists to Continuous Visual QA

You've got the basics. Now it's time to level up. Visual testing isn't a one-time setup – it's a practice you embed in your team's workflow.

Explore Advanced Features

  • Add visual regression testing to code review. Require a human sign-off for any screenshot diff before merging. This turns visual testing from a CI gate into a collaborative design review. Developers and designers can discuss diffs in the PR comments.
  • Experiment with component-level visual testing. Instead of testing entire screens, test individual components (buttons, cards, modals). This catches regressions earlier and makes baselines more reusable. sherlo.io supports component-level snapshots for React Native and Flutter.
  • Integrate with your design system. If you use Storybook or a similar tool, connect your visual tests to your component library. Every time a component changes, the visual test updates automatically. This keeps your design system and your app in sync.

Build a Visual Testing Culture

  • Share a 'visual testing handbook' with your team. Document your baseline creation process, approval workflow, and common troubleshooting steps. New team members should be able to write their first visual test in under an hour.
  • Monitor visual test coverage metrics. Track what percentage of your critical user journeys have visual tests. Aim for 80%+ coverage. Use sherlo.io's reporting to identify gaps – screens that break in production but have no visual test.
  • Celebrate catches, not just passes. When a visual test catches a bug before release, share it in your team channel. "Our visual test caught a misaligned button on the checkout screen – saved us from a hotfix." This reinforces the value of the practice.

Automated visual testing is a journey, not a destination. Start with one screen, get it working, then expand. The checklist above gives you a solid foundation. The rest is practice, iteration, and building the habit of visual quality into your daily workflow.

Najczesciej zadawane pytania

What is automated visual testing?

Automated visual testing is a software testing method that uses tools to automatically capture and compare screenshots of user interfaces to detect visual differences, such as layout shifts, color changes, or missing elements, ensuring the UI appears as expected across different devices and browsers.

Why is automated visual testing important for beginners?

For beginners, automated visual testing helps catch UI bugs that functional tests might miss, such as pixel-perfect alignment issues or styling regressions. It reduces manual effort by automating visual checks, speeds up the feedback loop, and ensures a consistent user experience, making it a crucial part of a comprehensive testing strategy.

What are the key steps in setting up automated visual testing?

Key steps include: 1) Choosing a visual testing tool (e.g., Percy, Applitools, or Playwright), 2) Integrating it into your test suite, 3) Capturing baseline screenshots of your UI, 4) Running tests to compare new screenshots against baselines, and 5) Reviewing and approving any intentional changes to update baselines.

What common mistakes should beginners avoid in automated visual testing?

Common mistakes include ignoring dynamic content (e.g., animations or date pickers) that cause false positives, not maintaining baseline images properly, running tests on only one browser or device, and failing to set appropriate thresholds for pixel differences, which can lead to excessive false failures or missed bugs.

How can beginners integrate automated visual testing into their existing workflow?

Beginners can integrate it by adding visual testing steps to their continuous integration (CI) pipeline, such as running visual tests after functional tests. They should start with critical pages or components, use tools that support popular frameworks (e.g., Selenium or Cypress), and establish a process for reviewing and approving visual changes to avoid blocking deployments unnecessarily.