jest-image-snapshot 6.4.0 → 6.5.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/.nvmrc ADDED
@@ -0,0 +1 @@
1
+ 20
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # [6.5.0](https://github.com/americanexpress/jest-image-snapshot/compare/v6.4.0...v6.5.0) (2025-05-12)
2
+
3
+
4
+ ### Features
5
+
6
+ * work with TypedArray / Array / ArrayBuffer ([b419a4d](https://github.com/americanexpress/jest-image-snapshot/commit/b419a4dfbd6a34470f2833073f4f714d98a871c9))
7
+
1
8
  # [6.4.0](https://github.com/americanexpress/jest-image-snapshot/compare/v6.3.0...v6.4.0) (2023-12-11)
2
9
 
3
10
 
package/CONTRIBUTING.md CHANGED
@@ -29,13 +29,19 @@ This project adheres to the American Express [Code of Conduct](./CODE_OF_CONDUCT
29
29
 
30
30
  > replace `your-github-username` with your github username
31
31
 
32
- 3. Install the dependencies by running
32
+ 3. Install and use the correct version of node (specified in `.nvmrc`)
33
+
34
+ ```bash
35
+ $ nvm use
36
+ ```
37
+
38
+ 4. Install the dependencies by running
33
39
 
34
40
  ```bash
35
41
  $ npm install
36
42
  ```
37
43
 
38
- 4. You can now run any of these scripts from the root folder.
44
+ 5. You can now run any of these scripts from the root folder.
39
45
 
40
46
  #### Running tests
41
47
 
@@ -112,4 +118,4 @@ Please review our [Security Policy](./SECURITY.md). Please follow the instructio
112
118
 
113
119
  ### Git Commit Guidelines
114
120
 
115
- We follow [conventional commits](https://www.conventionalcommits.org/) for git commit message formatting. These rules make it easier to review commit logs and improve contextual understanding of code changes. This also allows us to auto-generate the CHANGELOG from commit messages.
121
+ We follow [conventional commits](https://www.conventionalcommits.org/) for git commit message formatting. These rules make it easier to review commit logs and improve contextual understanding of code changes. This also allows us to auto-generate the CHANGELOG from commit messages.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jest-image-snapshot",
3
- "version": "6.4.0",
3
+ "version": "6.5.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": {
@@ -53,10 +53,11 @@
53
53
  "eslint-config-amex": "^7.0.0",
54
54
  "husky": "^4.2.1",
55
55
  "image-size": "^0.8.3",
56
- "jest": "^29.0.0",
56
+ "jest": "^29.7.0",
57
57
  "jest-snapshot": "^29.0.0",
58
- "lockfile-lint": "^4.0.0",
58
+ "lockfile-lint": "^4.14.0",
59
59
  "mock-spawn": "^0.2.6",
60
+ "rimraf": "^5.0.10",
60
61
  "semantic-release": "^17.0.4"
61
62
  },
62
63
  "dependencies": {
@@ -66,7 +67,6 @@
66
67
  "lodash": "^4.17.4",
67
68
  "pixelmatch": "^5.1.0",
68
69
  "pngjs": "^3.4.0",
69
- "rimraf": "^2.6.2",
70
70
  "ssim.js": "^3.1.1"
71
71
  },
72
72
  "peerDependencies": {
@@ -106,5 +106,10 @@
106
106
  "@semantic-release/git",
107
107
  "@semantic-release/github"
108
108
  ]
109
+ },
110
+ "overrides": {
111
+ "eslint-config-amex": {
112
+ "eslint": "$eslint"
113
+ }
109
114
  }
110
115
  }
@@ -18,7 +18,6 @@ const path = require('path');
18
18
  const pixelmatch = require('pixelmatch');
19
19
  const ssim = require('ssim.js');
20
20
  const { PNG } = require('pngjs');
21
- const rimraf = require('rimraf');
22
21
  const glur = require('glur');
23
22
  const ImageComposer = require('./image-composer');
24
23
 
@@ -271,10 +270,10 @@ function diffImageToSnapshot(options) {
271
270
  result = { added: true };
272
271
  } else {
273
272
  const receivedSnapshotPath = path.join(receivedDir, `${snapshotIdentifier}${receivedPostfix}.png`);
274
- rimraf.sync(receivedSnapshotPath);
273
+ fs.rmSync(receivedSnapshotPath, { recursive: true, force: true });
275
274
 
276
275
  const diffOutputPath = path.join(diffDir, `${snapshotIdentifier}-diff.png`);
277
- rimraf.sync(diffOutputPath);
276
+ fs.rmSync(diffOutputPath, { recursive: true, force: true });
278
277
 
279
278
  const defaultDiffConfig = comparisonMethod !== 'ssim' ? defaultPixelmatchDiffConfig : defaultSSIMDiffConfig;
280
279
 
package/src/index.js CHANGED
@@ -24,6 +24,14 @@ const timesCalled = new Map();
24
24
 
25
25
  const SNAPSHOTS_DIR = '__image_snapshots__';
26
26
 
27
+ function toBuffer(data) {
28
+ if (data == null || Buffer.isBuffer(data)) {
29
+ return data;
30
+ }
31
+
32
+ return Buffer.from(data);
33
+ }
34
+
27
35
  function updateSnapshotState(originalSnapshotState, partialSnapshotState) {
28
36
  if (global.UNSTABLE_SKIP_REPORTING) {
29
37
  return originalSnapshotState;
@@ -224,7 +232,7 @@ function configureToMatchImageSnapshot({
224
232
 
225
233
  const result =
226
234
  imageToSnapshot({
227
- receivedImageBuffer: received,
235
+ receivedImageBuffer: toBuffer(received),
228
236
  snapshotsDir,
229
237
  storeReceivedOnFailure,
230
238
  receivedDir,