jest-image-snapshot 6.1.1 → 6.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
+ # [6.2.0](https://github.com/americanexpress/jest-image-snapshot/compare/v6.1.1...v6.2.0) (2023-07-25)
2
+
3
+
4
+ ### Features
5
+
6
+ * allow configuration of postfix for received screenshots filename ([#328](https://github.com/americanexpress/jest-image-snapshot/issues/328)) ([bade294](https://github.com/americanexpress/jest-image-snapshot/commit/bade294ec2843c62b1dbcbf894faffd3a5708b98))
7
+
1
8
  ## [6.1.1](https://github.com/americanexpress/jest-image-snapshot/compare/v6.1.0...v6.1.1) (2023-07-25)
2
9
 
3
10
 
package/CONTRIBUTING.md CHANGED
@@ -47,7 +47,7 @@ Verifies that your code matches the American Express code style defined in [`esl
47
47
 
48
48
  Runs unit tests **and** verifies the format of all commit messages on the current branch.
49
49
 
50
- - **`npm posttest`**
50
+ - **`npm run posttest`**
51
51
 
52
52
  Runs linting on the current branch, checks that the commits follow [conventional commits](https://www.conventionalcommits.org/) and verifies that the `package-lock.json` file includes public NPM registry URLs.
53
53
 
package/README.md CHANGED
@@ -111,6 +111,7 @@ See [the examples](./examples/README.md) for more detailed usage or read about a
111
111
  * `customDiffDir`: A custom absolute path of a directory to keep this diff in
112
112
  * `storeReceivedOnFailure`: (default: `false`) Store the received images seperately from the composed diff images on failure. This can be useful when updating baseline images from CI.
113
113
  * `customReceivedDir`: A custom absolute path of a directory to keep this received image in
114
+ * `customReceivedPostfix`: A custom postfix which is added to the snapshot name of the received image, defaults to `-received`
114
115
  * `customSnapshotIdentifier`: A custom name to give this snapshot. If not provided one is computed automatically. When a function is provided it is called with an object containing `testPath`, `currentTestName`, `counter` and `defaultIdentifier` as its first argument. The function must return an identifier to use for the snapshot. If a path is given, the path will be created inside the snapshot/diff directories.
115
116
  * `diffDirection`: (default: `horizontal`) (options `horizontal` or `vertical`) Changes diff image layout direction
116
117
  * `onlyDiff`: (default: `false`) Either only include the difference between the baseline and the received image in the diff image, or include the 3 images (following the direction set by `diffDirection`).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jest-image-snapshot",
3
- "version": "6.1.1",
3
+ "version": "6.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": {
@@ -206,6 +206,7 @@ function diffImageToSnapshot(options) {
206
206
  snapshotIdentifier,
207
207
  snapshotsDir,
208
208
  storeReceivedOnFailure,
209
+ receivedPostfix = '-received',
209
210
  receivedDir = path.join(options.snapshotsDir, '__received_output__'),
210
211
  diffDir = path.join(options.snapshotsDir, '__diff_output__'),
211
212
  diffDirection,
@@ -228,7 +229,7 @@ function diffImageToSnapshot(options) {
228
229
  fs.writeFileSync(baselineSnapshotPath, receivedImageBuffer);
229
230
  result = { added: true };
230
231
  } else {
231
- const receivedSnapshotPath = path.join(receivedDir, `${snapshotIdentifier}-received.png`);
232
+ const receivedSnapshotPath = path.join(receivedDir, `${snapshotIdentifier}${receivedPostfix}.png`);
232
233
  rimraf.sync(receivedSnapshotPath);
233
234
 
234
235
  const diffOutputPath = path.join(diffDir, `${snapshotIdentifier}-diff.png`);
package/src/index.js CHANGED
@@ -137,6 +137,7 @@ function configureToMatchImageSnapshot({
137
137
  customSnapshotsDir: commonCustomSnapshotsDir,
138
138
  storeReceivedOnFailure: commonStoreReceivedOnFailure = false,
139
139
  customReceivedDir: commonCustomReceivedDir,
140
+ customReceivedPostfix: commonCustomReceivedPostfix,
140
141
  customDiffDir: commonCustomDiffDir,
141
142
  onlyDiff: commonOnlyDiff = false,
142
143
  diffDirection: commonDiffDirection = 'horizontal',
@@ -156,6 +157,7 @@ function configureToMatchImageSnapshot({
156
157
  customSnapshotsDir = commonCustomSnapshotsDir,
157
158
  storeReceivedOnFailure = commonStoreReceivedOnFailure,
158
159
  customReceivedDir = commonCustomReceivedDir,
160
+ customReceivedPostfix = commonCustomReceivedPostfix,
159
161
  customDiffDir = commonCustomDiffDir,
160
162
  onlyDiff = commonOnlyDiff,
161
163
  diffDirection = commonDiffDirection,
@@ -197,6 +199,7 @@ function configureToMatchImageSnapshot({
197
199
 
198
200
  const snapshotsDir = customSnapshotsDir || path.join(path.dirname(testPath), SNAPSHOTS_DIR);
199
201
  const receivedDir = customReceivedDir;
202
+ const receivedPostfix = customReceivedPostfix;
200
203
  const diffDir = customDiffDir;
201
204
  const baselineSnapshotPath = path.join(snapshotsDir, `${snapshotIdentifier}.png`);
202
205
  OutdatedSnapshotReporter.markTouchedFile(baselineSnapshotPath);
@@ -218,6 +221,7 @@ function configureToMatchImageSnapshot({
218
221
  snapshotsDir,
219
222
  storeReceivedOnFailure,
220
223
  receivedDir,
224
+ receivedPostfix,
221
225
  diffDir,
222
226
  diffDirection,
223
227
  onlyDiff,