jest-image-snapshot 6.4.0 → 6.5.1
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 +1 -0
- package/CHANGELOG.md +14 -0
- package/CONTRIBUTING.md +9 -3
- package/package.json +9 -4
- package/src/diff-snapshot.js +2 -3
- package/src/index.js +12 -1
package/.nvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
20
|
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
## [6.5.1](https://github.com/americanexpress/jest-image-snapshot/compare/v6.5.0...v6.5.1) (2025-05-20)
|
2
|
+
|
3
|
+
|
4
|
+
### Bug Fixes
|
5
|
+
|
6
|
+
* work with base64 strings ([#368](https://github.com/americanexpress/jest-image-snapshot/issues/368)) ([9a3ca4f](https://github.com/americanexpress/jest-image-snapshot/commit/9a3ca4f173669250a49b9a5709f8ba933b55fc78))
|
7
|
+
|
8
|
+
# [6.5.0](https://github.com/americanexpress/jest-image-snapshot/compare/v6.4.0...v6.5.0) (2025-05-12)
|
9
|
+
|
10
|
+
|
11
|
+
### Features
|
12
|
+
|
13
|
+
* work with TypedArray / Array / ArrayBuffer ([b419a4d](https://github.com/americanexpress/jest-image-snapshot/commit/b419a4dfbd6a34470f2833073f4f714d98a871c9))
|
14
|
+
|
1
15
|
# [6.4.0](https://github.com/americanexpress/jest-image-snapshot/compare/v6.3.0...v6.4.0) (2023-12-11)
|
2
16
|
|
3
17
|
|
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
|
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
|
-
|
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.
|
3
|
+
"version": "6.5.1",
|
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.
|
56
|
+
"jest": "^29.7.0",
|
57
57
|
"jest-snapshot": "^29.0.0",
|
58
|
-
"lockfile-lint": "^4.
|
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
|
}
|
package/src/diff-snapshot.js
CHANGED
@@ -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
|
-
|
273
|
+
fs.rmSync(receivedSnapshotPath, { recursive: true, force: true });
|
275
274
|
|
276
275
|
const diffOutputPath = path.join(diffDir, `${snapshotIdentifier}-diff.png`);
|
277
|
-
|
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,17 @@ 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
|
+
if (typeof data === 'string') {
|
32
|
+
return Buffer.from(data, 'base64');
|
33
|
+
}
|
34
|
+
|
35
|
+
return Buffer.from(data);
|
36
|
+
}
|
37
|
+
|
27
38
|
function updateSnapshotState(originalSnapshotState, partialSnapshotState) {
|
28
39
|
if (global.UNSTABLE_SKIP_REPORTING) {
|
29
40
|
return originalSnapshotState;
|
@@ -224,7 +235,7 @@ function configureToMatchImageSnapshot({
|
|
224
235
|
|
225
236
|
const result =
|
226
237
|
imageToSnapshot({
|
227
|
-
receivedImageBuffer: received,
|
238
|
+
receivedImageBuffer: toBuffer(received),
|
228
239
|
snapshotsDir,
|
229
240
|
storeReceivedOnFailure,
|
230
241
|
receivedDir,
|