Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pixelmatchThreshold image config #237

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const DEFAULT_SCREENSHOT_CONFIG = Object.freeze({
const DEFAULT_IMAGE_CONFIG = Object.freeze({
createDiffImage: true,
resizeDevicePixelRatio: true,
pixelmatchThreshold: 0.01,
threshold: 0.1,
thresholdType: 'percent', // can be 'percent' or 'pixel'
});
Expand Down
2 changes: 1 addition & 1 deletion src/utils/tasks/imageSnapshots.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ function compareImages(expected, actual, diffFilename, config) {

const imageConfig = merge({}, DEFAULT_IMAGE_CONFIG, config);
const pixelmatchConfig = {
threshold: 0.01,
threshold: imageConfig.pixelmatchThreshold,
};

const imageWidth = actual.image.width;
Expand Down
1 change: 1 addition & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ declare namespace Cypress {
toMatchImageSnapshot(options?: Partial<{
imageConfig: Partial<{
createDiffImage: boolean,
pixelmatchThreshold: number,
threshold: number,
thresholdType: "percent" | "pixels",
resizeDevicePixelRatio: boolean
Expand Down