americanexpress / jest-image-snapshot

✨ Jest matcher for image comparisons. Most commonly used for visual regression testing.
Apache License 2.0
3.81k stars 197 forks source link

[BUG] Outdated-snapshot-reporter fails with custom snapshot ids #341

Open LauriNieminen opened 10 months ago

LauriNieminen commented 10 months ago

Describe the bug

Outdated-snapshot-reporter assumes that all snapshot files end with -snap.png. Files that end differently are not reported nor removed when obsolete.

Provide step-by-step guide on how to reproduce the bug

Use a customSnapshotIdentifier that does not end with -snap.png with outdated-snapshot-reporter enabled. Existing snapshot files will be ignored by the reporter.

expect(image).toMatchImageSnapshot({
    customSnapshotIdentifier: customFilename,
  })
{
(...)
reporters: [
    'default',
    'jest-image-snapshot/src/outdated-snapshot-reporter.js',
    ['jest-junit', { outputDirectory: './build/test-reports/jest' }],
    'jest-stare',
  ],
}

Expected behavior

Outdated-snapshot-reporter does not make assumptions about snapshot identifiers or exposes the suffix as a configurable parameter. Bare minimum would be to document the assumption extremely clearly.

System information