@tryghost/jest-snapshot 0.4.7 → 0.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/lib/snapshot-manager.js +17 -10
- package/package.json +6 -6
package/lib/snapshot-manager.js
CHANGED
|
@@ -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
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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.
|
|
3
|
+
"version": "0.5.0",
|
|
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
|
|
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
|
},
|
|
@@ -20,15 +20,15 @@
|
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"c8": "7.12.0",
|
|
23
|
-
"mocha": "10.
|
|
23
|
+
"mocha": "10.2.0",
|
|
24
24
|
"should": "13.2.3",
|
|
25
|
-
"sinon": "15.0.
|
|
25
|
+
"sinon": "15.0.1"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@jest/expect": "^28.0.1",
|
|
29
29
|
"@jest/expect-utils": "^28.0.1",
|
|
30
|
-
"@tryghost/errors": "^1.2.
|
|
30
|
+
"@tryghost/errors": "^1.2.20",
|
|
31
31
|
"jest-snapshot": "^29.0.0"
|
|
32
32
|
},
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "7d645deb73825642289309a43333ee64b9a3a5d1"
|
|
34
34
|
}
|