jest-image-snapshot 5.1.1 → 5.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # [5.2.0](https://github.com/americanexpress/jest-image-snapshot/compare/v5.1.1...v5.2.0) (2022-08-31)
2
+
3
+
4
+ ### Features
5
+
6
+ * remove snap suffix if use custom identifier ([#305](https://github.com/americanexpress/jest-image-snapshot/issues/305)) ([775ac0a](https://github.com/americanexpress/jest-image-snapshot/commit/775ac0a7dff33da9719b1dc36b9e382dc10a82a1))
7
+
1
8
  ## [5.1.1](https://github.com/americanexpress/jest-image-snapshot/compare/v5.1.0...v5.1.1) (2022-08-25)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jest-image-snapshot",
3
- "version": "5.1.1",
3
+ "version": "5.2.0",
4
4
  "description": "Jest matcher for image comparisons. Most commonly used for visual regression testing.",
5
5
  "main": "src/index.js",
6
6
  "engines": {
@@ -205,7 +205,7 @@ function diffImageToSnapshot(options) {
205
205
 
206
206
  const comparisonFn = comparisonMethod === 'ssim' ? ssimMatch : pixelmatch;
207
207
  let result = {};
208
- const baselineSnapshotPath = path.join(snapshotsDir, `${snapshotIdentifier}-snap.png`);
208
+ const baselineSnapshotPath = path.join(snapshotsDir, `${snapshotIdentifier}.png`);
209
209
  if (!fs.existsSync(baselineSnapshotPath)) {
210
210
  mkdirp.sync(path.dirname(baselineSnapshotPath));
211
211
  fs.writeFileSync(baselineSnapshotPath, receivedImageBuffer);
package/src/index.js CHANGED
@@ -108,7 +108,7 @@ function createSnapshotIdentifier({
108
108
  const counter = snapshotState._counters.get(currentTestName);
109
109
  const defaultIdentifier = kebabCase(`${path.basename(testPath)}-${currentTestName}-${counter}`);
110
110
 
111
- let snapshotIdentifier = customSnapshotIdentifier || defaultIdentifier;
111
+ let snapshotIdentifier = customSnapshotIdentifier || `${defaultIdentifier}-snap`;
112
112
 
113
113
  if (typeof customSnapshotIdentifier === 'function') {
114
114
  const customRes = customSnapshotIdentifier({
@@ -195,7 +195,7 @@ function configureToMatchImageSnapshot({
195
195
  const snapshotsDir = customSnapshotsDir || path.join(path.dirname(testPath), SNAPSHOTS_DIR);
196
196
  const receivedDir = customReceivedDir;
197
197
  const diffDir = customDiffDir;
198
- const baselineSnapshotPath = path.join(snapshotsDir, `${snapshotIdentifier}-snap.png`);
198
+ const baselineSnapshotPath = path.join(snapshotsDir, `${snapshotIdentifier}.png`);
199
199
  OutdatedSnapshotReporter.markTouchedFile(baselineSnapshotPath);
200
200
 
201
201
  if (snapshotState._updateSnapshot === 'none' && !fs.existsSync(baselineSnapshotPath)) {