cypress-image-snapshot icon indicating copy to clipboard operation
cypress-image-snapshot copied to clipboard

snapFilenameExtension breaks snapshot comparison

Open maximegheraille opened this issue 1 year ago • 4 comments

Hi,

I configured snapFilenameExtension to an empty string to not have the .snap for each snapshot, but it does seems to break everything.

these are the issues it creates

  • does not fail the test if the snapshot is different
  • it modifies the original snapshot

it does however still creates a .diff snapshot, which is normal.

this is my current config

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

I tried to remove the snapFilenameExtension and add the .snap on each snapshot and then everything works fine.

maximegheraille avatar Feb 22 '24 13:02 maximegheraille

Just to clarify the issue, you were aiming to not have the .snap at all?

- cypress/snapshots/someTest/takes a snapshot of the page.snap.png
+ cypress/snapshots/someTest/takes a snapshot of the page.png

simonsmith avatar Feb 22 '24 21:02 simonsmith

Hi @simonsmith

That is what I indeed want, but it seems that using the option breaks stuff

maximegheraille avatar Feb 23 '24 06:02 maximegheraille

Just looking again at this because it might be similar to #61

There is a test here that asserts that a snapshot is created without the .snap extension. In your example above can you perhaps reduce the options down to as little as possible to see if that works?

I'm wondering if it's another option you've added that is causing a problem

simonsmith avatar Sep 16 '24 19:09 simonsmith

Hi, sorry I completely forgot to respond.

From my testing it seems related to the configuration option retries of cypress. With retries not set to 0, I can see when debugging cypress that the snapshots actually fails and it has a created a diff image but cypress itself does not flag it as a failed test.

It seems you do not have a test case for this, would it be useful to add one? It might just be a cypress issue in the end

maximegheraille avatar Jan 06 '25 19:01 maximegheraille