@tryghost/jest-snapshot 0.4.8 → 0.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.
@@ -83,18 +83,20 @@ class SnapshotManager {
83
83
  assert.notEqual(response[field], undefined, error);
84
84
  }
85
85
 
86
- const hint = `[${field}]`;
86
+ const hint = assertion.hint || `[${field}]`;
87
87
  const match = this.match(response[field], properties, hint);
88
88
 
89
- Object.keys(properties).forEach((prop) => {
90
- const errorMessage = `"response.${field}" is missing the expected property "${prop}"`;
91
- error.message = makeMessageFromMatchMessage(match.message(), errorMessage);
92
- error.expected = prop;
93
- error.actual = 'undefined';
94
- error.showDiff = false; // Disable mocha's diff output as it's already present in match.message()
89
+ if (properties) {
90
+ Object.keys(properties).forEach((prop) => {
91
+ const errorMessage = `"response.${field}" is missing the expected property "${prop}"`;
92
+ error.message = makeMessageFromMatchMessage(match.message(), errorMessage);
93
+ error.expected = prop;
94
+ error.actual = 'undefined';
95
+ error.showDiff = false; // Disable mocha's diff output as it's already present in match.message()
95
96
 
96
- assert.notEqual(response[field][prop], undefined, error);
97
- });
97
+ assert.notEqual(response[field][prop], undefined, error);
98
+ });
99
+ }
98
100
 
99
101
  if (match.pass !== true) {
100
102
  const errorMessage = `"response.${field}" does not match snapshot.`;
@@ -119,7 +121,12 @@ class SnapshotManager {
119
121
  });
120
122
 
121
123
  // Execute the matcher
122
- const result = matcher(received, properties, hint);
124
+ let result;
125
+ if (properties) {
126
+ result = matcher(received, properties, hint);
127
+ } else {
128
+ result = matcher(received, hint);
129
+ }
123
130
 
124
131
  // Store the state of snapshot, depending on updateSnapshot value
125
132
  snapshotState.save();
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@tryghost/jest-snapshot",
3
- "version": "0.4.8",
3
+ "version": "0.5.1",
4
4
  "repository": "https://github.com/TryGhost/framework/tree/main/packages/jest-snapshot",
5
5
  "author": "Ghost Foundation",
6
6
  "license": "MIT",
7
7
  "main": "index.js",
8
8
  "scripts": {
9
9
  "dev": "echo \"Implement me!\"",
10
- "test": "NODE_ENV=testing c8 --all --check-coverage --100 --reporter html --reporter text-summary --reporter cobertura mocha './test/**/*.test.js'",
10
+ "test": "NODE_ENV=testing c8 --all --check-coverage --100 --reporter text --reporter cobertura mocha './test/**/*.test.js'",
11
11
  "lint": "eslint . --ext .js --cache",
12
12
  "posttest": "yarn lint"
13
13
  },
@@ -19,7 +19,7 @@
19
19
  "access": "public"
20
20
  },
21
21
  "devDependencies": {
22
- "c8": "7.12.0",
22
+ "c8": "7.13.0",
23
23
  "mocha": "10.2.0",
24
24
  "should": "13.2.3",
25
25
  "sinon": "15.0.1"
@@ -27,8 +27,8 @@
27
27
  "dependencies": {
28
28
  "@jest/expect": "^28.0.1",
29
29
  "@jest/expect-utils": "^28.0.1",
30
- "@tryghost/errors": "^1.2.20",
30
+ "@tryghost/errors": "^1.2.21",
31
31
  "jest-snapshot": "^29.0.0"
32
32
  },
33
- "gitHead": "d846faf201de330ac94abaf4973b841284b13fa6"
33
+ "gitHead": "ca399175e6fe217dd222067bc47b09cd8c973f5b"
34
34
  }