jest-image-snapshot 4.4.1 → 5.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.
@@ -0,0 +1,2 @@
1
+ one-app-team-review-requested:
2
+ - '**/*'
@@ -0,0 +1,31 @@
1
+ name: Health Check
2
+
3
+ on:
4
+ schedule:
5
+ # At minute 0 past hour 0800 and 2000.
6
+ - cron: '0 8,20 * * *'
7
+
8
+ jobs:
9
+ tests:
10
+ runs-on: ubuntu-latest
11
+ strategy:
12
+ matrix:
13
+ node: [ '10.x', '12.x', '14.x', '16.x' ]
14
+ name: Node ${{ matrix.node }}
15
+ steps:
16
+ - uses: actions/checkout@v2
17
+ - run: |
18
+ git remote set-branches --add origin main
19
+ git fetch
20
+ - name: Setup Node
21
+ uses: actions/setup-node@v2
22
+ with:
23
+ node-version: ${{ matrix.node }}
24
+ - name: Install Dependencies
25
+ run: npm ci
26
+ env:
27
+ NODE_ENV: development
28
+ - name: Run Test Script
29
+ run: npm run test
30
+ env:
31
+ NODE_ENV: production
@@ -0,0 +1,12 @@
1
+ name: "Pull Request Labeler"
2
+ on:
3
+ pull_request_target:
4
+ types: [opened, reopened]
5
+
6
+ jobs:
7
+ triage:
8
+ runs-on: ubuntu-latest
9
+ steps:
10
+ - uses: actions/labeler@v3
11
+ with:
12
+ repo-token: "${{ secrets.GITHUB_TOKEN }}"
@@ -0,0 +1,37 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+
8
+ jobs:
9
+ prepare:
10
+ runs-on: ubuntu-latest
11
+ if: "! contains(github.event.head_commit.message, '[skip ci]')"
12
+ steps:
13
+ - run: echo "${{ github.event.head_commit.message }}"
14
+ release:
15
+ needs: prepare
16
+ name: Release
17
+ runs-on: ubuntu-latest
18
+ steps:
19
+ - name: Checkout
20
+ uses: actions/checkout@v2
21
+ with:
22
+ persist-credentials: false
23
+ - name: Setup Node.js
24
+ uses: actions/setup-node@v2
25
+ with:
26
+ node-version: 12
27
+ - name: Install dependencies
28
+ run: npm ci
29
+ - name: Release
30
+ env:
31
+ GIT_AUTHOR_EMAIL: ${{ secrets.GIT_AUTHOR_EMAIL }}
32
+ GIT_AUTHOR_NAME: ${{ secrets.GIT_AUTHOR_NAME }}
33
+ GIT_COMMITTER_EMAIL: ${{ secrets.GIT_COMMITTER_EMAIL }}
34
+ GIT_COMMITTER_NAME: ${{ secrets.GIT_COMMITTER_NAME }}
35
+ GITHUB_TOKEN: ${{ secrets.PA_TOKEN }}
36
+ NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
37
+ run: npx semantic-release
@@ -0,0 +1,43 @@
1
+ name: Tests
2
+
3
+ on:
4
+ pull_request:
5
+ branches:
6
+ - main
7
+
8
+ jobs:
9
+ tests:
10
+ runs-on: ubuntu-latest
11
+ strategy:
12
+ matrix:
13
+ node: [ '14.x', '16.x', '18.x' ]
14
+ name: Node ${{ matrix.node }}
15
+ steps:
16
+ - uses: actions/checkout@v2
17
+ - run: |
18
+ git remote set-branches --add origin main
19
+ git fetch
20
+ - name: Setup Node
21
+ uses: actions/setup-node@v2
22
+ with:
23
+ node-version: ${{ matrix.node }}
24
+ - name: Install Dependencies
25
+ run: npm ci
26
+ env:
27
+ NODE_ENV: development
28
+ - name: Unit Tests
29
+ run: npm run test
30
+ env:
31
+ NODE_ENV: production
32
+ - name: Lockfile Lint Test
33
+ run: npm run test:lockfile
34
+ env:
35
+ NODE_ENV: production
36
+ - name: Git History Test
37
+ run: npm run test:git-history
38
+ env:
39
+ NODE_ENV: production
40
+ - name: Lint
41
+ run: npm run lint
42
+ env:
43
+ NODE_ENV: production
package/CHANGELOG.md CHANGED
@@ -1,3 +1,30 @@
1
+ # [5.0.0](https://github.com/americanexpress/jest-image-snapshot/compare/v4.5.1...v5.0.0) (2022-05-30)
2
+
3
+
4
+ ### chore
5
+
6
+ * **jest:** upgrade v28 ([a902a5b](https://github.com/americanexpress/jest-image-snapshot/commit/a902a5baa87d0925b3ff241d7f592f6e1fc0c8fd)), closes [#296](https://github.com/americanexpress/jest-image-snapshot/issues/296)
7
+
8
+
9
+ ### BREAKING CHANGES
10
+
11
+ * **jest:** drop support for Node 10 due
12
+ to jest use of globalThis in Node 12
13
+
14
+ ## [4.5.1](https://github.com/americanexpress/jest-image-snapshot/compare/v4.5.0...v4.5.1) (2021-06-25)
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * **deps:** bump glob-parent from 5.1.1 to 5.1.2 ([#276](https://github.com/americanexpress/jest-image-snapshot/issues/276)) ([0c5879e](https://github.com/americanexpress/jest-image-snapshot/commit/0c5879ea2552682208e822d5d696c94121ed7125))
20
+
21
+ # [4.5.0](https://github.com/americanexpress/jest-image-snapshot/compare/v4.4.1...v4.5.0) (2021-04-29)
22
+
23
+
24
+ ### Features
25
+
26
+ * allow folders on snapshot identifier ([#267](https://github.com/americanexpress/jest-image-snapshot/issues/267)) ([ad49a97](https://github.com/americanexpress/jest-image-snapshot/commit/ad49a975a425826245a3f72e4df262db09ce25ea))
27
+
1
28
  ## [4.4.1](https://github.com/americanexpress/jest-image-snapshot/compare/v4.4.0...v4.4.1) (2021-04-01)
2
29
 
3
30
 
package/README.md CHANGED
@@ -1,9 +1,9 @@
1
1
  <h1 align="center">
2
- <img src='https://github.com/americanexpress/jest-image-snapshot/raw/master/jest-image-snapshot.png' alt="Jest Image Snapshot - One Amex" width='50%'/>
2
+ <img src='https://github.com/americanexpress/jest-image-snapshot/raw/main/jest-image-snapshot.png' alt="Jest Image Snapshot - One Amex" width='50%'/>
3
3
  </h1>
4
4
 
5
5
  [![npm](https://img.shields.io/npm/v/jest-image-snapshot)](https://www.npmjs.com/package/jest-image-snapshot)
6
- [![Travis (.org) branch](https://img.shields.io/travis/americanexpress/jest-image-snapshot/master)](https://travis-ci.org/americanexpress/jest-image-snapshot)
6
+ ![Health Check](https://github.com/americanexpress/jest-image-snapshot/workflows/Health%20Check/badge.svg)
7
7
  [![Mentioned in Awesome Jest](https://awesome.re/mentioned-badge.svg)](https://github.com/jest-community/awesome-jest)
8
8
 
9
9
  > Jest matcher that performs image comparisons using [pixelmatch](https://github.com/mapbox/pixelmatch) and behaves just like [Jest snapshots](https://facebook.github.io/jest/docs/snapshot-testing.html) do! Very useful for visual regression testing.
@@ -39,7 +39,7 @@ To update the stored image snapshot run Jest with `--updateSnapshot` or `-u` arg
39
39
 
40
40
  ### See it in action
41
41
 
42
- Typically this matcher is used to for visual tests that run on a browser. For example let's say I finish working on a feature and want to write a test to prevent visual regressions:
42
+ Typically this matcher is used for visual tests that run on a browser. For example let's say I finish working on a feature and want to write a test to prevent visual regressions:
43
43
 
44
44
  ```javascript
45
45
  ...
@@ -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 <=26` is a peerDependency. `jest-image-snapshot` will **not** work with anything below Jest 20.x.x
78
+ Please note that `Jest` `>=20 <=27` is a peerDependency. `jest-image-snapshot` will **not** work with anything below Jest 20.x.x
79
79
 
80
80
  ### Invocation
81
81
 
@@ -109,7 +109,7 @@ See [the examples](./examples/README.md) for more detailed usage or read about a
109
109
  * `comparisonMethod`: (default: `pixelmatch`) (options `pixelmatch` or `ssim`) The method by which images are compared. `pixelmatch` does a pixel by pixel comparison, whereas `ssim` does a structural similarity comparison. `ssim` is a new experimental feature for jest-image-snapshot, but may become the default comparison method in the future. For a better understanding of how to use SSIM, see [Recommendations when using SSIM Comparison](#recommendations-when-using-ssim-comparison).
110
110
  * `customSnapshotsDir`: A custom absolute path of a directory to keep this snapshot in
111
111
  * `customDiffDir`: A custom absolute path of a directory to keep this diff in
112
- * `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.
112
+ * `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.
113
113
  * `diffDirection`: (default: `horizontal`) (options `horizontal` or `vertical`) Changes diff image layout direction
114
114
  * `noColors`: Removes coloring from console output, useful if storing the results in a file
115
115
  * `failureThreshold`: (default `0`) Sets the threshold that would trigger a test failure based on the `failureThresholdType` selected. This is different to the `customDiffConfig.threshold` above, that is the per pixel failure threshold, this is the failure threshold for the entire comparison.
@@ -292,7 +292,7 @@ Please feel free to open pull requests and see [CONTRIBUTING.md](./CONTRIBUTING.
292
292
  ## 🗝️ License
293
293
 
294
294
  Any contributions made under this project will be governed by the [Apache License
295
- 2.0](https://github.com/americanexpress/jest-image-snapshot/blob/master/LICENSE.txt).
295
+ 2.0](https://github.com/americanexpress/jest-image-snapshot/blob/main/LICENSE.txt).
296
296
 
297
297
  ## 🗣️ Code of Conduct
298
298
 
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "jest-image-snapshot",
3
- "version": "4.4.1",
3
+ "version": "5.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": ">= 10.14.2"
7
+ "node": "^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0"
8
8
  },
9
9
  "scripts": {
10
10
  "lint": "eslint ./ --ignore-path .gitignore --ext .js",
11
11
  "test": "jest --ci=false",
12
12
  "test:lockfile": "lockfile-lint -p package-lock.json -t npm -a npm -o https: -c -i",
13
- "test:git-history": "commitlint --from origin/master --to HEAD",
13
+ "test:git-history": "commitlint --from origin/main --to HEAD",
14
14
  "posttest": "npm run lint && npm run test:git-history && npm run test:lockfile"
15
15
  },
16
16
  "keywords": [
@@ -53,8 +53,8 @@
53
53
  "eslint-config-amex": "^7.0.0",
54
54
  "husky": "^4.2.1",
55
55
  "image-size": "^0.8.3",
56
- "jest": "^26.0.1",
57
- "jest-snapshot": "^26.0.1",
56
+ "jest": "^28.0.3",
57
+ "jest-snapshot": "^28.0.3",
58
58
  "lockfile-lint": "^4.0.0",
59
59
  "mock-spawn": "^0.2.6",
60
60
  "semantic-release": "^17.0.4"
@@ -71,7 +71,7 @@
71
71
  "ssim.js": "^3.1.1"
72
72
  },
73
73
  "peerDependencies": {
74
- "jest": ">=20 <=26"
74
+ "jest": ">=20 <=28"
75
75
  },
76
76
  "husky": {
77
77
  "hooks": {
@@ -80,6 +80,20 @@
80
80
  }
81
81
  },
82
82
  "release": {
83
+ "branches": [
84
+ "+([0-9])?(.{+([0-9]),x}).x",
85
+ "main",
86
+ "next",
87
+ "next-major",
88
+ {
89
+ "name": "beta",
90
+ "prerelease": true
91
+ },
92
+ {
93
+ "name": "alpha",
94
+ "prerelease": true
95
+ }
96
+ ],
83
97
  "plugins": [
84
98
  "@semantic-release/commit-analyzer",
85
99
  "@semantic-release/release-notes-generator",
@@ -87,7 +101,6 @@
87
101
  "@semantic-release/npm",
88
102
  "@semantic-release/git",
89
103
  "@semantic-release/github"
90
- ],
91
- "branch": "master"
104
+ ]
92
105
  }
93
106
  }
@@ -205,7 +205,7 @@ function diffImageToSnapshot(options) {
205
205
  let result = {};
206
206
  const baselineSnapshotPath = path.join(snapshotsDir, `${snapshotIdentifier}-snap.png`);
207
207
  if (!fs.existsSync(baselineSnapshotPath)) {
208
- mkdirp.sync(snapshotsDir);
208
+ mkdirp.sync(path.dirname(baselineSnapshotPath));
209
209
  fs.writeFileSync(baselineSnapshotPath, receivedImageBuffer);
210
210
  result = { added: true };
211
211
  } else {
@@ -269,7 +269,7 @@ function diffImageToSnapshot(options) {
269
269
  });
270
270
 
271
271
  if (isFailure({ pass, updateSnapshot })) {
272
- mkdirp.sync(diffDir);
272
+ mkdirp.sync(path.dirname(diffOutputPath));
273
273
  const composer = new ImageComposer({
274
274
  direction: diffDirection,
275
275
  });
@@ -307,7 +307,7 @@ function diffImageToSnapshot(options) {
307
307
  imgSrcString: `data:image/png;base64,${pngBuffer.toString('base64')}`,
308
308
  };
309
309
  } else if (shouldUpdate({ pass, updateSnapshot, updatePassedSnapshot })) {
310
- mkdirp.sync(snapshotsDir);
310
+ mkdirp.sync(path.dirname(baselineSnapshotPath));
311
311
  fs.writeFileSync(baselineSnapshotPath, receivedImageBuffer);
312
312
  result = { updated: true };
313
313
  } else {
package/.travis.yml DELETED
@@ -1,24 +0,0 @@
1
- language: node_js
2
- node_js:
3
- - 10
4
- - 12
5
- - 14
6
- before_install:
7
- # Create a master branch for commitlint
8
- # https://github.com/conventional-changelog/commitlint/issues/6
9
- - git remote set-branches origin master && git fetch
10
- jobs:
11
- include:
12
- # Define the release stage that runs semantic-release
13
- - stage: release
14
- node_js:
15
- - 10
16
- - 12
17
- - 14
18
- deploy:
19
- on:
20
- branch: master
21
- provider: script
22
- skip_cleanup: true
23
- script:
24
- - npx semantic-release