Skip to content

Commit

Permalink
fix: base line for visual testing
Browse files Browse the repository at this point in the history
  • Loading branch information
marabesi committed Sep 10, 2023
1 parent 5f186c6 commit e501e47
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
Binary file modified cypress-visual-screenshots/baseline/pages.spec-index.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified cypress-visual-screenshots/baseline/pages.spec-settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ const { defineConfig } = require('cypress');
const getCompareSnapshotsPlugin = require('cypress-image-diff-js/dist/plugin');

module.exports = defineConfig({
viewportHeight: 920,
viewportWidth: 1280,
env: {
cypressImageDiff: {
FAILURE_THRESHOLD: 0,
FAILURE_THRESHOLD: 0.1,
}
},
e2e: {
Expand All @@ -15,8 +17,6 @@ module.exports = defineConfig({
'cypress/e2e/**/*.feature',
'cypress/regression/**/*.spec.js'
],
'viewportHeight': 920,
'viewportWidth': 1280,
setupNodeEvents(on, config) {
on('file:preprocessor', cucumber());
getCompareSnapshotsPlugin(on, config);
Expand Down
22 changes: 17 additions & 5 deletions cypress/regression/pages.spec.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
describe('visual testing regression', () => {
describe.only('visual testing regression', () => {
const visit = (path, darkAppearance) =>
cy.visit(path, {
onBeforeLoad(win) {
cy.stub(win, 'matchMedia')
.withArgs('(prefers-color-scheme: dark)')
.returns({
matches: darkAppearance,
});
},
});

it('should display the index page', () => {
cy.visit('/');
cy.viewport(1280, 920);
visit('/', true);
cy.wait(3000);
cy.compareSnapshot('index', 0);
cy.compareSnapshot('index', 0.1);
});

it('should display the settings page', () => {
cy.visit('/#/settings');
cy.viewport(1280, 920);
visit('/#/settings', true);
cy.wait(3000);
cy.compareSnapshot('settings', 0);
cy.compareSnapshot('settings', 0.1);
});
});

0 comments on commit e501e47

Please sign in to comment.