Skip to content

Commit

Permalink
fix: set default user config when cypressImageDiff undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
kien-ht committed Sep 11, 2023
1 parent 08aa95d commit 76374f8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
3 changes: 2 additions & 1 deletion src/command.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { recurse } from 'cypress-recurse';
import DEFAULT_CONFIG from './config.default'

const compareSnapshotCommand = defaultScreenshotOptions => {
const userConfig = Cypress.env('cypressImageDiff')
const userConfig = Cypress.env('cypressImageDiff') || DEFAULT_CONFIG

const height = Cypress.config('viewportHeight') || 1440
const width = Cypress.config('viewportWidth') || 1980
Expand Down
11 changes: 11 additions & 0 deletions src/config.default.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export default {
ROOT_DIR: '',
FAILURE_THRESHOLD: 0,
RETRY_OPTIONS: {},
FAIL_ON_MISSING_BASELINE: false,
COMPARISON_OPTIONS: { threshold: 0.1 },
JSON_REPORT: {
FILENAME: '',
OVERWRITE: true,
},
}
13 changes: 1 addition & 12 deletions src/config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import path from 'path'
import merge from 'lodash/merge'
import DEFAULT_CONFIG from './config.default'

function getUserConfigFile() {
try {
Expand All @@ -10,18 +11,6 @@ function getUserConfigFile() {
}
}

const DEFAULT_CONFIG = {
ROOT_DIR: '',
FAILURE_THRESHOLD: 0,
RETRY_OPTIONS: {},
FAIL_ON_MISSING_BASELINE: false,
COMPARISON_OPTIONS: { threshold: 0.1 },
JSON_REPORT: {
FILENAME: '',
OVERWRITE: true
}
}

export const userConfig = merge(DEFAULT_CONFIG, getUserConfigFile())

export class Paths {
Expand Down

0 comments on commit 76374f8

Please sign in to comment.