@vitest/snapshot 3.2.4 → 4.0.0-beta.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/LICENSE +1 -1
- package/dist/index.d.ts +5 -12
- package/dist/index.js +166 -220
- package/package.json +4 -4
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2021-Present Vitest
|
|
3
|
+
Copyright (c) 2021-Present VoidZero Inc. and Vitest contributors
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/dist/index.d.ts
CHANGED
|
@@ -20,11 +20,6 @@ declare class DefaultMap<
|
|
|
20
20
|
}
|
|
21
21
|
declare class CounterMap<K> extends DefaultMap<K, number> {
|
|
22
22
|
constructor();
|
|
23
|
-
// compat for jest-image-snapshot https://github.com/vitest-dev/vitest/issues/7322
|
|
24
|
-
// `valueOf` and `Snapshot.added` setter allows
|
|
25
|
-
// snapshotState.added = snapshotState.added + 1
|
|
26
|
-
// to function as
|
|
27
|
-
// snapshotState.added.total_ = snapshotState.added.total() + 1
|
|
28
23
|
_total: number | undefined;
|
|
29
24
|
valueOf(): number;
|
|
30
25
|
increment(key: K): void;
|
|
@@ -59,20 +54,18 @@ declare class SnapshotState {
|
|
|
59
54
|
private _environment;
|
|
60
55
|
private _fileExists;
|
|
61
56
|
expand: boolean;
|
|
62
|
-
// getter/setter for jest-image-snapshot compat
|
|
63
|
-
// https://github.com/vitest-dev/vitest/issues/7322
|
|
64
57
|
private _added;
|
|
65
58
|
private _matched;
|
|
66
59
|
private _unmatched;
|
|
67
60
|
private _updated;
|
|
68
61
|
get added(): CounterMap<string>;
|
|
69
|
-
set added(value:
|
|
62
|
+
set added(value: number);
|
|
70
63
|
get matched(): CounterMap<string>;
|
|
71
|
-
set matched(value:
|
|
64
|
+
set matched(value: number);
|
|
72
65
|
get unmatched(): CounterMap<string>;
|
|
73
|
-
set unmatched(value:
|
|
66
|
+
set unmatched(value: number);
|
|
74
67
|
get updated(): CounterMap<string>;
|
|
75
|
-
set updated(value:
|
|
68
|
+
set updated(value: number);
|
|
76
69
|
private constructor();
|
|
77
70
|
static create(testFilePath: string, options: SnapshotStateOptions): Promise<SnapshotState>;
|
|
78
71
|
get environment(): SnapshotEnvironment;
|
|
@@ -134,4 +127,4 @@ declare function stripSnapshotIndentation(inlineSnapshot: string): string;
|
|
|
134
127
|
declare function addSerializer(plugin: Plugin): void;
|
|
135
128
|
declare function getSerializers(): Plugins;
|
|
136
129
|
|
|
137
|
-
export { SnapshotClient, SnapshotMatchOptions, SnapshotResult, SnapshotState, SnapshotStateOptions, addSerializer, getSerializers, stripSnapshotIndentation };
|
|
130
|
+
export { SnapshotClient, SnapshotEnvironment, SnapshotMatchOptions, SnapshotResult, SnapshotState, SnapshotStateOptions, addSerializer, getSerializers, stripSnapshotIndentation };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { resolve as resolve$
|
|
1
|
+
import { resolve as resolve$1 } from 'pathe';
|
|
2
2
|
import { plugins, format } from '@vitest/pretty-format';
|
|
3
3
|
|
|
4
4
|
const comma = ','.charCodeAt(0);
|
|
@@ -283,7 +283,7 @@ function normalizePath(url, type) {
|
|
|
283
283
|
/**
|
|
284
284
|
* Attempts to resolve `input` URL/path relative to `base`.
|
|
285
285
|
*/
|
|
286
|
-
function resolve
|
|
286
|
+
function resolve(input, base) {
|
|
287
287
|
if (!input && !base)
|
|
288
288
|
return '';
|
|
289
289
|
const url = parseUrl(input);
|
|
@@ -343,245 +343,206 @@ function resolve$1(input, base) {
|
|
|
343
343
|
}
|
|
344
344
|
}
|
|
345
345
|
|
|
346
|
-
|
|
347
|
-
// The base is always treated as a directory, if it's not empty.
|
|
348
|
-
// https://github.com/mozilla/source-map/blob/8cb3ee57/lib/util.js#L327
|
|
349
|
-
// https://github.com/chromium/chromium/blob/da4adbb3/third_party/blink/renderer/devtools/front_end/sdk/SourceMap.js#L400-L401
|
|
350
|
-
if (base && !base.endsWith('/'))
|
|
351
|
-
base += '/';
|
|
352
|
-
return resolve$1(input, base);
|
|
353
|
-
}
|
|
346
|
+
// src/trace-mapping.ts
|
|
354
347
|
|
|
355
|
-
|
|
356
|
-
* Removes everything after the last "/", but leaves the slash.
|
|
357
|
-
*/
|
|
348
|
+
// src/strip-filename.ts
|
|
358
349
|
function stripFilename(path) {
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
350
|
+
if (!path) return "";
|
|
351
|
+
const index = path.lastIndexOf("/");
|
|
352
|
+
return path.slice(0, index + 1);
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
// src/resolve.ts
|
|
356
|
+
function resolver(mapUrl, sourceRoot) {
|
|
357
|
+
const from = stripFilename(mapUrl);
|
|
358
|
+
const prefix = sourceRoot ? sourceRoot + "/" : "";
|
|
359
|
+
return (source) => resolve(prefix + (source || ""), from);
|
|
363
360
|
}
|
|
364
361
|
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
362
|
+
// src/sourcemap-segment.ts
|
|
363
|
+
var COLUMN = 0;
|
|
364
|
+
var SOURCES_INDEX = 1;
|
|
365
|
+
var SOURCE_LINE = 2;
|
|
366
|
+
var SOURCE_COLUMN = 3;
|
|
367
|
+
var NAMES_INDEX = 4;
|
|
370
368
|
|
|
369
|
+
// src/sort.ts
|
|
371
370
|
function maybeSort(mappings, owned) {
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
for (let i = unsortedIndex; i < mappings.length; i = nextUnsortedSegmentLine(mappings, i + 1)) {
|
|
380
|
-
mappings[i] = sortSegments(mappings[i], owned);
|
|
381
|
-
}
|
|
382
|
-
return mappings;
|
|
371
|
+
const unsortedIndex = nextUnsortedSegmentLine(mappings, 0);
|
|
372
|
+
if (unsortedIndex === mappings.length) return mappings;
|
|
373
|
+
if (!owned) mappings = mappings.slice();
|
|
374
|
+
for (let i = unsortedIndex; i < mappings.length; i = nextUnsortedSegmentLine(mappings, i + 1)) {
|
|
375
|
+
mappings[i] = sortSegments(mappings[i], owned);
|
|
376
|
+
}
|
|
377
|
+
return mappings;
|
|
383
378
|
}
|
|
384
379
|
function nextUnsortedSegmentLine(mappings, start) {
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
return mappings.length;
|
|
380
|
+
for (let i = start; i < mappings.length; i++) {
|
|
381
|
+
if (!isSorted(mappings[i])) return i;
|
|
382
|
+
}
|
|
383
|
+
return mappings.length;
|
|
390
384
|
}
|
|
391
385
|
function isSorted(line) {
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
}
|
|
386
|
+
for (let j = 1; j < line.length; j++) {
|
|
387
|
+
if (line[j][COLUMN] < line[j - 1][COLUMN]) {
|
|
388
|
+
return false;
|
|
396
389
|
}
|
|
397
|
-
|
|
390
|
+
}
|
|
391
|
+
return true;
|
|
398
392
|
}
|
|
399
393
|
function sortSegments(line, owned) {
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
return line.sort(sortComparator);
|
|
394
|
+
if (!owned) line = line.slice();
|
|
395
|
+
return line.sort(sortComparator);
|
|
403
396
|
}
|
|
404
397
|
function sortComparator(a, b) {
|
|
405
|
-
|
|
398
|
+
return a[COLUMN] - b[COLUMN];
|
|
406
399
|
}
|
|
407
400
|
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
* A binary search implementation that returns the index if a match is found.
|
|
411
|
-
* If no match is found, then the left-index (the index associated with the item that comes just
|
|
412
|
-
* before the desired index) is returned. To maintain proper sort order, a splice would happen at
|
|
413
|
-
* the next index:
|
|
414
|
-
*
|
|
415
|
-
* ```js
|
|
416
|
-
* const array = [1, 3];
|
|
417
|
-
* const needle = 2;
|
|
418
|
-
* const index = binarySearch(array, needle, (item, needle) => item - needle);
|
|
419
|
-
*
|
|
420
|
-
* assert.equal(index, 0);
|
|
421
|
-
* array.splice(index + 1, 0, needle);
|
|
422
|
-
* assert.deepEqual(array, [1, 2, 3]);
|
|
423
|
-
* ```
|
|
424
|
-
*/
|
|
401
|
+
// src/binary-search.ts
|
|
402
|
+
var found = false;
|
|
425
403
|
function binarySearch(haystack, needle, low, high) {
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
}
|
|
433
|
-
if (cmp < 0) {
|
|
434
|
-
low = mid + 1;
|
|
435
|
-
}
|
|
436
|
-
else {
|
|
437
|
-
high = mid - 1;
|
|
438
|
-
}
|
|
404
|
+
while (low <= high) {
|
|
405
|
+
const mid = low + (high - low >> 1);
|
|
406
|
+
const cmp = haystack[mid][COLUMN] - needle;
|
|
407
|
+
if (cmp === 0) {
|
|
408
|
+
found = true;
|
|
409
|
+
return mid;
|
|
439
410
|
}
|
|
440
|
-
|
|
441
|
-
|
|
411
|
+
if (cmp < 0) {
|
|
412
|
+
low = mid + 1;
|
|
413
|
+
} else {
|
|
414
|
+
high = mid - 1;
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
found = false;
|
|
418
|
+
return low - 1;
|
|
442
419
|
}
|
|
443
420
|
function upperBound(haystack, needle, index) {
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
return index;
|
|
421
|
+
for (let i = index + 1; i < haystack.length; index = i++) {
|
|
422
|
+
if (haystack[i][COLUMN] !== needle) break;
|
|
423
|
+
}
|
|
424
|
+
return index;
|
|
449
425
|
}
|
|
450
426
|
function lowerBound(haystack, needle, index) {
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
return index;
|
|
427
|
+
for (let i = index - 1; i >= 0; index = i--) {
|
|
428
|
+
if (haystack[i][COLUMN] !== needle) break;
|
|
429
|
+
}
|
|
430
|
+
return index;
|
|
456
431
|
}
|
|
457
432
|
function memoizedState() {
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
433
|
+
return {
|
|
434
|
+
lastKey: -1,
|
|
435
|
+
lastNeedle: -1,
|
|
436
|
+
lastIndex: -1
|
|
437
|
+
};
|
|
463
438
|
}
|
|
464
|
-
/**
|
|
465
|
-
* This overly complicated beast is just to record the last tested line/column and the resulting
|
|
466
|
-
* index, allowing us to skip a few tests if mappings are monotonically increasing.
|
|
467
|
-
*/
|
|
468
439
|
function memoizedBinarySearch(haystack, needle, state, key) {
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
}
|
|
477
|
-
if (needle >= lastNeedle) {
|
|
478
|
-
// lastIndex may be -1 if the previous needle was not found.
|
|
479
|
-
low = lastIndex === -1 ? 0 : lastIndex;
|
|
480
|
-
}
|
|
481
|
-
else {
|
|
482
|
-
high = lastIndex;
|
|
483
|
-
}
|
|
440
|
+
const { lastKey, lastNeedle, lastIndex } = state;
|
|
441
|
+
let low = 0;
|
|
442
|
+
let high = haystack.length - 1;
|
|
443
|
+
if (key === lastKey) {
|
|
444
|
+
if (needle === lastNeedle) {
|
|
445
|
+
found = lastIndex !== -1 && haystack[lastIndex][COLUMN] === needle;
|
|
446
|
+
return lastIndex;
|
|
484
447
|
}
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
448
|
+
if (needle >= lastNeedle) {
|
|
449
|
+
low = lastIndex === -1 ? 0 : lastIndex;
|
|
450
|
+
} else {
|
|
451
|
+
high = lastIndex;
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
state.lastKey = key;
|
|
455
|
+
state.lastNeedle = needle;
|
|
456
|
+
return state.lastIndex = binarySearch(haystack, needle, low, high);
|
|
488
457
|
}
|
|
489
458
|
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
const GREATEST_LOWER_BOUND = 1;
|
|
494
|
-
class TraceMap {
|
|
495
|
-
constructor(map, mapUrl) {
|
|
496
|
-
const isString = typeof map === 'string';
|
|
497
|
-
if (!isString && map._decodedMemo)
|
|
498
|
-
return map;
|
|
499
|
-
const parsed = (isString ? JSON.parse(map) : map);
|
|
500
|
-
const { version, file, names, sourceRoot, sources, sourcesContent } = parsed;
|
|
501
|
-
this.version = version;
|
|
502
|
-
this.file = file;
|
|
503
|
-
this.names = names || [];
|
|
504
|
-
this.sourceRoot = sourceRoot;
|
|
505
|
-
this.sources = sources;
|
|
506
|
-
this.sourcesContent = sourcesContent;
|
|
507
|
-
this.ignoreList = parsed.ignoreList || parsed.x_google_ignoreList || undefined;
|
|
508
|
-
const from = resolve(sourceRoot || '', stripFilename(mapUrl));
|
|
509
|
-
this.resolvedSources = sources.map((s) => resolve(s || '', from));
|
|
510
|
-
const { mappings } = parsed;
|
|
511
|
-
if (typeof mappings === 'string') {
|
|
512
|
-
this._encoded = mappings;
|
|
513
|
-
this._decoded = undefined;
|
|
514
|
-
}
|
|
515
|
-
else {
|
|
516
|
-
this._encoded = undefined;
|
|
517
|
-
this._decoded = maybeSort(mappings, isString);
|
|
518
|
-
}
|
|
519
|
-
this._decodedMemo = memoizedState();
|
|
520
|
-
this._bySources = undefined;
|
|
521
|
-
this._bySourceMemos = undefined;
|
|
522
|
-
}
|
|
459
|
+
// src/types.ts
|
|
460
|
+
function parse(map) {
|
|
461
|
+
return typeof map === "string" ? JSON.parse(map) : map;
|
|
523
462
|
}
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
463
|
+
|
|
464
|
+
// src/trace-mapping.ts
|
|
465
|
+
var LINE_GTR_ZERO = "`line` must be greater than 0 (lines start at line 1)";
|
|
466
|
+
var COL_GTR_EQ_ZERO = "`column` must be greater than or equal to 0 (columns start at column 0)";
|
|
467
|
+
var LEAST_UPPER_BOUND = -1;
|
|
468
|
+
var GREATEST_LOWER_BOUND = 1;
|
|
469
|
+
var TraceMap = class {
|
|
470
|
+
constructor(map, mapUrl) {
|
|
471
|
+
const isString = typeof map === "string";
|
|
472
|
+
if (!isString && map._decodedMemo) return map;
|
|
473
|
+
const parsed = parse(map);
|
|
474
|
+
const { version, file, names, sourceRoot, sources, sourcesContent } = parsed;
|
|
475
|
+
this.version = version;
|
|
476
|
+
this.file = file;
|
|
477
|
+
this.names = names || [];
|
|
478
|
+
this.sourceRoot = sourceRoot;
|
|
479
|
+
this.sources = sources;
|
|
480
|
+
this.sourcesContent = sourcesContent;
|
|
481
|
+
this.ignoreList = parsed.ignoreList || parsed.x_google_ignoreList || void 0;
|
|
482
|
+
const resolve = resolver(mapUrl, sourceRoot);
|
|
483
|
+
this.resolvedSources = sources.map(resolve);
|
|
484
|
+
const { mappings } = parsed;
|
|
485
|
+
if (typeof mappings === "string") {
|
|
486
|
+
this._encoded = mappings;
|
|
487
|
+
this._decoded = void 0;
|
|
488
|
+
} else if (Array.isArray(mappings)) {
|
|
489
|
+
this._encoded = void 0;
|
|
490
|
+
this._decoded = maybeSort(mappings, isString);
|
|
491
|
+
} else if (parsed.sections) {
|
|
492
|
+
throw new Error(`TraceMap passed sectioned source map, please use FlattenMap export instead`);
|
|
493
|
+
} else {
|
|
494
|
+
throw new Error(`invalid source map: ${JSON.stringify(parsed)}`);
|
|
495
|
+
}
|
|
496
|
+
this._decodedMemo = memoizedState();
|
|
497
|
+
this._bySources = void 0;
|
|
498
|
+
this._bySourceMemos = void 0;
|
|
499
|
+
}
|
|
500
|
+
};
|
|
528
501
|
function cast(map) {
|
|
529
|
-
|
|
502
|
+
return map;
|
|
530
503
|
}
|
|
531
|
-
/**
|
|
532
|
-
* Returns the decoded (array of lines of segments) form of the SourceMap's mappings field.
|
|
533
|
-
*/
|
|
534
504
|
function decodedMappings(map) {
|
|
535
|
-
|
|
536
|
-
|
|
505
|
+
var _a;
|
|
506
|
+
return (_a = cast(map))._decoded || (_a._decoded = decode(cast(map)._encoded));
|
|
537
507
|
}
|
|
538
|
-
/**
|
|
539
|
-
* A higher-level API to find the source/line/column associated with a generated line/column
|
|
540
|
-
* (think, from a stack trace). Line is 1-based, but column is 0-based, due to legacy behavior in
|
|
541
|
-
* `source-map` library.
|
|
542
|
-
*/
|
|
543
508
|
function originalPositionFor(map, needle) {
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
509
|
+
let { line, column, bias } = needle;
|
|
510
|
+
line--;
|
|
511
|
+
if (line < 0) throw new Error(LINE_GTR_ZERO);
|
|
512
|
+
if (column < 0) throw new Error(COL_GTR_EQ_ZERO);
|
|
513
|
+
const decoded = decodedMappings(map);
|
|
514
|
+
if (line >= decoded.length) return OMapping(null, null, null, null);
|
|
515
|
+
const segments = decoded[line];
|
|
516
|
+
const index = traceSegmentInternal(
|
|
517
|
+
segments,
|
|
518
|
+
cast(map)._decodedMemo,
|
|
519
|
+
line,
|
|
520
|
+
column,
|
|
521
|
+
bias || GREATEST_LOWER_BOUND
|
|
522
|
+
);
|
|
523
|
+
if (index === -1) return OMapping(null, null, null, null);
|
|
524
|
+
const segment = segments[index];
|
|
525
|
+
if (segment.length === 1) return OMapping(null, null, null, null);
|
|
526
|
+
const { names, resolvedSources } = map;
|
|
527
|
+
return OMapping(
|
|
528
|
+
resolvedSources[segment[SOURCES_INDEX]],
|
|
529
|
+
segment[SOURCE_LINE] + 1,
|
|
530
|
+
segment[SOURCE_COLUMN],
|
|
531
|
+
segment.length === 5 ? names[segment[NAMES_INDEX]] : null
|
|
532
|
+
);
|
|
564
533
|
}
|
|
565
534
|
function OMapping(source, line, column, name) {
|
|
566
|
-
|
|
535
|
+
return { source, line, column, name };
|
|
567
536
|
}
|
|
568
537
|
function traceSegmentInternal(segments, memo, line, column, bias) {
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
if (index === -1 || index === segments.length)
|
|
576
|
-
return -1;
|
|
577
|
-
return index;
|
|
538
|
+
let index = memoizedBinarySearch(segments, column, memo, line);
|
|
539
|
+
if (found) {
|
|
540
|
+
index = (bias === LEAST_UPPER_BOUND ? upperBound : lowerBound)(segments, column, index);
|
|
541
|
+
} else if (bias === LEAST_UPPER_BOUND) index++;
|
|
542
|
+
if (index === -1 || index === segments.length) return -1;
|
|
543
|
+
return index;
|
|
578
544
|
}
|
|
579
545
|
|
|
580
|
-
/**
|
|
581
|
-
* Get original stacktrace without source map support the most performant way.
|
|
582
|
-
* - Create only 1 stack frame.
|
|
583
|
-
* - Rewrite prepareStackTrace to bypass "support-stack-trace" (usually takes ~250ms).
|
|
584
|
-
*/
|
|
585
546
|
function notNullish(v) {
|
|
586
547
|
return v != null;
|
|
587
548
|
}
|
|
@@ -646,6 +607,8 @@ const stackIgnorePatterns = [
|
|
|
646
607
|
"/node_modules/chai/",
|
|
647
608
|
"/node_modules/tinypool/",
|
|
648
609
|
"/node_modules/tinyspy/",
|
|
610
|
+
"/vite/dist/node/module-runner",
|
|
611
|
+
"/rolldown-vite/dist/node/module-runner",
|
|
649
612
|
"/deps/chunk-",
|
|
650
613
|
"/deps/@vitest",
|
|
651
614
|
"/deps/loupe",
|
|
@@ -742,7 +705,7 @@ function parseSingleV8Stack(raw) {
|
|
|
742
705
|
file = file.slice(7);
|
|
743
706
|
}
|
|
744
707
|
// normalize Windows path (\ -> /)
|
|
745
|
-
file = file.startsWith("node:") || file.startsWith("internal:") ? file : resolve$
|
|
708
|
+
file = file.startsWith("node:") || file.startsWith("internal:") ? file : resolve$1(file);
|
|
746
709
|
if (method) {
|
|
747
710
|
method = method.replace(/__vite_ssr_import_\d+__\./g, "");
|
|
748
711
|
}
|
|
@@ -804,7 +767,7 @@ function parseErrorStacktrace(e, options = {}) {
|
|
|
804
767
|
if (!e || isPrimitive(e)) {
|
|
805
768
|
return [];
|
|
806
769
|
}
|
|
807
|
-
if (e.stacks) {
|
|
770
|
+
if ("stacks" in e && e.stacks) {
|
|
808
771
|
return e.stacks;
|
|
809
772
|
}
|
|
810
773
|
const stackStr = e.stack || "";
|
|
@@ -827,24 +790,6 @@ function parseErrorStacktrace(e, options = {}) {
|
|
|
827
790
|
return stackFrames;
|
|
828
791
|
}
|
|
829
792
|
|
|
830
|
-
let getPromiseValue = () => 'Promise{…}';
|
|
831
|
-
try {
|
|
832
|
-
// @ts-ignore
|
|
833
|
-
const { getPromiseDetails, kPending, kRejected } = process.binding('util');
|
|
834
|
-
if (Array.isArray(getPromiseDetails(Promise.resolve()))) {
|
|
835
|
-
getPromiseValue = (value, options) => {
|
|
836
|
-
const [state, innerValue] = getPromiseDetails(value);
|
|
837
|
-
if (state === kPending) {
|
|
838
|
-
return 'Promise{<pending>}';
|
|
839
|
-
}
|
|
840
|
-
return `Promise${state === kRejected ? '!' : ''}{${options.inspect(innerValue, options)}}`;
|
|
841
|
-
};
|
|
842
|
-
}
|
|
843
|
-
}
|
|
844
|
-
catch (notNode) {
|
|
845
|
-
/* ignore */
|
|
846
|
-
}
|
|
847
|
-
|
|
848
793
|
const { AsymmetricMatcher: AsymmetricMatcher$1, DOMCollection: DOMCollection$1, DOMElement: DOMElement$1, Immutable: Immutable$1, ReactElement: ReactElement$1, ReactTestComponent: ReactTestComponent$1 } = plugins;
|
|
849
794
|
|
|
850
795
|
function getDefaultExportFromCjs (x) {
|
|
@@ -1530,6 +1475,7 @@ function replaceInlineSnap(code, s, currentIndex, newSnap) {
|
|
|
1530
1475
|
}
|
|
1531
1476
|
const INDENTATION_REGEX = /^([^\S\n]*)\S/m;
|
|
1532
1477
|
function stripSnapshotIndentation(inlineSnapshot) {
|
|
1478
|
+
var _lines$at;
|
|
1533
1479
|
// Find indentation if exists.
|
|
1534
1480
|
const match = inlineSnapshot.match(INDENTATION_REGEX);
|
|
1535
1481
|
if (!match || !match[1]) {
|
|
@@ -1542,7 +1488,7 @@ function stripSnapshotIndentation(inlineSnapshot) {
|
|
|
1542
1488
|
// Must be at least 3 lines.
|
|
1543
1489
|
return inlineSnapshot;
|
|
1544
1490
|
}
|
|
1545
|
-
if (lines[0].trim() !== "" || lines
|
|
1491
|
+
if (lines[0].trim() !== "" || ((_lines$at = lines.at(-1)) === null || _lines$at === void 0 ? void 0 : _lines$at.trim()) !== "") {
|
|
1546
1492
|
// If not blank first and last lines, abort.
|
|
1547
1493
|
return inlineSnapshot;
|
|
1548
1494
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitest/snapshot",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "4.0.0-beta.10",
|
|
5
5
|
"description": "Vitest snapshot manager",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"funding": "https://opencollective.com/vitest",
|
|
@@ -38,14 +38,14 @@
|
|
|
38
38
|
"dist"
|
|
39
39
|
],
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"magic-string": "^0.30.
|
|
41
|
+
"magic-string": "^0.30.18",
|
|
42
42
|
"pathe": "^2.0.3",
|
|
43
|
-
"@vitest/pretty-format": "
|
|
43
|
+
"@vitest/pretty-format": "4.0.0-beta.10"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@types/natural-compare": "^1.4.3",
|
|
47
47
|
"natural-compare": "^1.4.0",
|
|
48
|
-
"@vitest/utils": "
|
|
48
|
+
"@vitest/utils": "4.0.0-beta.10"
|
|
49
49
|
},
|
|
50
50
|
"scripts": {
|
|
51
51
|
"build": "rimraf dist && rollup -c",
|