@jsenv/snapshot 2.7.2 → 2.7.3
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
|
@@ -45,12 +45,20 @@ export const snapshotTests = async (
|
|
|
45
45
|
sideEffectFileUrl = new URL(sideEffectFileUrl, testFileUrl);
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
const dirUrlMap = new Map();
|
|
49
|
+
const sideEffectsMap = new Map();
|
|
48
50
|
const testMap = new Map();
|
|
49
51
|
const onlyTestMap = new Map();
|
|
50
52
|
const test = (scenario, fn, options) => {
|
|
53
|
+
if (testMap.has(scenario) || onlyTestMap.has(scenario)) {
|
|
54
|
+
console.warn(`test override "${scenario}"`);
|
|
55
|
+
}
|
|
51
56
|
testMap.set(scenario, { fn, options, callSite: getCallerLocation(2) });
|
|
52
57
|
};
|
|
53
58
|
test.ONLY = (scenario, fn, options) => {
|
|
59
|
+
if (testMap.has(scenario) || onlyTestMap.has(scenario)) {
|
|
60
|
+
console.warn(`test override "${scenario}"`);
|
|
61
|
+
}
|
|
54
62
|
onlyTestMap.set(scenario, { fn, options, callSite: getCallerLocation(2) });
|
|
55
63
|
};
|
|
56
64
|
fnRegisteringTest({ test });
|
|
@@ -89,6 +97,7 @@ export const snapshotTests = async (
|
|
|
89
97
|
callSite: linkToEachSource ? callSite : undefined,
|
|
90
98
|
baseDirectory: String(new URL("./", callSite.url)),
|
|
91
99
|
});
|
|
100
|
+
sideEffectsMap.set(scenario, sideEffects);
|
|
92
101
|
const testScenario = asValidFilename(scenario);
|
|
93
102
|
let outDirectoryRelativeUrl = outDirectoryPattern
|
|
94
103
|
.replaceAll("[test_name]", testName)
|
|
@@ -109,6 +118,8 @@ export const snapshotTests = async (
|
|
|
109
118
|
const outFileUrl = new URL(outFileRelativeUrl, testFileUrl).href;
|
|
110
119
|
return outFileUrl;
|
|
111
120
|
};
|
|
121
|
+
const outFileDirectoryUrl = generateOutFileUrl("");
|
|
122
|
+
dirUrlMap.set(scenario, outFileDirectoryUrl);
|
|
112
123
|
const sideEffectsMarkdown = renderSideEffects(sideEffects, {
|
|
113
124
|
sideEffectFileUrl,
|
|
114
125
|
outDirectoryUrl,
|
|
@@ -125,6 +136,8 @@ export const snapshotTests = async (
|
|
|
125
136
|
mockFluctuatingValues: false,
|
|
126
137
|
throwWhenDiff,
|
|
127
138
|
});
|
|
139
|
+
|
|
140
|
+
return { dirUrlMap, sideEffectsMap };
|
|
128
141
|
};
|
|
129
142
|
|
|
130
143
|
const generateExecutingLink = (sourceFileUrl, sideEffectFileUrl) => {
|