@vitest/snapshot 0.32.1 → 0.32.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/dist/index.js +35 -9
- package/dist/manager.js +2 -2
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { join, dirname } from 'pathe';
|
|
2
2
|
import { plugins, format } from 'pretty-format';
|
|
3
|
-
import 'util';
|
|
4
3
|
|
|
5
|
-
|
|
4
|
+
function getDefaultExportFromCjs (x) {
|
|
5
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
var naturalCompare$2 = {exports: {}};
|
|
6
9
|
|
|
7
10
|
/*
|
|
8
11
|
* @version 1.4.0
|
|
@@ -54,11 +57,14 @@ var naturalCompare = function(a, b) {
|
|
|
54
57
|
};
|
|
55
58
|
|
|
56
59
|
try {
|
|
57
|
-
naturalCompare$
|
|
60
|
+
naturalCompare$2.exports = naturalCompare;
|
|
58
61
|
} catch (e) {
|
|
59
62
|
String.naturalCompare = naturalCompare;
|
|
60
63
|
}
|
|
61
64
|
|
|
65
|
+
var naturalCompareExports = naturalCompare$2.exports;
|
|
66
|
+
var naturalCompare$1 = /*@__PURE__*/getDefaultExportFromCjs(naturalCompareExports);
|
|
67
|
+
|
|
62
68
|
function notNullish(v) {
|
|
63
69
|
return v != null;
|
|
64
70
|
}
|
|
@@ -118,6 +124,7 @@ try {
|
|
|
118
124
|
* Copyright(c) 2013 Jake Luer <jake@alogicalparadox.com>
|
|
119
125
|
* MIT Licensed
|
|
120
126
|
*/
|
|
127
|
+
|
|
121
128
|
let nodeInspect = false;
|
|
122
129
|
try {
|
|
123
130
|
// eslint-disable-next-line global-require
|
|
@@ -264,8 +271,8 @@ function parseSingleStack(raw) {
|
|
|
264
271
|
return {
|
|
265
272
|
method,
|
|
266
273
|
file,
|
|
267
|
-
line: parseInt(lineNumber),
|
|
268
|
-
column: parseInt(columnNumber)
|
|
274
|
+
line: Number.parseInt(lineNumber),
|
|
275
|
+
column: Number.parseInt(columnNumber)
|
|
269
276
|
};
|
|
270
277
|
}
|
|
271
278
|
function parseStacktrace(stack, ignore = stackIgnorePatterns) {
|
|
@@ -293,8 +300,8 @@ function positionToOffset(source, lineNumber, columnNumber) {
|
|
|
293
300
|
let start = 0;
|
|
294
301
|
if (lineNumber > lines.length)
|
|
295
302
|
return source.length;
|
|
296
|
-
for (let
|
|
297
|
-
start += lines[
|
|
303
|
+
for (let i2 = 0; i2 < lineNumber - 1; i2++)
|
|
304
|
+
start += lines[i2].length + nl;
|
|
298
305
|
return start + columnNumber;
|
|
299
306
|
}
|
|
300
307
|
function offsetToLineNumber(source, offset) {
|
|
@@ -416,7 +423,7 @@ function normalizeNewlines(string) {
|
|
|
416
423
|
return string.replace(/\r\n|\r/g, "\n");
|
|
417
424
|
}
|
|
418
425
|
async function saveSnapshotFile(environment, snapshotData, snapshotPath) {
|
|
419
|
-
const snapshots = Object.keys(snapshotData).sort(naturalCompare$1
|
|
426
|
+
const snapshots = Object.keys(snapshotData).sort(naturalCompare$1).map(
|
|
420
427
|
(key) => `exports[${printBacktickString(key)}] = ${printBacktickString(normalizeNewlines(snapshotData[key]))};`
|
|
421
428
|
);
|
|
422
429
|
const content = `${environment.getHeader()}
|
|
@@ -612,6 +619,22 @@ class SnapshotState {
|
|
|
612
619
|
};
|
|
613
620
|
this._environment = options.snapshotEnvironment;
|
|
614
621
|
}
|
|
622
|
+
_counters;
|
|
623
|
+
_dirty;
|
|
624
|
+
_updateSnapshot;
|
|
625
|
+
_snapshotData;
|
|
626
|
+
_initialData;
|
|
627
|
+
_inlineSnapshots;
|
|
628
|
+
_rawSnapshots;
|
|
629
|
+
_uncheckedKeys;
|
|
630
|
+
_snapshotFormat;
|
|
631
|
+
_environment;
|
|
632
|
+
_fileExists;
|
|
633
|
+
added;
|
|
634
|
+
expand;
|
|
635
|
+
matched;
|
|
636
|
+
unmatched;
|
|
637
|
+
updated;
|
|
615
638
|
static async create(testFilePath, options) {
|
|
616
639
|
const snapshotPath = await options.snapshotEnvironment.resolvePath(testFilePath);
|
|
617
640
|
const content = await options.snapshotEnvironment.readSnapshotFile(snapshotPath);
|
|
@@ -828,8 +851,11 @@ function createMismatchError(message, actual, expected) {
|
|
|
828
851
|
class SnapshotClient {
|
|
829
852
|
constructor(Service = SnapshotState) {
|
|
830
853
|
this.Service = Service;
|
|
831
|
-
this.snapshotStateMap = /* @__PURE__ */ new Map();
|
|
832
854
|
}
|
|
855
|
+
filepath;
|
|
856
|
+
name;
|
|
857
|
+
snapshotState;
|
|
858
|
+
snapshotStateMap = /* @__PURE__ */ new Map();
|
|
833
859
|
async setTest(filepath, name, options) {
|
|
834
860
|
var _a;
|
|
835
861
|
this.filepath = filepath;
|
package/dist/manager.js
CHANGED
|
@@ -3,10 +3,10 @@ import { join, dirname, basename, isAbsolute, resolve } from 'pathe';
|
|
|
3
3
|
class SnapshotManager {
|
|
4
4
|
constructor(options) {
|
|
5
5
|
this.options = options;
|
|
6
|
-
this.summary = void 0;
|
|
7
|
-
this.extension = ".snap";
|
|
8
6
|
this.clear();
|
|
9
7
|
}
|
|
8
|
+
summary = void 0;
|
|
9
|
+
extension = ".snap";
|
|
10
10
|
clear() {
|
|
11
11
|
this.summary = emptySummary(this.options);
|
|
12
12
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitest/snapshot",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.32.
|
|
4
|
+
"version": "0.32.3",
|
|
5
5
|
"description": "Vitest snapshot manager",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"funding": "https://opencollective.com/vitest",
|
|
@@ -39,13 +39,13 @@
|
|
|
39
39
|
],
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"magic-string": "^0.30.0",
|
|
42
|
-
"pathe": "^1.1.
|
|
43
|
-
"pretty-format": "^
|
|
42
|
+
"pathe": "^1.1.1",
|
|
43
|
+
"pretty-format": "^29.5.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@types/natural-compare": "^1.4.1",
|
|
47
47
|
"natural-compare": "^1.4.0",
|
|
48
|
-
"@vitest/utils": "0.32.
|
|
48
|
+
"@vitest/utils": "0.32.3"
|
|
49
49
|
},
|
|
50
50
|
"scripts": {
|
|
51
51
|
"build": "rimraf dist && rollup -c",
|