jest-image-snapshot 5.1.1 → 6.0.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,29 @@
1
+ # [6.0.0](https://github.com/americanexpress/jest-image-snapshot/compare/v5.2.0...v6.0.0) (2022-11-03)
2
+
3
+
4
+ * chore(jest)!: add support for jest v29 (#309) ([79e53fc](https://github.com/americanexpress/jest-image-snapshot/commit/79e53fc010793f574cd9da783ced895af6987712)), closes [#309](https://github.com/americanexpress/jest-image-snapshot/issues/309)
5
+
6
+
7
+ ### BREAKING CHANGES
8
+
9
+ * Drop support for Node v12 and Node v17,
10
+ as Jest v29 does not support these versions.
11
+
12
+ * ci(release): use Node v16 for release action
13
+
14
+ Node v16 is the current active LTS release of Node.JS
15
+
16
+ Co-authored-by: Jamie King <hello@jamieking.me>
17
+
18
+ Co-authored-by: Jamie King <hello@jamieking.me>
19
+
20
+ # [5.2.0](https://github.com/americanexpress/jest-image-snapshot/compare/v5.1.1...v5.2.0) (2022-08-31)
21
+
22
+
23
+ ### Features
24
+
25
+ * 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))
26
+
1
27
  ## [5.1.1](https://github.com/americanexpress/jest-image-snapshot/compare/v5.1.0...v5.1.1) (2022-08-25)
2
28
 
3
29
 
package/README.md CHANGED
@@ -75,7 +75,7 @@ Thanks `jest-image-snapshot`, that broken header would not have looked good in p
75
75
  npm i --save-dev jest-image-snapshot
76
76
  ```
77
77
 
78
- Please note that `Jest` `>=20 <=27` is a peerDependency. `jest-image-snapshot` will **not** work with anything below Jest 20.x.x
78
+ Please note that `Jest` `>=20 <=29` is a peerDependency. `jest-image-snapshot` will **not** work with anything below Jest 20.x.x
79
79
 
80
80
  ### Invocation
81
81
 
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "jest-image-snapshot",
3
- "version": "5.1.1",
3
+ "version": "6.0.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": {
7
- "node": "^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0"
7
+ "node": "^14.15.0 || ^16.10.0 || >=18.0.0"
8
8
  },
9
9
  "scripts": {
10
10
  "lint": "eslint ./ --ignore-path .gitignore --ext .js",
@@ -53,14 +53,14 @@
53
53
  "eslint-config-amex": "^7.0.0",
54
54
  "husky": "^4.2.1",
55
55
  "image-size": "^0.8.3",
56
- "jest": "^28.0.3",
57
- "jest-snapshot": "^28.0.3",
56
+ "jest": "^29.0.0",
57
+ "jest-snapshot": "^29.0.0",
58
58
  "lockfile-lint": "^4.0.0",
59
59
  "mock-spawn": "^0.2.6",
60
60
  "semantic-release": "^17.0.4"
61
61
  },
62
62
  "dependencies": {
63
- "chalk": "^1.1.3",
63
+ "chalk": "^4.0.0",
64
64
  "get-stdin": "^5.0.1",
65
65
  "glur": "^1.1.2",
66
66
  "lodash": "^4.17.4",
@@ -71,7 +71,7 @@
71
71
  "ssim.js": "^3.1.1"
72
72
  },
73
73
  "peerDependencies": {
74
- "jest": ">=20 <=28"
74
+ "jest": ">=20 <=29"
75
75
  },
76
76
  "husky": {
77
77
  "hooks": {
@@ -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
@@ -15,7 +15,7 @@
15
15
  const kebabCase = require('lodash/kebabCase');
16
16
  const merge = require('lodash/merge');
17
17
  const path = require('path');
18
- const Chalk = require('chalk').constructor;
18
+ const Chalk = require('chalk').Instance;
19
19
  const { diffImageToSnapshot, runDiffImageToSnapshot } = require('./diff-snapshot');
20
20
  const fs = require('fs');
21
21
  const OutdatedSnapshotReporter = require('./outdated-snapshot-reporter');
@@ -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({
@@ -174,7 +174,8 @@ function configureToMatchImageSnapshot({
174
174
  } = this;
175
175
  const chalkOptions = {};
176
176
  if (typeof noColors !== 'undefined') {
177
- chalkOptions.enabled = !noColors;
177
+ // 1 means basic ANSI 16-color support, 0 means no support
178
+ chalkOptions.level = noColors ? 0 : 1;
178
179
  }
179
180
  const chalk = new Chalk(chalkOptions);
180
181
 
@@ -195,7 +196,7 @@ function configureToMatchImageSnapshot({
195
196
  const snapshotsDir = customSnapshotsDir || path.join(path.dirname(testPath), SNAPSHOTS_DIR);
196
197
  const receivedDir = customReceivedDir;
197
198
  const diffDir = customDiffDir;
198
- const baselineSnapshotPath = path.join(snapshotsDir, `${snapshotIdentifier}-snap.png`);
199
+ const baselineSnapshotPath = path.join(snapshotsDir, `${snapshotIdentifier}.png`);
199
200
  OutdatedSnapshotReporter.markTouchedFile(baselineSnapshotPath);
200
201
 
201
202
  if (snapshotState._updateSnapshot === 'none' && !fs.existsSync(baselineSnapshotPath)) {