@jsenv/snapshot 2.9.8 → 2.9.10

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/snapshot",
3
- "version": "2.9.8",
3
+ "version": "2.9.10",
4
4
  "description": "Snapshot testing",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -56,6 +56,12 @@ export const replaceFluctuatingValues = (
56
56
  );
57
57
  return string;
58
58
  };
59
+ const replaceTimestamps = (string) => {
60
+ string = string.replace(/\?hot=\d+/g, () => {
61
+ return "?hot=now()";
62
+ });
63
+ return string;
64
+ };
59
65
  const replaceSizes = (string) => {
60
66
  // the size of files might slighly differ from an OS to an other
61
67
  // we round the floats to make them predictable
@@ -81,6 +87,7 @@ export const replaceFluctuatingValues = (
81
87
  if (stringType === "filesystem") {
82
88
  return replaceFilesystemWellKnownValues(string);
83
89
  }
90
+ string = replaceTimestamps(string);
84
91
  if (!preserveAnsi) {
85
92
  string = stripAnsi(string);
86
93
  }
@@ -101,7 +101,7 @@ export const renderSideEffects = (
101
101
  }
102
102
  markdown += sideEffectMd;
103
103
  if (generatedBy) {
104
- markdown += "\n";
104
+ markdown += "\n\n";
105
105
  markdown += "---";
106
106
  markdown += "\n\n";
107
107
  markdown += renderSmallLink(
@@ -111,6 +111,7 @@ export const renderSideEffects = (
111
111
  },
112
112
  { prefix: "Generated by " },
113
113
  );
114
+ markdown += "\n";
114
115
  }
115
116
  return markdown;
116
117
  };
@@ -68,7 +68,12 @@ export const snapshotTests = async (
68
68
  const testArray = [];
69
69
  let index = 0;
70
70
  let hasOnly = false;
71
+ const scenariosSet = new Set();
71
72
  const test = (scenario, fn, options) => {
73
+ if (scenariosSet.has(scenario)) {
74
+ console.warn(`"${scenario}" overrides`);
75
+ }
76
+ scenariosSet.add(scenario);
72
77
  testArray.push({
73
78
  index,
74
79
  scenario,
@@ -79,6 +84,10 @@ export const snapshotTests = async (
79
84
  index++;
80
85
  };
81
86
  test.ONLY = (scenario, fn, options) => {
87
+ if (scenariosSet.has(scenario)) {
88
+ console.warn(`"${scenario}" overrides`);
89
+ }
90
+ scenariosSet.add(scenario);
82
91
  hasOnly = true;
83
92
  testArray.push({
84
93
  index,
@@ -110,7 +119,7 @@ export const snapshotTests = async (
110
119
  markdown += `# [${urlToFilename(sourceFileUrl)}](${sourceRelativeUrl})`;
111
120
  markdown += `\n\n`;
112
121
  let testMd = "";
113
- testMd += `\n\n`;
122
+ testMd += `\n`;
114
123
  let outDirectorySnapshot;
115
124
  if (testArray.length === 0) {
116
125
  outDirectorySnapshot = takeDirectorySnapshot(
@@ -203,6 +212,7 @@ export const snapshotTests = async (
203
212
  },
204
213
  { prefix: "Generated by " },
205
214
  );
215
+ markdown += "\n";
206
216
  }
207
217
  writeFileSync(sideEffectMdFileUrl, markdown);
208
218
  outDirectorySnapshot.compare(throwWhenDiff);