@voidzero-dev/vite-plus-test 0.1.9 → 0.1.11
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.md +181 -1
- package/dist/@vitest/browser/client/.vite/manifest.json +6 -6
- package/dist/@vitest/browser/client/__vitest__/assets/index-Da0hb3oU.css +1 -0
- package/dist/@vitest/browser/client/__vitest__/assets/index-Di71CKDo.js +63 -0
- package/dist/@vitest/browser/client/__vitest__/favicon.ico +0 -0
- package/dist/@vitest/browser/client/__vitest__/favicon.svg +49 -4
- package/dist/@vitest/browser/client/__vitest__/index.html +2 -2
- package/dist/@vitest/browser/client/__vitest_browser__/{orchestrator-S_3e_uzt.js → orchestrator-CXs6qrFe.js} +70 -28
- package/dist/@vitest/browser/client/__vitest_browser__/{tester-k74mgIRa.js → tester-K5NNxh1O.js} +168 -59
- package/dist/@vitest/browser/client/__vitest_browser__/{utils-uxqdqUz8.js → utils-C2ISqq1C.js} +2 -2
- package/dist/@vitest/browser/client/favicon.svg +49 -4
- package/dist/@vitest/browser/client/orchestrator.html +2 -2
- package/dist/@vitest/browser/client/tester/tester.html +2 -2
- package/dist/@vitest/browser/client.js +20 -13
- package/dist/@vitest/browser/context.d.ts +160 -10
- package/dist/@vitest/browser/context.js +108 -22
- package/dist/@vitest/browser/expect-element.js +23 -28
- package/dist/@vitest/browser/index-5Pe7X7sp.js +7 -0
- package/dist/@vitest/browser/index.d.ts +20 -2
- package/dist/@vitest/browser/index.js +5706 -159
- package/dist/@vitest/browser/locators.d.ts +14 -3
- package/dist/@vitest/browser/locators.js +1 -1
- package/dist/@vitest/browser-playwright/index.d.ts +23 -6
- package/dist/@vitest/browser-playwright/index.js +169 -61
- package/dist/@vitest/browser-playwright/locators.js +1 -1
- package/dist/@vitest/browser-preview/index.d.ts +14 -1
- package/dist/@vitest/browser-preview/locators.js +32 -20
- package/dist/@vitest/browser-webdriverio/index.d.ts +17 -3
- package/dist/@vitest/browser-webdriverio/index.js +22 -2
- package/dist/@vitest/browser-webdriverio/locators.js +85 -9
- package/dist/@vitest/expect/index.d.ts +172 -54
- package/dist/@vitest/expect/index.js +124 -67
- package/dist/@vitest/mocker/auto-register.js +1 -0
- package/dist/@vitest/mocker/automock.d.ts +1 -0
- package/dist/@vitest/mocker/automock.js +5 -0
- package/dist/@vitest/mocker/browser.d.ts +4 -4
- package/dist/@vitest/mocker/browser.js +1 -0
- package/dist/@vitest/mocker/chunk-automock.js +182 -14
- package/dist/@vitest/mocker/chunk-helpers.js +44 -0
- package/dist/@vitest/mocker/chunk-hoistMocks.js +659 -0
- package/dist/@vitest/mocker/chunk-mocker.js +41 -30
- package/dist/@vitest/mocker/chunk-registry.js +21 -7
- package/dist/@vitest/mocker/chunk-utils.js +18 -7
- package/dist/@vitest/mocker/hoistMocks.d-w2ILr1dG.d.ts +739 -0
- package/dist/@vitest/mocker/{index.d-C-sLYZi-.d.ts → index.d-B41z0AuW.d.ts} +1 -1
- package/dist/@vitest/mocker/index.d.ts +2 -2
- package/dist/@vitest/mocker/index.js +18 -3
- package/dist/@vitest/mocker/{mocker.d-TnKRhz7N.d.ts → mocker.d-QEntlm6J.d.ts} +10 -5
- package/dist/@vitest/mocker/node.d.ts +5 -734
- package/dist/@vitest/mocker/node.js +29 -587
- package/dist/@vitest/mocker/redirect.js +4 -4
- package/dist/@vitest/mocker/register.d.ts +3 -3
- package/dist/@vitest/mocker/register.js +1 -0
- package/dist/@vitest/mocker/transforms.d.ts +6 -0
- package/dist/@vitest/mocker/transforms.js +8 -0
- package/dist/@vitest/mocker/{types.d-B8CCKmHt.d.ts → types.d-BjI5eAwu.d.ts} +23 -7
- package/dist/@vitest/pretty-format/index.d.ts +11 -1
- package/dist/@vitest/pretty-format/index.js +33 -4
- package/dist/@vitest/runner/chunk-tasks.js +305 -37
- package/dist/@vitest/runner/index.d.ts +5 -6
- package/dist/@vitest/runner/index.js +1146 -455
- package/dist/@vitest/runner/{tasks.d-C7UxawJ9.d.ts → tasks.d-D2GKpdwQ.d.ts} +726 -55
- package/dist/@vitest/runner/types.d.ts +2 -182
- package/dist/@vitest/runner/utils.d.ts +16 -8
- package/dist/@vitest/runner/utils.js +1 -1
- package/dist/@vitest/snapshot/{environment.d-DHdQ1Csl.d.ts → environment.d-DOJxxZV9.d.ts} +2 -7
- package/dist/@vitest/snapshot/environment.d.ts +2 -1
- package/dist/@vitest/snapshot/environment.js +1 -1
- package/dist/@vitest/snapshot/index.d.ts +4 -3
- package/dist/@vitest/snapshot/index.js +21 -550
- package/dist/@vitest/snapshot/manager.d.ts +3 -2
- package/dist/@vitest/snapshot/manager.js +1 -1
- package/dist/@vitest/snapshot/{rawSnapshot.d-lFsMJFUd.d.ts → rawSnapshot.d-U2kJUxDr.d.ts} +1 -1
- package/dist/@vitest/spy/index.d.ts +34 -4
- package/dist/@vitest/spy/index.js +69 -19
- package/dist/@vitest/utils/diff.js +11 -9
- package/dist/@vitest/utils/display.d.ts +2 -1
- package/dist/@vitest/utils/display.js +38 -5
- package/dist/@vitest/utils/error.d.ts +2 -1
- package/dist/@vitest/utils/error.js +1 -2
- package/dist/@vitest/utils/helpers.d.ts +4 -1
- package/dist/@vitest/utils/helpers.js +43 -1
- package/dist/@vitest/utils/resolver.js +1 -2
- package/dist/@vitest/utils/serialize.js +6 -6
- package/dist/@vitest/utils/source-map/node.d.ts +6 -0
- package/dist/@vitest/utils/source-map/node.js +23 -0
- package/dist/@vitest/utils/source-map.js +15 -5
- package/dist/browser.d.ts +3 -2
- package/dist/browser.js +2 -2
- package/dist/chunks/acorn.B2iPLyUM.js +5958 -0
- package/dist/chunks/{base.CJ0Y4ePK.js → base.DM0-RqVb.js} +54 -16
- package/dist/chunks/{benchmark.B3N2zMcH.js → benchmark.D0SlKNbZ.js} +1 -1
- package/dist/chunks/{browser.d.ChKACdzH.d.ts → browser.d.X3SXoOCV.d.ts} +4 -1
- package/dist/chunks/{cac.DVeoLl0M.js → cac.CWGDZnXT.js} +979 -20
- package/dist/chunks/{cli-api.B7PN_QUv.js → cli-api.DuT9iuvY.js} +8764 -7898
- package/dist/chunks/{config.d.Cy95HiCx.d.ts → config.d.EJLVE3es.d.ts} +30 -15
- package/dist/chunks/{console.Cf-YriPC.js → console.3WNpx0tS.js} +3 -2
- package/dist/chunks/{constants.D_Q9UYh-.js → constants.CPYnjOGj.js} +4 -2
- package/dist/chunks/coverage.Bri33R1t.js +1050 -0
- package/dist/chunks/{creator.DAmOKTvJ.js → creator.DgVhQm5q.js} +35 -4
- package/dist/chunks/{defaults.BOqNVLsY.js → defaults.CdU2lD-q.js} +4 -3
- package/dist/chunks/{global.d.B15mdLcR.d.ts → global.d.x-ILCfAE.d.ts} +1 -2
- package/dist/chunks/{globals.DOayXfHP.js → globals.BXNGLnTL.js} +11 -10
- package/dist/chunks/{coverage.AVPTjMgw.js → index.BCY_7LL2.js} +5 -959
- package/dist/chunks/{index.C5r1PdPD.js → index.CEzQDJGb.js} +1 -1
- package/dist/chunks/{index.D3XRDfWc.js → index.CMESou6r.js} +26 -1
- package/dist/chunks/{index.6Qv1eEA6.js → index.DGNSnENe.js} +95 -9
- package/dist/chunks/{index.M8mOzt4Y.js → index.DXMFO5MJ.js} +3279 -2914
- package/dist/chunks/{index.Z5E_ObnR.js → index.DlDSLQD3.js} +7 -3
- package/dist/chunks/{index.CyBMJtT7.js → index.EY6TCHpo.js} +10 -8
- package/dist/chunks/{index.D4KonVSU.js → index.og1WyBLx.js} +18 -3
- package/dist/chunks/{init-forks._y3TW739.js → init-forks.DeArv0jT.js} +1 -1
- package/dist/chunks/{init-threads.DBO2kn-p.js → init-threads.-2OUl4Nn.js} +1 -1
- package/dist/chunks/{init.B6MLFIaN.js → init.DICorXCo.js} +52 -13
- package/dist/chunks/native.DPzPHdi5.js +148 -0
- package/dist/chunks/nativeModuleMocker.DndvSdL6.js +206 -0
- package/dist/chunks/nativeModuleRunner.BIakptoF.js +36 -0
- package/dist/chunks/{node.Ce0vMQM7.js → node.COQbm6gK.js} +1 -1
- package/dist/chunks/{plugin.d.CtqpEehP.d.ts → plugin.d.BuW-flqo.d.ts} +1 -1
- package/dist/chunks/{reporters.d.CWXNI2jG.d.ts → reporters.d.DVUYHHhe.d.ts} +328 -79
- package/dist/chunks/rpc.MzXet3jl.js +144 -0
- package/dist/chunks/{rpc.d.RH3apGEf.d.ts → rpc.d.BFMWpdph.d.ts} +10 -2
- package/dist/chunks/{setup-common.Cm-kSBVi.js → setup-common.B41N_kPE.js} +3 -3
- package/dist/chunks/{startModuleRunner.DEj0jb3e.js → startVitestModuleRunner.C3ZR-4J3.js} +265 -405
- package/dist/chunks/{suite.d.BJWk38HB.d.ts → suite.d.udJtyAgw.d.ts} +1 -1
- package/dist/chunks/{vi.2VT5v0um.js → test.CTcmp4Su.js} +538 -181
- package/dist/chunks/{utils.DvEY5TfP.js → utils.BX5Fg8C4.js} +8 -1
- package/dist/chunks/{vm.D3epNOPZ.js → vm.Dh2rTtmP.js} +48 -8
- package/dist/chunks/{worker.d.Dyxm8DEL.d.ts → worker.d.B84sVRy0.d.ts} +2 -2
- package/dist/cli.js +6 -5
- package/dist/client/.vite/manifest.json +6 -6
- package/dist/client/__vitest__/assets/index-Da0hb3oU.css +1 -0
- package/dist/client/__vitest__/assets/index-Di71CKDo.js +63 -0
- package/dist/client/__vitest__/favicon.ico +0 -0
- package/dist/client/__vitest__/favicon.svg +49 -4
- package/dist/client/__vitest__/index.html +2 -2
- package/dist/client/__vitest_browser__/{orchestrator-S_3e_uzt.js → orchestrator-CXs6qrFe.js} +70 -28
- package/dist/client/__vitest_browser__/{tester-k74mgIRa.js → tester-K5NNxh1O.js} +167 -58
- package/dist/client/__vitest_browser__/{utils-uxqdqUz8.js → utils-C2ISqq1C.js} +2 -2
- package/dist/client/favicon.svg +49 -4
- package/dist/client/orchestrator.html +2 -2
- package/dist/client/tester/tester.html +2 -2
- package/dist/client.js +20 -13
- package/dist/config.cjs +3 -2
- package/dist/config.d.ts +13 -12
- package/dist/config.js +2 -2
- package/dist/context.js +108 -22
- package/dist/coverage.d.ts +12 -8
- package/dist/coverage.js +8 -5
- package/dist/environments.js +3 -1
- package/dist/expect-element.js +23 -23
- package/dist/index-5Pe7X7sp.js +7 -0
- package/dist/index.d.ts +66 -27
- package/dist/index.js +10 -9
- package/dist/locators.d.ts +14 -3
- package/dist/locators.js +1 -1
- package/dist/module-evaluator.d.ts +11 -1
- package/dist/module-evaluator.js +43 -26
- package/dist/node.d.ts +28 -14
- package/dist/node.js +42 -40
- package/dist/nodejs-worker-loader.js +41 -0
- package/dist/plugins/mocker-transforms.mjs +2 -0
- package/dist/plugins/utils-source-map-node.mjs +2 -0
- package/dist/reporters.d.ts +8 -8
- package/dist/reporters.js +7 -5
- package/dist/runners.d.ts +24 -5
- package/dist/runners.js +6 -6
- package/dist/runtime.d.ts +6 -0
- package/dist/runtime.js +35 -0
- package/dist/snapshot.js +4 -2
- package/dist/suite.d.ts +1 -1
- package/dist/suite.js +4 -2
- package/dist/vendor/blazediff_core.d.mts +1 -0
- package/dist/vendor/blazediff_core.mjs +117 -0
- package/dist/vendor/chai.mjs +4 -249
- package/dist/vendor/convert-source-map.d.mts +1 -0
- package/dist/vendor/convert-source-map.mjs +150 -0
- package/dist/vendor/expect-type.d.mts +14 -7
- package/dist/vendor/expect-type.mjs +5 -5
- package/dist/vendor/std-env.d.mts +131 -40
- package/dist/vendor/std-env.mjs +114 -117
- package/dist/worker.d.ts +6 -6
- package/dist/worker.js +27 -21
- package/dist/workers/forks.js +23 -17
- package/dist/workers/runVmTests.js +18 -16
- package/dist/workers/threads.js +23 -17
- package/dist/workers/vmForks.js +15 -12
- package/dist/workers/vmThreads.js +15 -12
- package/globals.d.ts +2 -0
- package/package.json +35 -26
- package/suppress-warnings.cjs +1 -0
- package/dist/@vitest/browser/client/__vitest__/assets/index-BUCFJtth.js +0 -57
- package/dist/@vitest/browser/client/__vitest__/assets/index-DlhE0rqZ.css +0 -1
- package/dist/@vitest/browser/index-D6m36C6U.js +0 -11
- package/dist/@vitest/utils/chunk-_commonjsHelpers.js +0 -5
- package/dist/@vitest/utils/highlight.d.ts +0 -9
- package/dist/@vitest/utils/highlight.js +0 -538
- package/dist/chunks/date.Bq6ZW5rf.js +0 -73
- package/dist/chunks/rpc.BoxB0q7B.js +0 -76
- package/dist/chunks/test.B8ej_ZHS.js +0 -254
- package/dist/client/__vitest__/assets/index-BUCFJtth.js +0 -57
- package/dist/client/__vitest__/assets/index-DlhE0rqZ.css +0 -1
- package/dist/index-D6m36C6U.js +0 -6
- package/dist/mocker.d.ts +0 -1
- package/dist/mocker.js +0 -1
- package/dist/module-runner.js +0 -17
|
@@ -1,551 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { parseErrorStacktrace } from '../utils/source-map.js';
|
|
2
|
+
import { getCallLastIndex, isObject } from '../utils/helpers.js';
|
|
3
|
+
import { positionToOffset, offsetToLineNumber, lineSplitRE } from '../utils/offset.js';
|
|
2
4
|
import { plugins, format } from '../pretty-format/index.js';
|
|
3
5
|
|
|
4
|
-
// src/vlq.ts
|
|
5
|
-
var comma = ",".charCodeAt(0);
|
|
6
|
-
var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
7
|
-
var intToChar = new Uint8Array(64);
|
|
8
|
-
var charToInt = new Uint8Array(128);
|
|
9
|
-
for (let i = 0; i < chars.length; i++) {
|
|
10
|
-
const c = chars.charCodeAt(i);
|
|
11
|
-
intToChar[i] = c;
|
|
12
|
-
charToInt[c] = i;
|
|
13
|
-
}
|
|
14
|
-
function decodeInteger(reader, relative) {
|
|
15
|
-
let value = 0;
|
|
16
|
-
let shift = 0;
|
|
17
|
-
let integer = 0;
|
|
18
|
-
do {
|
|
19
|
-
const c = reader.next();
|
|
20
|
-
integer = charToInt[c];
|
|
21
|
-
value |= (integer & 31) << shift;
|
|
22
|
-
shift += 5;
|
|
23
|
-
} while (integer & 32);
|
|
24
|
-
const shouldNegate = value & 1;
|
|
25
|
-
value >>>= 1;
|
|
26
|
-
if (shouldNegate) {
|
|
27
|
-
value = -2147483648 | -value;
|
|
28
|
-
}
|
|
29
|
-
return relative + value;
|
|
30
|
-
}
|
|
31
|
-
function hasMoreVlq(reader, max) {
|
|
32
|
-
if (reader.pos >= max) return false;
|
|
33
|
-
return reader.peek() !== comma;
|
|
34
|
-
}
|
|
35
|
-
var StringReader = class {
|
|
36
|
-
constructor(buffer) {
|
|
37
|
-
this.pos = 0;
|
|
38
|
-
this.buffer = buffer;
|
|
39
|
-
}
|
|
40
|
-
next() {
|
|
41
|
-
return this.buffer.charCodeAt(this.pos++);
|
|
42
|
-
}
|
|
43
|
-
peek() {
|
|
44
|
-
return this.buffer.charCodeAt(this.pos);
|
|
45
|
-
}
|
|
46
|
-
indexOf(char) {
|
|
47
|
-
const { buffer, pos } = this;
|
|
48
|
-
const idx = buffer.indexOf(char, pos);
|
|
49
|
-
return idx === -1 ? buffer.length : idx;
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
// src/sourcemap-codec.ts
|
|
54
|
-
function decode(mappings) {
|
|
55
|
-
const { length } = mappings;
|
|
56
|
-
const reader = new StringReader(mappings);
|
|
57
|
-
const decoded = [];
|
|
58
|
-
let genColumn = 0;
|
|
59
|
-
let sourcesIndex = 0;
|
|
60
|
-
let sourceLine = 0;
|
|
61
|
-
let sourceColumn = 0;
|
|
62
|
-
let namesIndex = 0;
|
|
63
|
-
do {
|
|
64
|
-
const semi = reader.indexOf(";");
|
|
65
|
-
const line = [];
|
|
66
|
-
let sorted = true;
|
|
67
|
-
let lastCol = 0;
|
|
68
|
-
genColumn = 0;
|
|
69
|
-
while (reader.pos < semi) {
|
|
70
|
-
let seg;
|
|
71
|
-
genColumn = decodeInteger(reader, genColumn);
|
|
72
|
-
if (genColumn < lastCol) sorted = false;
|
|
73
|
-
lastCol = genColumn;
|
|
74
|
-
if (hasMoreVlq(reader, semi)) {
|
|
75
|
-
sourcesIndex = decodeInteger(reader, sourcesIndex);
|
|
76
|
-
sourceLine = decodeInteger(reader, sourceLine);
|
|
77
|
-
sourceColumn = decodeInteger(reader, sourceColumn);
|
|
78
|
-
if (hasMoreVlq(reader, semi)) {
|
|
79
|
-
namesIndex = decodeInteger(reader, namesIndex);
|
|
80
|
-
seg = [genColumn, sourcesIndex, sourceLine, sourceColumn, namesIndex];
|
|
81
|
-
} else {
|
|
82
|
-
seg = [genColumn, sourcesIndex, sourceLine, sourceColumn];
|
|
83
|
-
}
|
|
84
|
-
} else {
|
|
85
|
-
seg = [genColumn];
|
|
86
|
-
}
|
|
87
|
-
line.push(seg);
|
|
88
|
-
reader.pos++;
|
|
89
|
-
}
|
|
90
|
-
if (!sorted) sort(line);
|
|
91
|
-
decoded.push(line);
|
|
92
|
-
reader.pos = semi + 1;
|
|
93
|
-
} while (reader.pos <= length);
|
|
94
|
-
return decoded;
|
|
95
|
-
}
|
|
96
|
-
function sort(line) {
|
|
97
|
-
line.sort(sortComparator);
|
|
98
|
-
}
|
|
99
|
-
function sortComparator(a, b) {
|
|
100
|
-
return a[0] - b[0];
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// src/trace-mapping.ts
|
|
104
|
-
|
|
105
|
-
// src/sourcemap-segment.ts
|
|
106
|
-
var COLUMN = 0;
|
|
107
|
-
var SOURCES_INDEX = 1;
|
|
108
|
-
var SOURCE_LINE = 2;
|
|
109
|
-
var SOURCE_COLUMN = 3;
|
|
110
|
-
var NAMES_INDEX = 4;
|
|
111
|
-
|
|
112
|
-
// src/binary-search.ts
|
|
113
|
-
var found = false;
|
|
114
|
-
function binarySearch(haystack, needle, low, high) {
|
|
115
|
-
while (low <= high) {
|
|
116
|
-
const mid = low + (high - low >> 1);
|
|
117
|
-
const cmp = haystack[mid][COLUMN] - needle;
|
|
118
|
-
if (cmp === 0) {
|
|
119
|
-
found = true;
|
|
120
|
-
return mid;
|
|
121
|
-
}
|
|
122
|
-
if (cmp < 0) {
|
|
123
|
-
low = mid + 1;
|
|
124
|
-
} else {
|
|
125
|
-
high = mid - 1;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
found = false;
|
|
129
|
-
return low - 1;
|
|
130
|
-
}
|
|
131
|
-
function upperBound(haystack, needle, index) {
|
|
132
|
-
for (let i = index + 1; i < haystack.length; index = i++) {
|
|
133
|
-
if (haystack[i][COLUMN] !== needle) break;
|
|
134
|
-
}
|
|
135
|
-
return index;
|
|
136
|
-
}
|
|
137
|
-
function lowerBound(haystack, needle, index) {
|
|
138
|
-
for (let i = index - 1; i >= 0; index = i--) {
|
|
139
|
-
if (haystack[i][COLUMN] !== needle) break;
|
|
140
|
-
}
|
|
141
|
-
return index;
|
|
142
|
-
}
|
|
143
|
-
function memoizedBinarySearch(haystack, needle, state, key) {
|
|
144
|
-
const { lastKey, lastNeedle, lastIndex } = state;
|
|
145
|
-
let low = 0;
|
|
146
|
-
let high = haystack.length - 1;
|
|
147
|
-
if (key === lastKey) {
|
|
148
|
-
if (needle === lastNeedle) {
|
|
149
|
-
found = lastIndex !== -1 && haystack[lastIndex][COLUMN] === needle;
|
|
150
|
-
return lastIndex;
|
|
151
|
-
}
|
|
152
|
-
if (needle >= lastNeedle) {
|
|
153
|
-
low = lastIndex === -1 ? 0 : lastIndex;
|
|
154
|
-
} else {
|
|
155
|
-
high = lastIndex;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
state.lastKey = key;
|
|
159
|
-
state.lastNeedle = needle;
|
|
160
|
-
return state.lastIndex = binarySearch(haystack, needle, low, high);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
// src/trace-mapping.ts
|
|
164
|
-
var LINE_GTR_ZERO = "`line` must be greater than 0 (lines start at line 1)";
|
|
165
|
-
var COL_GTR_EQ_ZERO = "`column` must be greater than or equal to 0 (columns start at column 0)";
|
|
166
|
-
var LEAST_UPPER_BOUND = -1;
|
|
167
|
-
var GREATEST_LOWER_BOUND = 1;
|
|
168
|
-
function cast(map) {
|
|
169
|
-
return map;
|
|
170
|
-
}
|
|
171
|
-
function decodedMappings(map) {
|
|
172
|
-
var _a;
|
|
173
|
-
return (_a = cast(map))._decoded || (_a._decoded = decode(cast(map)._encoded));
|
|
174
|
-
}
|
|
175
|
-
function originalPositionFor(map, needle) {
|
|
176
|
-
let { line, column, bias } = needle;
|
|
177
|
-
line--;
|
|
178
|
-
if (line < 0) throw new Error(LINE_GTR_ZERO);
|
|
179
|
-
if (column < 0) throw new Error(COL_GTR_EQ_ZERO);
|
|
180
|
-
const decoded = decodedMappings(map);
|
|
181
|
-
if (line >= decoded.length) return OMapping(null, null, null, null);
|
|
182
|
-
const segments = decoded[line];
|
|
183
|
-
const index = traceSegmentInternal(
|
|
184
|
-
segments,
|
|
185
|
-
cast(map)._decodedMemo,
|
|
186
|
-
line,
|
|
187
|
-
column,
|
|
188
|
-
bias || GREATEST_LOWER_BOUND
|
|
189
|
-
);
|
|
190
|
-
if (index === -1) return OMapping(null, null, null, null);
|
|
191
|
-
const segment = segments[index];
|
|
192
|
-
if (segment.length === 1) return OMapping(null, null, null, null);
|
|
193
|
-
const { names, resolvedSources } = map;
|
|
194
|
-
return OMapping(
|
|
195
|
-
resolvedSources[segment[SOURCES_INDEX]],
|
|
196
|
-
segment[SOURCE_LINE] + 1,
|
|
197
|
-
segment[SOURCE_COLUMN],
|
|
198
|
-
segment.length === 5 ? names[segment[NAMES_INDEX]] : null
|
|
199
|
-
);
|
|
200
|
-
}
|
|
201
|
-
function OMapping(source, line, column, name) {
|
|
202
|
-
return { source, line, column, name };
|
|
203
|
-
}
|
|
204
|
-
function traceSegmentInternal(segments, memo, line, column, bias) {
|
|
205
|
-
let index = memoizedBinarySearch(segments, column, memo, line);
|
|
206
|
-
if (found) {
|
|
207
|
-
index = (bias === LEAST_UPPER_BOUND ? upperBound : lowerBound)(segments, column, index);
|
|
208
|
-
} else if (bias === LEAST_UPPER_BOUND) index++;
|
|
209
|
-
if (index === -1 || index === segments.length) return -1;
|
|
210
|
-
return index;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
function notNullish(v) {
|
|
214
|
-
return v != null;
|
|
215
|
-
}
|
|
216
|
-
function isPrimitive(value) {
|
|
217
|
-
return value === null || typeof value !== "function" && typeof value !== "object";
|
|
218
|
-
}
|
|
219
|
-
function isObject(item) {
|
|
220
|
-
return item != null && typeof item === "object" && !Array.isArray(item);
|
|
221
|
-
}
|
|
222
|
-
/**
|
|
223
|
-
* If code starts with a function call, will return its last index, respecting arguments.
|
|
224
|
-
* This will return 25 - last ending character of toMatch ")"
|
|
225
|
-
* Also works with callbacks
|
|
226
|
-
* ```
|
|
227
|
-
* toMatch({ test: '123' });
|
|
228
|
-
* toBeAliased('123')
|
|
229
|
-
* ```
|
|
230
|
-
*/
|
|
231
|
-
function getCallLastIndex(code) {
|
|
232
|
-
let charIndex = -1;
|
|
233
|
-
let inString = null;
|
|
234
|
-
let startedBracers = 0;
|
|
235
|
-
let endedBracers = 0;
|
|
236
|
-
let beforeChar = null;
|
|
237
|
-
while (charIndex <= code.length) {
|
|
238
|
-
beforeChar = code[charIndex];
|
|
239
|
-
charIndex++;
|
|
240
|
-
const char = code[charIndex];
|
|
241
|
-
const isCharString = char === "\"" || char === "'" || char === "`";
|
|
242
|
-
if (isCharString && beforeChar !== "\\") {
|
|
243
|
-
if (inString === char) {
|
|
244
|
-
inString = null;
|
|
245
|
-
} else if (!inString) {
|
|
246
|
-
inString = char;
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
if (!inString) {
|
|
250
|
-
if (char === "(") {
|
|
251
|
-
startedBracers++;
|
|
252
|
-
}
|
|
253
|
-
if (char === ")") {
|
|
254
|
-
endedBracers++;
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
if (startedBracers && endedBracers && startedBracers === endedBracers) {
|
|
258
|
-
return charIndex;
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
return null;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
const CHROME_IE_STACK_REGEXP = /^\s*at .*(?:\S:\d+|\(native\))/m;
|
|
265
|
-
const SAFARI_NATIVE_CODE_REGEXP = /^(?:eval@)?(?:\[native code\])?$/;
|
|
266
|
-
const stackIgnorePatterns = [
|
|
267
|
-
"node:internal",
|
|
268
|
-
/\/packages\/\w+\/dist\//,
|
|
269
|
-
/\/@vitest\/\w+\/dist\//,
|
|
270
|
-
"/vitest/dist/",
|
|
271
|
-
"/vitest/src/",
|
|
272
|
-
"/node_modules/chai/",
|
|
273
|
-
"/node_modules/tinyspy/",
|
|
274
|
-
"/vite/dist/node/module-runner",
|
|
275
|
-
"/rolldown-vite/dist/node/module-runner",
|
|
276
|
-
"/deps/chunk-",
|
|
277
|
-
"/deps/@vitest",
|
|
278
|
-
"/deps/loupe",
|
|
279
|
-
"/deps/chai",
|
|
280
|
-
"/browser-playwright/dist/locators.js",
|
|
281
|
-
"/browser-webdriverio/dist/locators.js",
|
|
282
|
-
"/browser-preview/dist/locators.js",
|
|
283
|
-
/node:\w+/,
|
|
284
|
-
/__vitest_test__/,
|
|
285
|
-
/__vitest_browser__/,
|
|
286
|
-
/\/deps\/vitest_/
|
|
287
|
-
];
|
|
288
|
-
function extractLocation(urlLike) {
|
|
289
|
-
// Fail-fast but return locations like "(native)"
|
|
290
|
-
if (!urlLike.includes(":")) {
|
|
291
|
-
return [urlLike];
|
|
292
|
-
}
|
|
293
|
-
const regExp = /(.+?)(?::(\d+))?(?::(\d+))?$/;
|
|
294
|
-
const parts = regExp.exec(urlLike.replace(/^\(|\)$/g, ""));
|
|
295
|
-
if (!parts) {
|
|
296
|
-
return [urlLike];
|
|
297
|
-
}
|
|
298
|
-
let url = parts[1];
|
|
299
|
-
if (url.startsWith("async ")) {
|
|
300
|
-
url = url.slice(6);
|
|
301
|
-
}
|
|
302
|
-
if (url.startsWith("http:") || url.startsWith("https:")) {
|
|
303
|
-
const urlObj = new URL(url);
|
|
304
|
-
urlObj.searchParams.delete("import");
|
|
305
|
-
urlObj.searchParams.delete("browserv");
|
|
306
|
-
url = urlObj.pathname + urlObj.hash + urlObj.search;
|
|
307
|
-
}
|
|
308
|
-
if (url.startsWith("/@fs/")) {
|
|
309
|
-
const isWindows = /^\/@fs\/[a-zA-Z]:\//.test(url);
|
|
310
|
-
url = url.slice(isWindows ? 5 : 4);
|
|
311
|
-
}
|
|
312
|
-
return [
|
|
313
|
-
url,
|
|
314
|
-
parts[2] || undefined,
|
|
315
|
-
parts[3] || undefined
|
|
316
|
-
];
|
|
317
|
-
}
|
|
318
|
-
function parseSingleFFOrSafariStack(raw) {
|
|
319
|
-
let line = raw.trim();
|
|
320
|
-
if (SAFARI_NATIVE_CODE_REGEXP.test(line)) {
|
|
321
|
-
return null;
|
|
322
|
-
}
|
|
323
|
-
if (line.includes(" > eval")) {
|
|
324
|
-
line = line.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g, ":$1");
|
|
325
|
-
}
|
|
326
|
-
// Early return for lines that don't look like Firefox/Safari stack traces
|
|
327
|
-
// Firefox/Safari stack traces must contain '@' and should have location info after it
|
|
328
|
-
if (!line.includes("@")) {
|
|
329
|
-
return null;
|
|
330
|
-
}
|
|
331
|
-
// Find the correct @ that separates function name from location
|
|
332
|
-
// For cases like '@https://@fs/path' or 'functionName@https://@fs/path'
|
|
333
|
-
// we need to find the first @ that precedes a valid location (containing :)
|
|
334
|
-
let atIndex = -1;
|
|
335
|
-
let locationPart = "";
|
|
336
|
-
let functionName;
|
|
337
|
-
// Try each @ from left to right to find the one that gives us a valid location
|
|
338
|
-
for (let i = 0; i < line.length; i++) {
|
|
339
|
-
if (line[i] === "@") {
|
|
340
|
-
const candidateLocation = line.slice(i + 1);
|
|
341
|
-
// Minimum length 3 for valid location: 1 for filename + 1 for colon + 1 for line number (e.g., "a:1")
|
|
342
|
-
if (candidateLocation.includes(":") && candidateLocation.length >= 3) {
|
|
343
|
-
atIndex = i;
|
|
344
|
-
locationPart = candidateLocation;
|
|
345
|
-
functionName = i > 0 ? line.slice(0, i) : undefined;
|
|
346
|
-
break;
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
// Validate we found a valid location with minimum length (filename:line format)
|
|
351
|
-
if (atIndex === -1 || !locationPart.includes(":") || locationPart.length < 3) {
|
|
352
|
-
return null;
|
|
353
|
-
}
|
|
354
|
-
const [url, lineNumber, columnNumber] = extractLocation(locationPart);
|
|
355
|
-
if (!url || !lineNumber || !columnNumber) {
|
|
356
|
-
return null;
|
|
357
|
-
}
|
|
358
|
-
return {
|
|
359
|
-
file: url,
|
|
360
|
-
method: functionName || "",
|
|
361
|
-
line: Number.parseInt(lineNumber),
|
|
362
|
-
column: Number.parseInt(columnNumber)
|
|
363
|
-
};
|
|
364
|
-
}
|
|
365
|
-
// Based on https://github.com/stacktracejs/error-stack-parser
|
|
366
|
-
// Credit to stacktracejs
|
|
367
|
-
function parseSingleV8Stack(raw) {
|
|
368
|
-
let line = raw.trim();
|
|
369
|
-
if (!CHROME_IE_STACK_REGEXP.test(line)) {
|
|
370
|
-
return null;
|
|
371
|
-
}
|
|
372
|
-
if (line.includes("(eval ")) {
|
|
373
|
-
line = line.replace(/eval code/g, "eval").replace(/(\(eval at [^()]*)|(,.*$)/g, "");
|
|
374
|
-
}
|
|
375
|
-
let sanitizedLine = line.replace(/^\s+/, "").replace(/\(eval code/g, "(").replace(/^.*?\s+/, "");
|
|
376
|
-
// capture and preserve the parenthesized location "(/foo/my bar.js:12:87)" in
|
|
377
|
-
// case it has spaces in it, as the string is split on \s+ later on
|
|
378
|
-
const location = sanitizedLine.match(/ (\(.+\)$)/);
|
|
379
|
-
// remove the parenthesized location from the line, if it was matched
|
|
380
|
-
sanitizedLine = location ? sanitizedLine.replace(location[0], "") : sanitizedLine;
|
|
381
|
-
// if a location was matched, pass it to extractLocation() otherwise pass all sanitizedLine
|
|
382
|
-
// because this line doesn't have function name
|
|
383
|
-
const [url, lineNumber, columnNumber] = extractLocation(location ? location[1] : sanitizedLine);
|
|
384
|
-
let method = location && sanitizedLine || "";
|
|
385
|
-
let file = url && ["eval", "<anonymous>"].includes(url) ? undefined : url;
|
|
386
|
-
if (!file || !lineNumber || !columnNumber) {
|
|
387
|
-
return null;
|
|
388
|
-
}
|
|
389
|
-
if (method.startsWith("async ")) {
|
|
390
|
-
method = method.slice(6);
|
|
391
|
-
}
|
|
392
|
-
if (file.startsWith("file://")) {
|
|
393
|
-
file = file.slice(7);
|
|
394
|
-
}
|
|
395
|
-
// normalize Windows path (\ -> /)
|
|
396
|
-
file = file.startsWith("node:") || file.startsWith("internal:") ? file : resolve(file);
|
|
397
|
-
if (method) {
|
|
398
|
-
method = method.replace(/__vite_ssr_import_\d+__\./g, "").replace(/(Object\.)?__vite_ssr_export_default__\s?/g, "");
|
|
399
|
-
}
|
|
400
|
-
return {
|
|
401
|
-
method,
|
|
402
|
-
file,
|
|
403
|
-
line: Number.parseInt(lineNumber),
|
|
404
|
-
column: Number.parseInt(columnNumber)
|
|
405
|
-
};
|
|
406
|
-
}
|
|
407
|
-
function parseStacktrace(stack, options = {}) {
|
|
408
|
-
const { ignoreStackEntries = stackIgnorePatterns } = options;
|
|
409
|
-
const stacks = !CHROME_IE_STACK_REGEXP.test(stack) ? parseFFOrSafariStackTrace(stack) : parseV8Stacktrace(stack);
|
|
410
|
-
return stacks.map((stack) => {
|
|
411
|
-
var _options$getSourceMap;
|
|
412
|
-
if (options.getUrlId) {
|
|
413
|
-
stack.file = options.getUrlId(stack.file);
|
|
414
|
-
}
|
|
415
|
-
const map = (_options$getSourceMap = options.getSourceMap) === null || _options$getSourceMap === void 0 ? void 0 : _options$getSourceMap.call(options, stack.file);
|
|
416
|
-
if (!map || typeof map !== "object" || !map.version) {
|
|
417
|
-
return shouldFilter(ignoreStackEntries, stack.file) ? null : stack;
|
|
418
|
-
}
|
|
419
|
-
const traceMap = new DecodedMap(map, stack.file);
|
|
420
|
-
const position = getOriginalPosition(traceMap, stack);
|
|
421
|
-
if (!position) {
|
|
422
|
-
return stack;
|
|
423
|
-
}
|
|
424
|
-
const { line, column, source, name } = position;
|
|
425
|
-
let file = source || stack.file;
|
|
426
|
-
if (file.match(/\/\w:\//)) {
|
|
427
|
-
file = file.slice(1);
|
|
428
|
-
}
|
|
429
|
-
if (shouldFilter(ignoreStackEntries, file)) {
|
|
430
|
-
return null;
|
|
431
|
-
}
|
|
432
|
-
if (line != null && column != null) {
|
|
433
|
-
return {
|
|
434
|
-
line,
|
|
435
|
-
column,
|
|
436
|
-
file,
|
|
437
|
-
method: name || stack.method
|
|
438
|
-
};
|
|
439
|
-
}
|
|
440
|
-
return stack;
|
|
441
|
-
}).filter((s) => s != null);
|
|
442
|
-
}
|
|
443
|
-
function shouldFilter(ignoreStackEntries, file) {
|
|
444
|
-
return ignoreStackEntries.some((p) => file.match(p));
|
|
445
|
-
}
|
|
446
|
-
function parseFFOrSafariStackTrace(stack) {
|
|
447
|
-
return stack.split("\n").map((line) => parseSingleFFOrSafariStack(line)).filter(notNullish);
|
|
448
|
-
}
|
|
449
|
-
function parseV8Stacktrace(stack) {
|
|
450
|
-
return stack.split("\n").map((line) => parseSingleV8Stack(line)).filter(notNullish);
|
|
451
|
-
}
|
|
452
|
-
function parseErrorStacktrace(e, options = {}) {
|
|
453
|
-
if (!e || isPrimitive(e)) {
|
|
454
|
-
return [];
|
|
455
|
-
}
|
|
456
|
-
if ("stacks" in e && e.stacks) {
|
|
457
|
-
return e.stacks;
|
|
458
|
-
}
|
|
459
|
-
const stackStr = e.stack || "";
|
|
460
|
-
// if "stack" property was overwritten at runtime to be something else,
|
|
461
|
-
// ignore the value because we don't know how to process it
|
|
462
|
-
let stackFrames = typeof stackStr === "string" ? parseStacktrace(stackStr, options) : [];
|
|
463
|
-
if (!stackFrames.length) {
|
|
464
|
-
const e_ = e;
|
|
465
|
-
if (e_.fileName != null && e_.lineNumber != null && e_.columnNumber != null) {
|
|
466
|
-
stackFrames = parseStacktrace(`${e_.fileName}:${e_.lineNumber}:${e_.columnNumber}`, options);
|
|
467
|
-
}
|
|
468
|
-
if (e_.sourceURL != null && e_.line != null && e_._column != null) {
|
|
469
|
-
stackFrames = parseStacktrace(`${e_.sourceURL}:${e_.line}:${e_.column}`, options);
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
if (options.frameFilter) {
|
|
473
|
-
stackFrames = stackFrames.filter((f) => options.frameFilter(e, f) !== false);
|
|
474
|
-
}
|
|
475
|
-
e.stacks = stackFrames;
|
|
476
|
-
return stackFrames;
|
|
477
|
-
}
|
|
478
|
-
class DecodedMap {
|
|
479
|
-
_encoded;
|
|
480
|
-
_decoded;
|
|
481
|
-
_decodedMemo;
|
|
482
|
-
url;
|
|
483
|
-
version;
|
|
484
|
-
names = [];
|
|
485
|
-
resolvedSources;
|
|
486
|
-
constructor(map, from) {
|
|
487
|
-
this.map = map;
|
|
488
|
-
const { mappings, names, sources } = map;
|
|
489
|
-
this.version = map.version;
|
|
490
|
-
this.names = names || [];
|
|
491
|
-
this._encoded = mappings || "";
|
|
492
|
-
this._decodedMemo = memoizedState();
|
|
493
|
-
this.url = from;
|
|
494
|
-
this.resolvedSources = (sources || []).map((s) => resolve(s || "", from));
|
|
495
|
-
}
|
|
496
|
-
}
|
|
497
|
-
function memoizedState() {
|
|
498
|
-
return {
|
|
499
|
-
lastKey: -1,
|
|
500
|
-
lastNeedle: -1,
|
|
501
|
-
lastIndex: -1
|
|
502
|
-
};
|
|
503
|
-
}
|
|
504
|
-
function getOriginalPosition(map, needle) {
|
|
505
|
-
const result = originalPositionFor(map, needle);
|
|
506
|
-
if (result.column == null) {
|
|
507
|
-
return null;
|
|
508
|
-
}
|
|
509
|
-
return result;
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
const lineSplitRE = /\r?\n/;
|
|
513
|
-
function positionToOffset(source, lineNumber, columnNumber) {
|
|
514
|
-
const lines = source.split(lineSplitRE);
|
|
515
|
-
const nl = /\r\n/.test(source) ? 2 : 1;
|
|
516
|
-
let start = 0;
|
|
517
|
-
if (lineNumber > lines.length) {
|
|
518
|
-
return source.length;
|
|
519
|
-
}
|
|
520
|
-
for (let i = 0; i < lineNumber - 1; i++) {
|
|
521
|
-
start += lines[i].length + nl;
|
|
522
|
-
}
|
|
523
|
-
return start + columnNumber;
|
|
524
|
-
}
|
|
525
|
-
function offsetToLineNumber(source, offset) {
|
|
526
|
-
if (offset > source.length) {
|
|
527
|
-
throw new Error(`offset is longer than source length! offset ${offset} > length ${source.length}`);
|
|
528
|
-
}
|
|
529
|
-
const lines = source.split(lineSplitRE);
|
|
530
|
-
const nl = /\r\n/.test(source) ? 2 : 1;
|
|
531
|
-
let counted = 0;
|
|
532
|
-
let line = 0;
|
|
533
|
-
for (; line < lines.length; line++) {
|
|
534
|
-
const lineLength = lines[line].length + nl;
|
|
535
|
-
if (counted + lineLength >= offset) {
|
|
536
|
-
break;
|
|
537
|
-
}
|
|
538
|
-
counted += lineLength;
|
|
539
|
-
}
|
|
540
|
-
return line + 1;
|
|
541
|
-
}
|
|
542
|
-
|
|
543
6
|
async function saveInlineSnapshots(environment, snapshots) {
|
|
544
7
|
const MagicString = (await import('../../vendor/magic-string.mjs')).default;
|
|
545
8
|
const files = new Set(snapshots.map((i) => i.file));
|
|
546
9
|
await Promise.all(Array.from(files).map(async (file) => {
|
|
547
10
|
const snaps = snapshots.filter((i) => i.file === file);
|
|
548
11
|
const code = await environment.readSnapshotFile(file);
|
|
12
|
+
if (code == null) {
|
|
13
|
+
throw new Error(`cannot read ${file} when saving inline snapshot`);
|
|
14
|
+
}
|
|
549
15
|
const s = new MagicString(code);
|
|
550
16
|
for (const snap of snaps) {
|
|
551
17
|
const index = positionToOffset(code, snap.line, snap.column);
|
|
@@ -636,7 +102,7 @@ function replaceInlineSnap(code, s, currentIndex, newSnap) {
|
|
|
636
102
|
const { code: codeStartingAtIndex, index } = getCodeStartingAtIndex(code, currentIndex);
|
|
637
103
|
const startMatch = startRegex.exec(codeStartingAtIndex);
|
|
638
104
|
const firstKeywordMatch = /toMatchInlineSnapshot|toThrowErrorMatchingInlineSnapshot/.exec(codeStartingAtIndex);
|
|
639
|
-
if (!startMatch || startMatch.index !==
|
|
105
|
+
if (!startMatch || startMatch.index !== firstKeywordMatch?.index) {
|
|
640
106
|
return replaceObjectSnap(code, s, index, newSnap);
|
|
641
107
|
}
|
|
642
108
|
const quote = startMatch[1];
|
|
@@ -657,7 +123,6 @@ function replaceInlineSnap(code, s, currentIndex, newSnap) {
|
|
|
657
123
|
}
|
|
658
124
|
const INDENTATION_REGEX = /^([^\S\n]*)\S/m;
|
|
659
125
|
function stripSnapshotIndentation(inlineSnapshot) {
|
|
660
|
-
var _lines$at;
|
|
661
126
|
// Find indentation if exists.
|
|
662
127
|
const match = inlineSnapshot.match(INDENTATION_REGEX);
|
|
663
128
|
if (!match || !match[1]) {
|
|
@@ -670,7 +135,7 @@ function stripSnapshotIndentation(inlineSnapshot) {
|
|
|
670
135
|
// Must be at least 3 lines.
|
|
671
136
|
return inlineSnapshot;
|
|
672
137
|
}
|
|
673
|
-
if (lines[0].trim() !== "" ||
|
|
138
|
+
if (lines[0].trim() !== "" || lines.at(-1)?.trim() !== "") {
|
|
674
139
|
// If not blank first and last lines, abort.
|
|
675
140
|
return inlineSnapshot;
|
|
676
141
|
}
|
|
@@ -1099,6 +564,14 @@ class SnapshotState {
|
|
|
1099
564
|
if (promiseIndex !== -1) {
|
|
1100
565
|
return stacks[promiseIndex + 3];
|
|
1101
566
|
}
|
|
567
|
+
// inline snapshot function can be named __INLINE_SNAPSHOT_OFFSET_<n>__
|
|
568
|
+
// to specify a custom stack offset
|
|
569
|
+
for (let i = 0; i < stacks.length; i++) {
|
|
570
|
+
const match = stacks[i].method.match(/__INLINE_SNAPSHOT_OFFSET_(\d+)__/);
|
|
571
|
+
if (match) {
|
|
572
|
+
return stacks[i + Number(match[1])] ?? null;
|
|
573
|
+
}
|
|
574
|
+
}
|
|
1102
575
|
// inline snapshot function is called __INLINE_SNAPSHOT__
|
|
1103
576
|
// in integrations/snapshot/chai.ts
|
|
1104
577
|
const stackIndex = stacks.findIndex((i) => i.method.includes("__INLINE_SNAPSHOT__"));
|
|
@@ -1189,7 +662,7 @@ class SnapshotState {
|
|
|
1189
662
|
}
|
|
1190
663
|
}
|
|
1191
664
|
const expected = isInline ? inlineSnapshot : rawSnapshot ? rawSnapshot.content : this._snapshotData[key];
|
|
1192
|
-
const expectedTrimmed = rawSnapshot ? expected : expected
|
|
665
|
+
const expectedTrimmed = rawSnapshot ? expected : expected?.trim();
|
|
1193
666
|
const pass = expectedTrimmed === (rawSnapshot ? receivedSerialized : receivedSerialized.trim());
|
|
1194
667
|
const hasSnapshot = expected !== undefined;
|
|
1195
668
|
const snapshotIsPersisted = isInline || this._fileExists || rawSnapshot && rawSnapshot.content != null;
|
|
@@ -1205,13 +678,12 @@ class SnapshotState {
|
|
|
1205
678
|
// find call site of toMatchInlineSnapshot
|
|
1206
679
|
let stack;
|
|
1207
680
|
if (isInline) {
|
|
1208
|
-
var _this$environment$pro, _this$environment;
|
|
1209
681
|
const stacks = parseErrorStacktrace(error || new Error("snapshot"), { ignoreStackEntries: [] });
|
|
1210
682
|
const _stack = this._inferInlineSnapshotStack(stacks);
|
|
1211
683
|
if (!_stack) {
|
|
1212
684
|
throw new Error(`@vitest/snapshot: Couldn't infer stack frame for inline snapshot.\n${JSON.stringify(stacks)}`);
|
|
1213
685
|
}
|
|
1214
|
-
stack =
|
|
686
|
+
stack = this.environment.processStackTrace?.(_stack) || _stack;
|
|
1215
687
|
// removing 1 column, because source map points to the wrong
|
|
1216
688
|
// location for js files, but `column-1` points to the same in both js/ts
|
|
1217
689
|
// https://github.com/vitejs/vite/issues/8657
|
|
@@ -1384,8 +856,7 @@ class SnapshotClient {
|
|
|
1384
856
|
throw new Error("Received value must be an object when the matcher has properties");
|
|
1385
857
|
}
|
|
1386
858
|
try {
|
|
1387
|
-
|
|
1388
|
-
const pass = ((_this$options$isEqual = (_this$options = this.options).isEqual) === null || _this$options$isEqual === void 0 ? void 0 : _this$options$isEqual.call(_this$options, received, properties)) ?? false;
|
|
859
|
+
const pass = this.options.isEqual?.(received, properties) ?? false;
|
|
1389
860
|
// const pass = equals(received, properties, [iterableEquality, subsetEquality])
|
|
1390
861
|
if (!pass) {
|
|
1391
862
|
throw createMismatchError("Snapshot properties mismatched", snapshotState.expand, received, properties);
|
|
@@ -1408,7 +879,7 @@ class SnapshotClient {
|
|
|
1408
879
|
rawSnapshot
|
|
1409
880
|
});
|
|
1410
881
|
if (!pass) {
|
|
1411
|
-
throw createMismatchError(`Snapshot \`${key || "unknown"}\` mismatched`, snapshotState.expand, rawSnapshot ? actual : actual
|
|
882
|
+
throw createMismatchError(`Snapshot \`${key || "unknown"}\` mismatched`, snapshotState.expand, rawSnapshot ? actual : actual?.trim(), rawSnapshot ? expected : expected?.trim());
|
|
1412
883
|
}
|
|
1413
884
|
}
|
|
1414
885
|
async assertRaw(options) {
|
|
@@ -1422,7 +893,7 @@ class SnapshotClient {
|
|
|
1422
893
|
}
|
|
1423
894
|
const snapshotState = this.getSnapshotState(filepath);
|
|
1424
895
|
// save the filepath, so it don't lose even if the await make it out-of-context
|
|
1425
|
-
options.filepath
|
|
896
|
+
options.filepath ||= filepath;
|
|
1426
897
|
// resolve and read the raw snapshot file
|
|
1427
898
|
rawSnapshot.file = await snapshotState.environment.resolveRawPath(filepath, rawSnapshot.file);
|
|
1428
899
|
rawSnapshot.content = await snapshotState.environment.readSnapshotFile(rawSnapshot.file) ?? undefined;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { S as SnapshotStateOptions, e as SnapshotSummary, b as SnapshotResult } from './rawSnapshot.d-
|
|
1
|
+
import { S as SnapshotStateOptions, e as SnapshotSummary, b as SnapshotResult } from './rawSnapshot.d-U2kJUxDr.js';
|
|
2
2
|
import '../pretty-format/index.js';
|
|
3
|
-
import './environment.d-
|
|
3
|
+
import './environment.d-DOJxxZV9.js';
|
|
4
|
+
import '../utils/index.js';
|
|
4
5
|
|
|
5
6
|
declare class SnapshotManager {
|
|
6
7
|
options: Omit<SnapshotStateOptions, "snapshotEnvironment">;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { OptionsReceived, Plugin } from '../pretty-format/index.js';
|
|
2
|
-
import { S as SnapshotEnvironment } from './environment.d-
|
|
2
|
+
import { S as SnapshotEnvironment } from './environment.d-DOJxxZV9.js';
|
|
3
3
|
|
|
4
4
|
type SnapshotData = Record<string, string>;
|
|
5
5
|
type SnapshotUpdateState = "all" | "new" | "none";
|