@vitest/snapshot 4.0.17 → 4.1.0-beta.2
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/dist/index.js +8 -0
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -285,6 +285,8 @@ const stackIgnorePatterns = [
|
|
|
285
285
|
/__vitest_browser__/,
|
|
286
286
|
/\/deps\/vitest_/
|
|
287
287
|
];
|
|
288
|
+
const NOW_LENGTH = Date.now().toString().length;
|
|
289
|
+
const REGEXP_VITEST = new RegExp(`vitest=\\d{${NOW_LENGTH}}`);
|
|
288
290
|
function extractLocation(urlLike) {
|
|
289
291
|
// Fail-fast but return locations like "(native)"
|
|
290
292
|
if (!urlLike.includes(":")) {
|
|
@@ -309,6 +311,9 @@ function extractLocation(urlLike) {
|
|
|
309
311
|
const isWindows = /^\/@fs\/[a-zA-Z]:\//.test(url);
|
|
310
312
|
url = url.slice(isWindows ? 5 : 4);
|
|
311
313
|
}
|
|
314
|
+
if (url.includes("vitest=")) {
|
|
315
|
+
url = url.replace(REGEXP_VITEST, "").replace(/[?&]$/, "");
|
|
316
|
+
}
|
|
312
317
|
return [
|
|
313
318
|
url,
|
|
314
319
|
parts[2] || undefined,
|
|
@@ -546,6 +551,9 @@ async function saveInlineSnapshots(environment, snapshots) {
|
|
|
546
551
|
await Promise.all(Array.from(files).map(async (file) => {
|
|
547
552
|
const snaps = snapshots.filter((i) => i.file === file);
|
|
548
553
|
const code = await environment.readSnapshotFile(file);
|
|
554
|
+
if (code == null) {
|
|
555
|
+
throw new Error(`cannot read ${file} when saving inline snapshot`);
|
|
556
|
+
}
|
|
549
557
|
const s = new MagicString(code);
|
|
550
558
|
for (const snap of snaps) {
|
|
551
559
|
const index = positionToOffset(code, snap.line, snap.column);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitest/snapshot",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.0.
|
|
4
|
+
"version": "4.1.0-beta.2",
|
|
5
5
|
"description": "Vitest snapshot manager",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"funding": "https://opencollective.com/vitest",
|
|
@@ -40,12 +40,12 @@
|
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"magic-string": "^0.30.21",
|
|
42
42
|
"pathe": "^2.0.3",
|
|
43
|
-
"@vitest/pretty-format": "4.0.
|
|
43
|
+
"@vitest/pretty-format": "4.1.0-beta.2"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@types/natural-compare": "^1.4.3",
|
|
47
47
|
"natural-compare": "^1.4.0",
|
|
48
|
-
"@vitest/utils": "4.0.
|
|
48
|
+
"@vitest/utils": "4.1.0-beta.2"
|
|
49
49
|
},
|
|
50
50
|
"scripts": {
|
|
51
51
|
"build": "premove dist && rollup -c",
|