diff --git a/README.md b/README.md index b711519..edf93ab 100644 --- a/README.md +++ b/README.md @@ -118,6 +118,9 @@ Currently supported values in the custom config file: - FAILURE_THRESHOLD: must be between 0 and 1, default to 0 - RETRY_OPTIONS: see [retry options](https://www.npmjs.com/package/cypress-recurse#options) - FAIL_ON_MISSING_BASELINE: a boolean to determine whether to fail a test if its baseline doesn't exist, default to false +- COMPARISON_OPTIONS: custom options passed to pixelmatch, see [pixelmatch options](https://github.com/mapbox/pixelmatch#api), default to `{ threshold: 0.1 }`. Please note that the `COMPARISON_OPTIONS.threshold` is different from the `FAILURE_THRESHOLD` above: + - `COMPARISON_OPTIONS.threshold`: is the failure threshold for every pixel comparision + - `FAILURE_THRESHOLD`: is the failure threshold for the whole comparision > **Note**: In order to make this custom config values effective, remember to return `getCompareSnapshotsPlugin` instance inside function `setupNodeEvents`: diff --git a/src/config.js b/src/config.js index f1a1dd2..97c2c0c 100644 --- a/src/config.js +++ b/src/config.js @@ -13,7 +13,8 @@ const DEFAULT_CONFIG = { ROOT_DIR: '', FAILURE_THRESHOLD: 0, RETRY_OPTIONS: {}, - FAIL_ON_MISSING_BASELINE: false + FAIL_ON_MISSING_BASELINE: false, + COMPARISON_OPTIONS: { threshold: 0.1 } } export const userConfig = { ...DEFAULT_CONFIG, ...getUserConfigFile() } diff --git a/src/plugin.js b/src/plugin.js index d482c11..70e3693 100644 --- a/src/plugin.js +++ b/src/plugin.js @@ -93,7 +93,7 @@ const getStatsComparisonAndPopulateDiffIfAny = async (args) => { diff.data, diff.width, diff.height, - { threshold: 0.1 } + userConfig.COMPARISON_OPTIONS ) const percentage = (pixelMismatchResult / diff.width / diff.height) ** 0.5