vitest 0.0.112 → 0.0.113
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/cli.js +7 -5
- package/dist/{constants-2b0310b7.js → constants-900abe4a.js} +1 -1
- package/dist/{diff-66d6bb83.js → diff-9c43ab50.js} +3300 -3298
- package/dist/entry.js +74 -18
- package/dist/{global-201fd559.js → global-75208c77.js} +7 -6
- package/dist/{utils-cb6b1266.js → index-041e627e.js} +1 -185
- package/dist/{index-2bb9fd4d.js → index-09437c50.js} +1 -1
- package/dist/index-1488b423.js +186 -0
- package/dist/{index-8ab26d25.js → index-c3f2f9fe.js} +64 -1113
- package/dist/index.d.ts +16 -3
- package/dist/index.js +3 -4
- package/dist/magic-string.es-94000aea.js +1360 -0
- package/dist/{middleware-2028dfa0.js → middleware-0ebc5238.js} +2 -4
- package/dist/node.d.ts +1 -0
- package/dist/node.js +8 -6
- package/dist/utils.js +3 -2
- package/dist/{vi-cb9e4e4e.js → vi-51946984.js} +1 -1
- package/dist/worker.js +5 -4
- package/package.json +1 -1
package/dist/entry.js
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import fs, { promises } from 'fs';
|
|
2
|
-
import { f as equals, h as iterableEquality, j as subsetEquality, k as isA, J as JestChaiExpect, l as clearContext, m as defaultSuite, n as setHooks, o as getHooks, p as context, s as setState, q as getFn, b as getState, e as vi } from './vi-
|
|
2
|
+
import { f as equals, h as iterableEquality, j as subsetEquality, k as isA, J as JestChaiExpect, l as clearContext, m as defaultSuite, n as setHooks, o as getHooks, p as context, s as setState, q as getFn, b as getState, e as vi } from './vi-51946984.js';
|
|
3
3
|
import { Console } from 'console';
|
|
4
4
|
import { Writable } from 'stream';
|
|
5
5
|
import { importModule } from 'local-pkg';
|
|
6
6
|
import chai$1, { expect, util } from 'chai';
|
|
7
7
|
import { a as commonjsRequire, c as commonjsGlobal } from './_commonjsHelpers-c9e3b764.js';
|
|
8
|
-
import {
|
|
8
|
+
import { c as index, r as relative } from './index-1488b423.js';
|
|
9
9
|
import { r as rpc, s as send } from './rpc-7de86f29.js';
|
|
10
|
-
import {
|
|
10
|
+
import { s as slash, f as getNames, c as c$1, t as toArray, i as interpretOnlyMode, p as partitionSuiteChildren, j as hasTests, h as hasFailed } from './index-041e627e.js';
|
|
11
|
+
import { l as getOriginalPos, m as posToNumber, n as parseStack, u as unifiedDiff } from './diff-9c43ab50.js';
|
|
11
12
|
import { performance } from 'perf_hooks';
|
|
12
13
|
import { n as nanoid } from './jest-mock-a57b745c.js';
|
|
13
14
|
import { format as format$1 } from 'util';
|
|
14
|
-
import 'tty';
|
|
15
15
|
import 'path';
|
|
16
|
+
import 'tty';
|
|
16
17
|
import 'tinyspy';
|
|
17
18
|
|
|
18
19
|
var node = {
|
|
@@ -382,6 +383,44 @@ var chaiSubset = {exports: {}};
|
|
|
382
383
|
|
|
383
384
|
var Subset = chaiSubset.exports;
|
|
384
385
|
|
|
386
|
+
async function saveInlineSnapshots(snapshots) {
|
|
387
|
+
const MagicString = (await import('./magic-string.es-94000aea.js')).default;
|
|
388
|
+
const files = new Set(snapshots.map((i) => i.file));
|
|
389
|
+
await Promise.all(Array.from(files).map(async (file) => {
|
|
390
|
+
const map = await rpc("getSourceMap", file, true);
|
|
391
|
+
const snaps = snapshots.filter((i) => i.file === file);
|
|
392
|
+
const code = await promises.readFile(file, "utf8");
|
|
393
|
+
const s = new MagicString(code);
|
|
394
|
+
for (const snap of snaps) {
|
|
395
|
+
const pos = await getOriginalPos(map, snap);
|
|
396
|
+
const index = posToNumber(code, pos);
|
|
397
|
+
replaceInlineSnap(code, s, index, snap.snapshot);
|
|
398
|
+
}
|
|
399
|
+
await promises.writeFile(file, s.toString(), "utf-8");
|
|
400
|
+
}));
|
|
401
|
+
}
|
|
402
|
+
const startRegex = /toMatchInlineSnapshot\s*\(\s*(['"`\)])/m;
|
|
403
|
+
function replaceInlineSnap(code, s, index, newSnap) {
|
|
404
|
+
const startMatch = startRegex.exec(code.slice(index));
|
|
405
|
+
if (!startMatch)
|
|
406
|
+
return false;
|
|
407
|
+
newSnap = newSnap.replace(/\\/g, "\\\\");
|
|
408
|
+
const snapString = newSnap.includes("\n") ? `\`${newSnap.replace(/`/g, "\\`").trimEnd()}\`` : `'${newSnap.replace(/'/g, "\\'")}'`;
|
|
409
|
+
const quote = startMatch[1];
|
|
410
|
+
const startIndex = index + startMatch.index + startMatch[0].length;
|
|
411
|
+
if (quote === ")") {
|
|
412
|
+
s.appendRight(startIndex - 1, snapString);
|
|
413
|
+
return true;
|
|
414
|
+
}
|
|
415
|
+
const quoteEndRE = new RegExp(`(?:^|[^\\\\])${quote}`);
|
|
416
|
+
const endMatch = quoteEndRE.exec(code.slice(startIndex));
|
|
417
|
+
if (!endMatch)
|
|
418
|
+
return false;
|
|
419
|
+
const endIndex = startIndex + endMatch.index + endMatch[0].length;
|
|
420
|
+
s.overwrite(startIndex - 1, endIndex, snapString);
|
|
421
|
+
return true;
|
|
422
|
+
}
|
|
423
|
+
|
|
385
424
|
var naturalCompare$2 = {exports: {}};
|
|
386
425
|
|
|
387
426
|
/*
|
|
@@ -2830,13 +2869,13 @@ function ensureDirectoryExists(filePath) {
|
|
|
2830
2869
|
function normalizeNewlines(string) {
|
|
2831
2870
|
return string.replace(/\r\n|\r/g, "\n");
|
|
2832
2871
|
}
|
|
2833
|
-
function saveSnapshotFile(snapshotData, snapshotPath) {
|
|
2872
|
+
async function saveSnapshotFile(snapshotData, snapshotPath) {
|
|
2834
2873
|
const snapshots = Object.keys(snapshotData).sort(naturalCompare$1).map((key) => `exports[${printBacktickString(key)}] = ${printBacktickString(normalizeNewlines(snapshotData[key]))};`);
|
|
2835
2874
|
ensureDirectoryExists(snapshotPath);
|
|
2836
|
-
|
|
2875
|
+
await promises.writeFile(snapshotPath, `${writeSnapshotVersion()}
|
|
2837
2876
|
|
|
2838
2877
|
${snapshots.join("\n\n")}
|
|
2839
|
-
|
|
2878
|
+
`, "utf-8");
|
|
2840
2879
|
}
|
|
2841
2880
|
|
|
2842
2881
|
var __defProp$1 = Object.defineProperty;
|
|
@@ -2862,6 +2901,7 @@ class SnapshotState {
|
|
|
2862
2901
|
this._initialData = data;
|
|
2863
2902
|
this._snapshotData = data;
|
|
2864
2903
|
this._dirty = dirty;
|
|
2904
|
+
this._inlineSnapshots = [];
|
|
2865
2905
|
this._uncheckedKeys = new Set(Object.keys(this._snapshotData));
|
|
2866
2906
|
this._counters = /* @__PURE__ */ new Map();
|
|
2867
2907
|
this._index = 0;
|
|
@@ -2883,7 +2923,20 @@ class SnapshotState {
|
|
|
2883
2923
|
}
|
|
2884
2924
|
_addSnapshot(key, receivedSerialized, options) {
|
|
2885
2925
|
this._dirty = true;
|
|
2886
|
-
|
|
2926
|
+
if (options.isInline) {
|
|
2927
|
+
const error = options.error || new Error("Unknown error");
|
|
2928
|
+
const stacks = parseStack(error.stack || "");
|
|
2929
|
+
stacks.forEach((i) => i.file = slash(i.file));
|
|
2930
|
+
const stack = stacks.find((i) => process.__vitest_worker__.ctx.files.includes(i.file));
|
|
2931
|
+
if (!stack) {
|
|
2932
|
+
throw new Error("Vitest: Couldn't infer stack frame for inline snapshot.");
|
|
2933
|
+
}
|
|
2934
|
+
this._inlineSnapshots.push(__spreadValues$1({
|
|
2935
|
+
snapshot: receivedSerialized
|
|
2936
|
+
}, stack));
|
|
2937
|
+
} else {
|
|
2938
|
+
this._snapshotData[key] = receivedSerialized;
|
|
2939
|
+
}
|
|
2887
2940
|
}
|
|
2888
2941
|
clear() {
|
|
2889
2942
|
this._snapshotData = this._initialData;
|
|
@@ -2894,16 +2947,19 @@ class SnapshotState {
|
|
|
2894
2947
|
this.unmatched = 0;
|
|
2895
2948
|
this.updated = 0;
|
|
2896
2949
|
}
|
|
2897
|
-
save() {
|
|
2950
|
+
async save() {
|
|
2898
2951
|
const hasExternalSnapshots = Object.keys(this._snapshotData).length;
|
|
2899
|
-
const
|
|
2952
|
+
const hasInlineSnapshots = this._inlineSnapshots.length;
|
|
2953
|
+
const isEmpty = !hasExternalSnapshots && !hasInlineSnapshots;
|
|
2900
2954
|
const status = {
|
|
2901
2955
|
deleted: false,
|
|
2902
2956
|
saved: false
|
|
2903
2957
|
};
|
|
2904
2958
|
if ((this._dirty || this._uncheckedKeys.size) && !isEmpty) {
|
|
2905
2959
|
if (hasExternalSnapshots)
|
|
2906
|
-
saveSnapshotFile(this._snapshotData, this._snapshotPath);
|
|
2960
|
+
await saveSnapshotFile(this._snapshotData, this._snapshotPath);
|
|
2961
|
+
if (hasInlineSnapshots)
|
|
2962
|
+
await saveInlineSnapshots(this._inlineSnapshots);
|
|
2907
2963
|
status.saved = true;
|
|
2908
2964
|
} else if (!hasExternalSnapshots && fs.existsSync(this._snapshotPath)) {
|
|
2909
2965
|
if (this._updateSnapshot === "all")
|
|
@@ -3019,7 +3075,7 @@ class SnapshotClient {
|
|
|
3019
3075
|
clearTest() {
|
|
3020
3076
|
this.test = void 0;
|
|
3021
3077
|
}
|
|
3022
|
-
assert(received, message, inlineSnapshot) {
|
|
3078
|
+
assert(received, message, isInline = false, inlineSnapshot) {
|
|
3023
3079
|
if (!this.test)
|
|
3024
3080
|
throw new Error("Snapshot cannot be used outside of test");
|
|
3025
3081
|
const testName = [
|
|
@@ -3029,7 +3085,7 @@ class SnapshotClient {
|
|
|
3029
3085
|
const { actual, expected, key, pass } = this.snapshotState.match({
|
|
3030
3086
|
testName,
|
|
3031
3087
|
received,
|
|
3032
|
-
isInline
|
|
3088
|
+
isInline,
|
|
3033
3089
|
inlineSnapshot: inlineSnapshot == null ? void 0 : inlineSnapshot.trim()
|
|
3034
3090
|
});
|
|
3035
3091
|
if (!pass) {
|
|
@@ -3044,13 +3100,13 @@ class SnapshotClient {
|
|
|
3044
3100
|
async saveSnap() {
|
|
3045
3101
|
if (!this.testFile || !this.snapshotState)
|
|
3046
3102
|
return;
|
|
3047
|
-
const result = packSnapshotState(this.testFile, this.snapshotState);
|
|
3103
|
+
const result = await packSnapshotState(this.testFile, this.snapshotState);
|
|
3048
3104
|
await rpc("snapshotSaved", result);
|
|
3049
3105
|
this.testFile = "";
|
|
3050
3106
|
this.snapshotState = void 0;
|
|
3051
3107
|
}
|
|
3052
3108
|
}
|
|
3053
|
-
function packSnapshotState(filepath, state) {
|
|
3109
|
+
async function packSnapshotState(filepath, state) {
|
|
3054
3110
|
const snapshot = {
|
|
3055
3111
|
filepath,
|
|
3056
3112
|
added: 0,
|
|
@@ -3065,7 +3121,7 @@ function packSnapshotState(filepath, state) {
|
|
|
3065
3121
|
const uncheckedKeys = state.getUncheckedKeys();
|
|
3066
3122
|
if (uncheckedCount)
|
|
3067
3123
|
state.removeUncheckedKeys();
|
|
3068
|
-
const status = state.save();
|
|
3124
|
+
const status = await state.save();
|
|
3069
3125
|
snapshot.fileDeleted = status.deleted;
|
|
3070
3126
|
snapshot.added = state.added;
|
|
3071
3127
|
snapshot.matched = state.matched;
|
|
@@ -3091,7 +3147,7 @@ const SnapshotPlugin = (chai, utils) => {
|
|
|
3091
3147
|
}
|
|
3092
3148
|
utils.addMethod(chai.Assertion.prototype, "toMatchInlineSnapshot", function(inlineSnapshot, message) {
|
|
3093
3149
|
const expected = utils.flag(this, "object");
|
|
3094
|
-
getSnapshotClient().assert(expected, message, inlineSnapshot);
|
|
3150
|
+
getSnapshotClient().assert(expected, message, true, inlineSnapshot);
|
|
3095
3151
|
});
|
|
3096
3152
|
};
|
|
3097
3153
|
|
|
@@ -3472,7 +3528,7 @@ async function setupGlobalEnv(config) {
|
|
|
3472
3528
|
setupConsoleLogSpy();
|
|
3473
3529
|
await setupChai();
|
|
3474
3530
|
if (config.global)
|
|
3475
|
-
(await import('./global-
|
|
3531
|
+
(await import('./global-75208c77.js')).registerApiGlobally();
|
|
3476
3532
|
}
|
|
3477
3533
|
function setupConsoleLogSpy() {
|
|
3478
3534
|
const stdout = new Writable({
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { g as globalApis } from './constants-
|
|
2
|
-
import { i as index } from './index-
|
|
1
|
+
import { g as globalApis } from './constants-900abe4a.js';
|
|
2
|
+
import { i as index } from './index-09437c50.js';
|
|
3
3
|
import 'url';
|
|
4
|
-
import './
|
|
5
|
-
import 'tty';
|
|
6
|
-
import 'local-pkg';
|
|
4
|
+
import './index-1488b423.js';
|
|
7
5
|
import 'path';
|
|
8
|
-
import './vi-
|
|
6
|
+
import './vi-51946984.js';
|
|
9
7
|
import './jest-mock-a57b745c.js';
|
|
10
8
|
import 'chai';
|
|
11
9
|
import 'tinyspy';
|
|
10
|
+
import './index-041e627e.js';
|
|
11
|
+
import 'tty';
|
|
12
|
+
import 'local-pkg';
|
|
12
13
|
import './_commonjsHelpers-c9e3b764.js';
|
|
13
14
|
|
|
14
15
|
function registerApiGlobally() {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import require$$0 from 'tty';
|
|
2
2
|
import { isPackageExists } from 'local-pkg';
|
|
3
|
-
import path from 'path';
|
|
4
3
|
|
|
5
4
|
var picocolors = {exports: {}};
|
|
6
5
|
|
|
@@ -65,189 +64,6 @@ picocolors.exports.createColors = createColors;
|
|
|
65
64
|
|
|
66
65
|
var c = picocolors.exports;
|
|
67
66
|
|
|
68
|
-
function normalizeWindowsPath(input = "") {
|
|
69
|
-
if (!input.includes("\\")) {
|
|
70
|
-
return input;
|
|
71
|
-
}
|
|
72
|
-
return input.replace(/\\/g, "/");
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
const _UNC_REGEX = /^[/][/]/;
|
|
76
|
-
const _UNC_DRIVE_REGEX = /^[/][/]([.]{1,2}[/])?([a-zA-Z]):[/]/;
|
|
77
|
-
const _IS_ABSOLUTE_RE = /^\/|^\\|^[a-zA-Z]:[/\\]/;
|
|
78
|
-
const sep = "/";
|
|
79
|
-
const delimiter = ":";
|
|
80
|
-
const normalize = function(path2) {
|
|
81
|
-
if (path2.length === 0) {
|
|
82
|
-
return ".";
|
|
83
|
-
}
|
|
84
|
-
path2 = normalizeWindowsPath(path2);
|
|
85
|
-
const isUNCPath = path2.match(_UNC_REGEX);
|
|
86
|
-
const hasUNCDrive = isUNCPath && path2.match(_UNC_DRIVE_REGEX);
|
|
87
|
-
const isPathAbsolute = isAbsolute(path2);
|
|
88
|
-
const trailingSeparator = path2[path2.length - 1] === "/";
|
|
89
|
-
path2 = normalizeString(path2, !isPathAbsolute);
|
|
90
|
-
if (path2.length === 0) {
|
|
91
|
-
if (isPathAbsolute) {
|
|
92
|
-
return "/";
|
|
93
|
-
}
|
|
94
|
-
return trailingSeparator ? "./" : ".";
|
|
95
|
-
}
|
|
96
|
-
if (trailingSeparator) {
|
|
97
|
-
path2 += "/";
|
|
98
|
-
}
|
|
99
|
-
if (isUNCPath) {
|
|
100
|
-
if (hasUNCDrive) {
|
|
101
|
-
return `//./${path2}`;
|
|
102
|
-
}
|
|
103
|
-
return `//${path2}`;
|
|
104
|
-
}
|
|
105
|
-
return isPathAbsolute && !isAbsolute(path2) ? `/${path2}` : path2;
|
|
106
|
-
};
|
|
107
|
-
const join = function(...args) {
|
|
108
|
-
if (args.length === 0) {
|
|
109
|
-
return ".";
|
|
110
|
-
}
|
|
111
|
-
let joined;
|
|
112
|
-
for (let i = 0; i < args.length; ++i) {
|
|
113
|
-
const arg = args[i];
|
|
114
|
-
if (arg.length > 0) {
|
|
115
|
-
if (joined === void 0) {
|
|
116
|
-
joined = arg;
|
|
117
|
-
} else {
|
|
118
|
-
joined += `/${arg}`;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
if (joined === void 0) {
|
|
123
|
-
return ".";
|
|
124
|
-
}
|
|
125
|
-
return normalize(joined);
|
|
126
|
-
};
|
|
127
|
-
const resolve = function(...args) {
|
|
128
|
-
args = args.map((arg) => normalizeWindowsPath(arg));
|
|
129
|
-
let resolvedPath = "";
|
|
130
|
-
let resolvedAbsolute = false;
|
|
131
|
-
for (let i = args.length - 1; i >= -1 && !resolvedAbsolute; i--) {
|
|
132
|
-
const path2 = i >= 0 ? args[i] : process.cwd();
|
|
133
|
-
if (path2.length === 0) {
|
|
134
|
-
continue;
|
|
135
|
-
}
|
|
136
|
-
resolvedPath = `${path2}/${resolvedPath}`;
|
|
137
|
-
resolvedAbsolute = isAbsolute(path2);
|
|
138
|
-
}
|
|
139
|
-
resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
|
|
140
|
-
if (resolvedAbsolute && !isAbsolute(resolvedPath)) {
|
|
141
|
-
return `/${resolvedPath}`;
|
|
142
|
-
}
|
|
143
|
-
return resolvedPath.length > 0 ? resolvedPath : ".";
|
|
144
|
-
};
|
|
145
|
-
function normalizeString(path2, allowAboveRoot) {
|
|
146
|
-
let res = "";
|
|
147
|
-
let lastSegmentLength = 0;
|
|
148
|
-
let lastSlash = -1;
|
|
149
|
-
let dots = 0;
|
|
150
|
-
let char = null;
|
|
151
|
-
for (let i = 0; i <= path2.length; ++i) {
|
|
152
|
-
if (i < path2.length) {
|
|
153
|
-
char = path2[i];
|
|
154
|
-
} else if (char === "/") {
|
|
155
|
-
break;
|
|
156
|
-
} else {
|
|
157
|
-
char = "/";
|
|
158
|
-
}
|
|
159
|
-
if (char === "/") {
|
|
160
|
-
if (lastSlash === i - 1 || dots === 1) ; else if (dots === 2) {
|
|
161
|
-
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
|
162
|
-
if (res.length > 2) {
|
|
163
|
-
const lastSlashIndex = res.lastIndexOf("/");
|
|
164
|
-
if (lastSlashIndex === -1) {
|
|
165
|
-
res = "";
|
|
166
|
-
lastSegmentLength = 0;
|
|
167
|
-
} else {
|
|
168
|
-
res = res.slice(0, lastSlashIndex);
|
|
169
|
-
lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
|
|
170
|
-
}
|
|
171
|
-
lastSlash = i;
|
|
172
|
-
dots = 0;
|
|
173
|
-
continue;
|
|
174
|
-
} else if (res.length !== 0) {
|
|
175
|
-
res = "";
|
|
176
|
-
lastSegmentLength = 0;
|
|
177
|
-
lastSlash = i;
|
|
178
|
-
dots = 0;
|
|
179
|
-
continue;
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
if (allowAboveRoot) {
|
|
183
|
-
res += res.length > 0 ? "/.." : "..";
|
|
184
|
-
lastSegmentLength = 2;
|
|
185
|
-
}
|
|
186
|
-
} else {
|
|
187
|
-
if (res.length > 0) {
|
|
188
|
-
res += `/${path2.slice(lastSlash + 1, i)}`;
|
|
189
|
-
} else {
|
|
190
|
-
res = path2.slice(lastSlash + 1, i);
|
|
191
|
-
}
|
|
192
|
-
lastSegmentLength = i - lastSlash - 1;
|
|
193
|
-
}
|
|
194
|
-
lastSlash = i;
|
|
195
|
-
dots = 0;
|
|
196
|
-
} else if (char === "." && dots !== -1) {
|
|
197
|
-
++dots;
|
|
198
|
-
} else {
|
|
199
|
-
dots = -1;
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
return res;
|
|
203
|
-
}
|
|
204
|
-
const isAbsolute = function(p) {
|
|
205
|
-
return _IS_ABSOLUTE_RE.test(p);
|
|
206
|
-
};
|
|
207
|
-
const toNamespacedPath = function(p) {
|
|
208
|
-
return normalizeWindowsPath(p);
|
|
209
|
-
};
|
|
210
|
-
const extname = function(p) {
|
|
211
|
-
return path.posix.extname(normalizeWindowsPath(p));
|
|
212
|
-
};
|
|
213
|
-
const relative = function(from, to) {
|
|
214
|
-
return path.posix.relative(normalizeWindowsPath(from), normalizeWindowsPath(to));
|
|
215
|
-
};
|
|
216
|
-
const dirname = function(p) {
|
|
217
|
-
return path.posix.dirname(normalizeWindowsPath(p));
|
|
218
|
-
};
|
|
219
|
-
const format = function(p) {
|
|
220
|
-
return normalizeWindowsPath(path.posix.format(p));
|
|
221
|
-
};
|
|
222
|
-
const basename = function(p, ext) {
|
|
223
|
-
return path.posix.basename(normalizeWindowsPath(p), ext);
|
|
224
|
-
};
|
|
225
|
-
const parse = function(p) {
|
|
226
|
-
return path.posix.parse(normalizeWindowsPath(p));
|
|
227
|
-
};
|
|
228
|
-
|
|
229
|
-
const _path = /*#__PURE__*/Object.freeze({
|
|
230
|
-
__proto__: null,
|
|
231
|
-
sep: sep,
|
|
232
|
-
delimiter: delimiter,
|
|
233
|
-
normalize: normalize,
|
|
234
|
-
join: join,
|
|
235
|
-
resolve: resolve,
|
|
236
|
-
normalizeString: normalizeString,
|
|
237
|
-
isAbsolute: isAbsolute,
|
|
238
|
-
toNamespacedPath: toNamespacedPath,
|
|
239
|
-
extname: extname,
|
|
240
|
-
relative: relative,
|
|
241
|
-
dirname: dirname,
|
|
242
|
-
format: format,
|
|
243
|
-
basename: basename,
|
|
244
|
-
parse: parse
|
|
245
|
-
});
|
|
246
|
-
|
|
247
|
-
const index = {
|
|
248
|
-
..._path
|
|
249
|
-
};
|
|
250
|
-
|
|
251
67
|
function toArray(array) {
|
|
252
68
|
array = array || [];
|
|
253
69
|
if (Array.isArray(array))
|
|
@@ -349,4 +165,4 @@ async function ensurePackageInstalled(dependency, promptInstall = !process.env.C
|
|
|
349
165
|
return false;
|
|
350
166
|
}
|
|
351
167
|
|
|
352
|
-
export {
|
|
168
|
+
export { getSuites as a, getTests as b, c, notNullish as d, ensurePackageInstalled as e, getNames as f, getFullName as g, hasFailed as h, interpretOnlyMode as i, hasTests as j, getTasks as k, mergeSlashes as m, noop as n, partitionSuiteChildren as p, slash as s, toArray as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { g as getCurrentSuite, w as withTimeout, a as getDefaultHookTimeout, b as getState, s as setState, c as suite, t as test, d as describe, i as it, v as vitest, e as vi } from './vi-
|
|
1
|
+
import { g as getCurrentSuite, w as withTimeout, a as getDefaultHookTimeout, b as getState, s as setState, c as suite, t as test, d as describe, i as it, v as vitest, e as vi } from './vi-51946984.js';
|
|
2
2
|
import chai, { assert, should } from 'chai';
|
|
3
3
|
import { s as spies, a as spyOn, f as fn } from './jest-mock-a57b745c.js';
|
|
4
4
|
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
|
|
3
|
+
function normalizeWindowsPath(input = "") {
|
|
4
|
+
if (!input.includes("\\")) {
|
|
5
|
+
return input;
|
|
6
|
+
}
|
|
7
|
+
return input.replace(/\\/g, "/");
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const _UNC_REGEX = /^[/][/]/;
|
|
11
|
+
const _UNC_DRIVE_REGEX = /^[/][/]([.]{1,2}[/])?([a-zA-Z]):[/]/;
|
|
12
|
+
const _IS_ABSOLUTE_RE = /^\/|^\\|^[a-zA-Z]:[/\\]/;
|
|
13
|
+
const sep = "/";
|
|
14
|
+
const delimiter = ":";
|
|
15
|
+
const normalize = function(path2) {
|
|
16
|
+
if (path2.length === 0) {
|
|
17
|
+
return ".";
|
|
18
|
+
}
|
|
19
|
+
path2 = normalizeWindowsPath(path2);
|
|
20
|
+
const isUNCPath = path2.match(_UNC_REGEX);
|
|
21
|
+
const hasUNCDrive = isUNCPath && path2.match(_UNC_DRIVE_REGEX);
|
|
22
|
+
const isPathAbsolute = isAbsolute(path2);
|
|
23
|
+
const trailingSeparator = path2[path2.length - 1] === "/";
|
|
24
|
+
path2 = normalizeString(path2, !isPathAbsolute);
|
|
25
|
+
if (path2.length === 0) {
|
|
26
|
+
if (isPathAbsolute) {
|
|
27
|
+
return "/";
|
|
28
|
+
}
|
|
29
|
+
return trailingSeparator ? "./" : ".";
|
|
30
|
+
}
|
|
31
|
+
if (trailingSeparator) {
|
|
32
|
+
path2 += "/";
|
|
33
|
+
}
|
|
34
|
+
if (isUNCPath) {
|
|
35
|
+
if (hasUNCDrive) {
|
|
36
|
+
return `//./${path2}`;
|
|
37
|
+
}
|
|
38
|
+
return `//${path2}`;
|
|
39
|
+
}
|
|
40
|
+
return isPathAbsolute && !isAbsolute(path2) ? `/${path2}` : path2;
|
|
41
|
+
};
|
|
42
|
+
const join = function(...args) {
|
|
43
|
+
if (args.length === 0) {
|
|
44
|
+
return ".";
|
|
45
|
+
}
|
|
46
|
+
let joined;
|
|
47
|
+
for (let i = 0; i < args.length; ++i) {
|
|
48
|
+
const arg = args[i];
|
|
49
|
+
if (arg.length > 0) {
|
|
50
|
+
if (joined === void 0) {
|
|
51
|
+
joined = arg;
|
|
52
|
+
} else {
|
|
53
|
+
joined += `/${arg}`;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (joined === void 0) {
|
|
58
|
+
return ".";
|
|
59
|
+
}
|
|
60
|
+
return normalize(joined);
|
|
61
|
+
};
|
|
62
|
+
const resolve = function(...args) {
|
|
63
|
+
args = args.map((arg) => normalizeWindowsPath(arg));
|
|
64
|
+
let resolvedPath = "";
|
|
65
|
+
let resolvedAbsolute = false;
|
|
66
|
+
for (let i = args.length - 1; i >= -1 && !resolvedAbsolute; i--) {
|
|
67
|
+
const path2 = i >= 0 ? args[i] : process.cwd();
|
|
68
|
+
if (path2.length === 0) {
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
resolvedPath = `${path2}/${resolvedPath}`;
|
|
72
|
+
resolvedAbsolute = isAbsolute(path2);
|
|
73
|
+
}
|
|
74
|
+
resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
|
|
75
|
+
if (resolvedAbsolute && !isAbsolute(resolvedPath)) {
|
|
76
|
+
return `/${resolvedPath}`;
|
|
77
|
+
}
|
|
78
|
+
return resolvedPath.length > 0 ? resolvedPath : ".";
|
|
79
|
+
};
|
|
80
|
+
function normalizeString(path2, allowAboveRoot) {
|
|
81
|
+
let res = "";
|
|
82
|
+
let lastSegmentLength = 0;
|
|
83
|
+
let lastSlash = -1;
|
|
84
|
+
let dots = 0;
|
|
85
|
+
let char = null;
|
|
86
|
+
for (let i = 0; i <= path2.length; ++i) {
|
|
87
|
+
if (i < path2.length) {
|
|
88
|
+
char = path2[i];
|
|
89
|
+
} else if (char === "/") {
|
|
90
|
+
break;
|
|
91
|
+
} else {
|
|
92
|
+
char = "/";
|
|
93
|
+
}
|
|
94
|
+
if (char === "/") {
|
|
95
|
+
if (lastSlash === i - 1 || dots === 1) ; else if (dots === 2) {
|
|
96
|
+
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
|
97
|
+
if (res.length > 2) {
|
|
98
|
+
const lastSlashIndex = res.lastIndexOf("/");
|
|
99
|
+
if (lastSlashIndex === -1) {
|
|
100
|
+
res = "";
|
|
101
|
+
lastSegmentLength = 0;
|
|
102
|
+
} else {
|
|
103
|
+
res = res.slice(0, lastSlashIndex);
|
|
104
|
+
lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
|
|
105
|
+
}
|
|
106
|
+
lastSlash = i;
|
|
107
|
+
dots = 0;
|
|
108
|
+
continue;
|
|
109
|
+
} else if (res.length !== 0) {
|
|
110
|
+
res = "";
|
|
111
|
+
lastSegmentLength = 0;
|
|
112
|
+
lastSlash = i;
|
|
113
|
+
dots = 0;
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
if (allowAboveRoot) {
|
|
118
|
+
res += res.length > 0 ? "/.." : "..";
|
|
119
|
+
lastSegmentLength = 2;
|
|
120
|
+
}
|
|
121
|
+
} else {
|
|
122
|
+
if (res.length > 0) {
|
|
123
|
+
res += `/${path2.slice(lastSlash + 1, i)}`;
|
|
124
|
+
} else {
|
|
125
|
+
res = path2.slice(lastSlash + 1, i);
|
|
126
|
+
}
|
|
127
|
+
lastSegmentLength = i - lastSlash - 1;
|
|
128
|
+
}
|
|
129
|
+
lastSlash = i;
|
|
130
|
+
dots = 0;
|
|
131
|
+
} else if (char === "." && dots !== -1) {
|
|
132
|
+
++dots;
|
|
133
|
+
} else {
|
|
134
|
+
dots = -1;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return res;
|
|
138
|
+
}
|
|
139
|
+
const isAbsolute = function(p) {
|
|
140
|
+
return _IS_ABSOLUTE_RE.test(p);
|
|
141
|
+
};
|
|
142
|
+
const toNamespacedPath = function(p) {
|
|
143
|
+
return normalizeWindowsPath(p);
|
|
144
|
+
};
|
|
145
|
+
const extname = function(p) {
|
|
146
|
+
return path.posix.extname(normalizeWindowsPath(p));
|
|
147
|
+
};
|
|
148
|
+
const relative = function(from, to) {
|
|
149
|
+
return path.posix.relative(normalizeWindowsPath(from), normalizeWindowsPath(to));
|
|
150
|
+
};
|
|
151
|
+
const dirname = function(p) {
|
|
152
|
+
return path.posix.dirname(normalizeWindowsPath(p));
|
|
153
|
+
};
|
|
154
|
+
const format = function(p) {
|
|
155
|
+
return normalizeWindowsPath(path.posix.format(p));
|
|
156
|
+
};
|
|
157
|
+
const basename = function(p, ext) {
|
|
158
|
+
return path.posix.basename(normalizeWindowsPath(p), ext);
|
|
159
|
+
};
|
|
160
|
+
const parse = function(p) {
|
|
161
|
+
return path.posix.parse(normalizeWindowsPath(p));
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
const _path = /*#__PURE__*/Object.freeze({
|
|
165
|
+
__proto__: null,
|
|
166
|
+
sep: sep,
|
|
167
|
+
delimiter: delimiter,
|
|
168
|
+
normalize: normalize,
|
|
169
|
+
join: join,
|
|
170
|
+
resolve: resolve,
|
|
171
|
+
normalizeString: normalizeString,
|
|
172
|
+
isAbsolute: isAbsolute,
|
|
173
|
+
toNamespacedPath: toNamespacedPath,
|
|
174
|
+
extname: extname,
|
|
175
|
+
relative: relative,
|
|
176
|
+
dirname: dirname,
|
|
177
|
+
format: format,
|
|
178
|
+
basename: basename,
|
|
179
|
+
parse: parse
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
const index = {
|
|
183
|
+
..._path
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
export { resolve as a, basename as b, index as c, dirname as d, isAbsolute as i, relative as r };
|