@tryghost/jest-snapshot 0.1.0 → 0.2.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/jest-snapshot.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
const expect = require('expect');
|
|
2
|
-
const
|
|
3
|
-
const
|
|
2
|
+
const SnapshotManager = require('./snapshot-manager');
|
|
3
|
+
const snapshotManager = new SnapshotManager();
|
|
4
4
|
|
|
5
5
|
function matchSnapshotAssertion(properties) {
|
|
6
6
|
this.params = {operator: 'to match a stored snapshot'};
|
|
7
7
|
|
|
8
|
-
const result =
|
|
8
|
+
const result = snapshotManager.match(this.obj, properties);
|
|
9
9
|
|
|
10
10
|
this.params.message = result.message();
|
|
11
11
|
this.assert(result.pass.should.eql(true));
|
|
@@ -13,12 +13,12 @@ function matchSnapshotAssertion(properties) {
|
|
|
13
13
|
|
|
14
14
|
const mochaHooks = {
|
|
15
15
|
beforeAll() {
|
|
16
|
-
|
|
16
|
+
snapshotManager.resetRegistry();
|
|
17
17
|
},
|
|
18
18
|
beforeEach() {
|
|
19
19
|
const {currentTest} = this;
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
snapshotManager.setCurrentTest({
|
|
22
22
|
filename: currentTest.file + '.snap',
|
|
23
23
|
nameTemplate: currentTest.fullTitle()
|
|
24
24
|
});
|
|
@@ -29,8 +29,7 @@ const {any, anything, stringMatching} = expect;
|
|
|
29
29
|
|
|
30
30
|
module.exports = {
|
|
31
31
|
mochaHooks,
|
|
32
|
-
|
|
33
|
-
matchSnapshot: snapshotMatcher.matchSnapshot,
|
|
32
|
+
snapshotManager,
|
|
34
33
|
matchSnapshotAssertion,
|
|
35
34
|
any,
|
|
36
35
|
anything,
|
|
@@ -2,7 +2,7 @@ const {SnapshotState, toMatchSnapshot} = require('jest-snapshot');
|
|
|
2
2
|
const expect = require('expect');
|
|
3
3
|
const utils = require('expect/build/utils');
|
|
4
4
|
|
|
5
|
-
class
|
|
5
|
+
class SnapshotManageer {
|
|
6
6
|
constructor() {
|
|
7
7
|
this.registry = {};
|
|
8
8
|
this.currentTest = {};
|
|
@@ -44,7 +44,7 @@ class SnapshotMatcher {
|
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
match(received, properties = {}) {
|
|
48
48
|
const {testFile, snapshotName, willUpdate} = this._getConfig();
|
|
49
49
|
|
|
50
50
|
const snapshotState = this.getSnapshotState(testFile, willUpdate);
|
|
@@ -76,4 +76,4 @@ class SnapshotMatcher {
|
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
module.exports =
|
|
79
|
+
module.exports = SnapshotManageer;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tryghost/jest-snapshot",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"repository": "https://github.com/TryGhost/framework/tree/main/packages/jest-snapshot",
|
|
5
5
|
"author": "Ghost Foundation",
|
|
6
6
|
"license": "MIT",
|
|
@@ -28,5 +28,5 @@
|
|
|
28
28
|
"expect": "^27.5.0",
|
|
29
29
|
"jest-snapshot": "^27.5.0"
|
|
30
30
|
},
|
|
31
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "1750e2bdc5b8f659a4439490c79a8c262a74e66f"
|
|
32
32
|
}
|