simonsmith / cypress-image-snapshot

Catch visual regressions in Cypress with jest-image-snapshot
MIT License
64 stars 15 forks source link

empty folder is added at the screenshotsFolder path #34

Open maximegheraille opened 10 months ago

maximegheraille commented 10 months ago

Hi,

I do have a weird issue when taking screenshots, where I get a random folder with my test file name + extension created which is empty. As an example, this gets generated from the matchImageSnapshot function. /reports/mochareports/snapshot/brand/env/TestFileName/actualSnapshotName.png

But I also get this folder which is always empty /reports/mochareports/snapshot/brand/TestFileName.ts

This is my current config

const options: CypressImageSnapshotOptions = {
            failureThreshold: 0.1,
            allowSizeMismatch: true,
            failureThresholdType: 'percent',
            capture: 'viewport',
            comparisonMethod: 'ssim',
            customSnapshotsDir: `./cypress/reports/mochareports/snapshots/${Cypress.env(
                'brand',
            )}/${Cypress.env('env')}/${
                Cypress.spec.fileName
            }`,
            e2eSpecDir: `${Cypress.spec.relative}`,
        };

My cypress config contains screenshotsFolder: 'cypress/reports/mochareports/snapshots'

simonsmith commented 10 months ago

Yeah, I've seen that as well. I think it's because the screenshots get put there first before the plugin can move them but I'm not totally sure. Perhaps they can be cleaned up. I tend to gitignore them at the moment

maximegheraille commented 10 months ago

indeed, might be an idea to add an option to delete that folder which is defined in the cypress config when the plugin runs. Otherwise I guess I will go with a .gitignore rule

simonsmith commented 10 months ago

I'll take a look at this, but for now the .gitignore workaround is probably best