Skip to content

Commit

Permalink
Fix options bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Zaista committed Sep 6, 2024
1 parent 26e6b58 commit 975d330
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## v5.2.1

- Fix bug with providing options through e2e file, fixes [#267](https://github.com/cypress-visual-regression/cypress-visual-regression/issues/267)

## v5.2.0

- Enable overriding pixelmatch options, fixes [#263](https://github.com/cypress-visual-regression/cypress-visual-regression/issues/263) and [#113](https://github.com/cypress-visual-regression/cypress-visual-regression/issues/113)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cypress-visual-regression",
"version": "5.2.0",
"version": "5.2.1",
"description": "Module for adding visual regression testing to Cypress",
"keywords": [
"visual regression",
Expand Down
6 changes: 6 additions & 0 deletions src/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,12 @@ function prepareOptions(
if (screenshotOptions.pixelmatchOptions !== undefined) {
options.pluginOptions.pixelmatchOptions = screenshotOptions.pixelmatchOptions
}
if (screenshotOptions.errorThreshold !== undefined) {
options.pluginOptions.errorThreshold = screenshotOptions.errorThreshold
}
if (screenshotOptions.failSilently !== undefined) {
options.pluginOptions.failSilently = screenshotOptions.failSilently
}
// TODO refactor this in next release, separate plugin vs screenshot properties
options.screenshotOptions = { ...screenshotOptions, ...commandOptions }

Expand Down
4 changes: 2 additions & 2 deletions tests/integration/cypress/e2e/main.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ describe('Visual Regression Example', () => {
it('should display the foo page incorrectly', () => {
cy.on('fail', (error) => {
if (error.message.includes("The 'bar' image is different.")) {
expect(error.message).to.contain("Threshold limit of '0' exceeded")
expect(error.message).to.contain("Threshold limit of '0.007' exceeded")
expect(error.message).to.contain(' - [Show Difference]')
return
}
Expand Down Expand Up @@ -213,7 +213,7 @@ describe('Visual Regression Example', () => {
}
expect(options.baseDirectory).to.equal('cypress/snapshots/base')
expect(options.diffDirectory).to.equal('cypress/snapshots/diff')
expect(options.pluginOptions.errorThreshold).to.equal(0)
expect(options.pluginOptions.errorThreshold).to.equal(0.007)
expect(options.pluginOptions.failSilently).to.be.false
expect(options.generateDiff).to.equal('fail')
expect(options.screenshotAbsolutePath).to.exist
Expand Down
6 changes: 1 addition & 5 deletions tests/integration/cypress/e2e/sub-folder/deep-spec.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@ describe('Inner file within context', () => {
describe('File name tests', () => {
it('test file names', () => {
cy.on('fail', (error) => {
if (
error.message.includes(
"The 'files-1[2<3>4:5\"6\\7|8?9*10, 11]12(13)' image is different. Threshold limit of '0' exceeded"
)
) {
if (error.message.includes("The 'files-1[2<3>4:5\"6\\7|8?9*10, 11]12(13)' image is different")) {
return
}
throw error
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/cypress/support/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ addCompareSnapshotCommand({
pixelmatchOptions: {
threshold: 0.1
},
errorThreshold: 0,
errorThreshold: 0.007,
failSilently: false,
capture: 'fullPage'
})

0 comments on commit 975d330

Please sign in to comment.