Skip to main content
Use expect(driver).toHaveScreenshot() to compare a screenshot of the current native app screen against a stored baseline. For web and mobile web visual diffing, see Web & Mobile web screenshots.
  • name — string used to identify and store the baseline image
  • options — optional object controlling comparison behavior, see Key options below

Examples

iOS
Android
Assert a specific element Pass a WebdriverIO element instead of driver to scope the screenshot to a specific UI component:
Omitting a name and maxMisMatchPercentage makes the baseline hard to identify and causes minor rendering differences to fail the test.

When to use

  • Your app has a rendering-heavy screen like a chart or map that can’t be asserted with selectors.
  • Your app has pixel-perfect design requirements and you want automated enforcement.
  • Your app has gone through a redesign and you need to catch layout regressions.
  • Your test needs to verify a visual state that no functional assertion can cover.
Avoid toHaveScreenshot when the screen contains timestamps, live data, animations, or other frequently-changing content — these cause false failures. Use a functional assertion instead.

Key options

maxMisMatchPercentage is a 0–100 percentage, unlike the web API’s maxDiffPixelRatio which is a 0–1 ratio.

Notes

  • On the first run, no baseline exists yet — the screenshot is saved automatically as the expected image. Review it before relying on the test.
  • The editor shows the diff, the expected image, and the actual image for each named snapshot, and compares them.
  • On subsequent runs, a new screenshot is compared pixel-by-pixel to the baseline. If the difference exceeds the threshold, the test fails and a diff image is saved showing exactly which pixels changed.
  • If a UI change is intentional, promote the new screenshot as the updated baseline in the QA Wolf editor. Future runs will compare against the new image.
  • On iOS, baselines are named by device screen size (e.g. home-screen-ios-390×844-expected.png) — a baseline captured on an iPhone 15 will not match an iPhone 15 Plus.
  • Baselines are stored in team storage under _screenshots_ and are shared across all flows in the same team.

Full sample test

Last modified on December 4, 2026