@tryghost/jest-snapshot 0.3.0 → 0.3.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.
@@ -8,7 +8,6 @@ class SnapshotManageer {
8
8
  constructor() {
9
9
  this.registry = {};
10
10
  this.currentTest = {};
11
- this.defaultTestPath = 'test';
12
11
  this.defaultSnapshotPath = '__snapshots__';
13
12
  }
14
13
 
@@ -23,6 +22,14 @@ class SnapshotManageer {
23
22
  return `${snapshotNameTemplate} ${nextCounter}`;
24
23
  }
25
24
 
25
+ _resolveSnapshotFilePath(testFile) {
26
+ const parsedPath = path.parse(testFile);
27
+
28
+ parsedPath.dir = path.join(parsedPath.dir, this.defaultSnapshotPath);
29
+
30
+ return path.format(parsedPath);
31
+ }
32
+
26
33
  _getConfig() {
27
34
  if (!this.currentTest.filename || !this.currentTest.nameTemplate) {
28
35
  throw new errors.IncorrectUsageError({
@@ -38,10 +45,7 @@ class SnapshotManageer {
38
45
  const willUpdate = process.env.SNAPSHOT_UPDATE ? 'all' : 'new';
39
46
 
40
47
  // Set full path
41
- const testPath = path.resolve(this.defaultTestPath);
42
- const snapshotPath = path.join(testPath, this.defaultSnapshotPath);
43
-
44
- testFile = testFile.replace(testPath, snapshotPath);
48
+ testFile = this._resolveSnapshotFilePath(testFile);
45
49
 
46
50
  return {testFile, snapshotName, willUpdate};
47
51
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tryghost/jest-snapshot",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "repository": "https://github.com/TryGhost/framework/tree/main/packages/jest-snapshot",
5
5
  "author": "Ghost Foundation",
6
6
  "license": "MIT",
@@ -29,5 +29,5 @@
29
29
  "expect": "^27.5.0",
30
30
  "jest-snapshot": "^27.5.0"
31
31
  },
32
- "gitHead": "5304fb34a2b5dd02f96386fceed34124940ce9ec"
32
+ "gitHead": "79e0c67a94342496f84870a200eab7e4e74e4dbc"
33
33
  }