Skip to main content

Mismatch Thresholds for SmartUI Visual Regression Testing


Mismatch Thresholds New

When running visual regression tests, not every pixel-level difference is a real bug. Minor rendering variations such as font anti-aliasing, date/time stamps, or animated content can cause screenshots to fail even when the page looks correct to the human eye.

Mismatch Thresholds let you define how much visual difference is acceptable before a screenshot is flagged. You can configure two values:

ParameterDescription
Approval ThresholdThe maximum mismatch percentage at which a screenshot is automatically approved. If the detected difference is at or below this value, the screenshot passes without manual review.
Rejection ThresholdThe minimum mismatch percentage at which a screenshot is automatically rejected. If the detected difference meets or exceeds this value, the screenshot is marked as failed.

Screenshots with a mismatch percentage between the approval and rejection thresholds will require manual review by an approver.

Example

If you set approvalThreshold: 2 and rejectionThreshold: 5:

  • A screenshot with 1.5% mismatch is auto-approved.
  • A screenshot with 3% mismatch needs manual review.
  • A screenshot with 6% mismatch is auto-rejected.

Supported Frameworks & Languages

LanguagesFrameworks
Java, JavaScript, Python, C#, RubySelenium, Appium

Threshold Hierarchy

You can set thresholds at three levels. When multiple levels are configured, the most specific setting takes priority:

PriorityLevelScopeHow to Set
1 (Highest)ScreenshotApplies to a single screenshotPass options in the smartuiSnapshot call
2BuildApplies to all screenshots in a buildSet in your test capabilities (LT:Options)
3 (Lowest)ProjectApplies to all builds in a projectConfigure in the LambdaTest SmartUI Dashboard
Backward Compatible

If you do not configure build or screenshot-level thresholds, your existing project-level settings continue to apply. No changes are needed to your existing tests.


Threshold Rules

Keep the following constraints in mind when configuring thresholds:

  • Both values must be a number between 0 and 100 (representing a percentage).
  • The approvalThreshold must be less than the rejectionThreshold.
  • If only one threshold is provided, the other falls back to the next level in the hierarchy (build or project).

Build-Level Configuration

Set thresholds for an entire build by adding them to your test capabilities. This overrides the project-level defaults for every screenshot captured in that build.

Capability Parameters

ParameterTypeDescription
smartUI.approvalThresholdNumberMismatch percentage at or below which screenshots are auto-approved.
smartUI.rejectionThresholdNumberMismatch percentage at or above which screenshots are auto-rejected.

Examples

Add thresholds to your LT:Options capabilities
let capabilities = {
browserName: "chrome",
"LT:Options": {
user: process.env.LT_USERNAME,
accessKey: process.env.LT_ACCESS_KEY,
"smartUI.approvalThreshold": 2,
"smartUI.rejectionThreshold": 5
}
};

Screenshot-Level Configuration

Override the build or project thresholds for individual screenshots. This is useful when specific pages contain dynamic content (e.g., live feeds, timestamps, ads) that naturally causes higher mismatch.

The smartuiSnapshot method accepts an optional options object with threshold parameters.

Options Parameters

ParameterTypeDescription
approvalThresholdNumberMismatch percentage at or below which this screenshot is auto-approved.
rejectionThresholdNumberMismatch percentage at or above which this screenshot is auto-rejected.

Examples

Pass thresholds as the third argument to smartuiSnapshot
// Screenshot using build/project-level thresholds (no override)
await smartuiSnapshot(driver, "Homepage");

// Screenshot with a custom threshold for a dynamic page
await smartuiSnapshot(driver, "Live Dashboard", {
approvalThreshold: 5,
rejectionThreshold: 10
});

Combining Build and Screenshot Thresholds

You can set a strict default at the build level and relax it only for specific screenshots that need it. Here is a full JavaScript example:

Build-level strict + screenshot-level relaxed
// Build-level: strict 1% approval, 3% rejection for most pages
let capabilities = {
browserName: "chrome",
"LT:Options": {
"smartUI.approvalThreshold": 1,
"smartUI.rejectionThreshold": 3
}
};

let driver = new webdriver.Builder()
.usingServer("https://hub.lambdatest.com/wd/hub")
.withCapabilities(capabilities)
.build();

// This screenshot uses the strict build-level thresholds (1% / 3%)
await driver.get("https://example.com/checkout");
await smartuiSnapshot(driver, "Checkout Page");

// This screenshot overrides with relaxed thresholds for a page with ads
await driver.get("https://example.com/homepage");
await smartuiSnapshot(driver, "Homepage with Ads", {
approvalThreshold: 5,
rejectionThreshold: 15
});

Common Use Cases

ScenarioRecommended Configuration
Pixel-perfect pages (login, checkout)Set tight thresholds: approvalThreshold: 0, rejectionThreshold: 1
Pages with minor dynamic content (timestamps, counters)Moderate thresholds: approvalThreshold: 2, rejectionThreshold: 5
Highly dynamic pages (live feeds, ad banners, dashboards)Relaxed screenshot-level thresholds: approvalThreshold: 10, rejectionThreshold: 20
Global default for all buildsSet via the SmartUI Dashboard at the project level

Test across 3000+ combinations of browsers, real devices & OS.

Book Demo

Help and Support

Related Articles