jaredpalmer / cypress-image-snapshot

Catch visual regressions in Cypress
MIT License
891 stars 158 forks source link

Snapshots under CI are failing where local is succeeding #103

Closed nitzanashi closed 5 years ago

nitzanashi commented 5 years ago

I'm testing cypress with travis, Tests are keep failing in CI where on local they succeeding. I updated all snapshots to make sure that everything will success, though most differences are around 5%, but there are some (which are related to changes I did in that PR) where it's around 70% diff,

another fun fact, our Cypress Plan reached over 100% so no more recordings (so unfortunately can't see the differences), is it possible that CI is testing for some reason against the last snapshots that we're recorded into dashboard and not the one I just updated?

commands.js

import {addMatchImageSnapshotCommand} from 'cypress-image-snapshot/command';
addMatchImageSnapshotCommand();

plugins/index.js

const {addMatchImageSnapshotPlugin} = require('cypress-image-snapshot/plugin');

const webpack = require('@cypress/webpack-preprocessor');

const webpackOptions = require('../webpack.config');

module.exports = (on, config) => {
    const options = {webpackOptions};
    on('file:preprocessor', webpack(options));
    addMatchImageSnapshotPlugin(on, config);
};

Example test:

    it('can have error', () => {
        cy.get(soul(SANDBOX_ERROR)).type('Error Message');
        cy.get(soul(SANDBOX_SECTION)).matchImageSnapshot('error');
        cy.get(soul(SANDBOX_ERROR)).clear();
    });
dimitriy-k commented 5 years ago

base snapshots should be generated on the same environment as where they are compared. For example when I generate base snapshots in Chrome on my Mac, it will fail in Chrome on Linux in CI, because it renders fonts different.

I use linux docker to generate base snapshots on my Mac, the same linux version as on CI. Till now everything works ok.

nitzanashi commented 5 years ago

I didn't thought about running it on linux using Docker thanks for the tip.

I found some issues that caused the differences, mostly falsy snapshots, closing it :)