vitest 0.0.84 → 0.0.85
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 +2 -2
- package/dist/entry.js +43 -67
- package/dist/{index-ad1b10e4.js → index-c033f95e.js} +21 -6
- package/dist/index.d.ts +2 -3
- package/dist/node.js +1 -1
- package/dist/worker.js +16 -19
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EventEmitter } from 'events';
|
|
2
2
|
import { c } from './error-c651f5ae.js';
|
|
3
|
-
import { c as createVitest } from './index-
|
|
3
|
+
import { c as createVitest } from './index-c033f95e.js';
|
|
4
4
|
import 'fs';
|
|
5
5
|
import 'path';
|
|
6
6
|
import 'tty';
|
|
@@ -631,7 +631,7 @@ class CAC extends EventEmitter {
|
|
|
631
631
|
|
|
632
632
|
const cac = (name = "") => new CAC(name);
|
|
633
633
|
|
|
634
|
-
var version = "0.0.
|
|
634
|
+
var version = "0.0.85";
|
|
635
635
|
|
|
636
636
|
const cli = cac("vitest");
|
|
637
637
|
cli.version(version).option("-r, --root <path>", "root path").option("-c, --config <path>", "path to config file").option("-u, --update", "update snapshot").option("-w, --watch", "watch mode").option("-o, --open", "open Vitest UI").option("--api", "listen to port and serve API").option("--threads", "enabled threads", { default: true }).option("--silent", "silent").option("--global", "inject apis globally").option("--dom", "mock browser api with happy-dom").option("--environment <env>", "runner environment", {
|
package/dist/entry.js
CHANGED
|
@@ -3106,42 +3106,34 @@ function isAsymmetric(obj) {
|
|
|
3106
3106
|
return !!obj && isA("Function", obj.asymmetricMatch);
|
|
3107
3107
|
}
|
|
3108
3108
|
function asymmetricMatch(a, b) {
|
|
3109
|
-
|
|
3110
|
-
|
|
3109
|
+
const asymmetricA = isAsymmetric(a);
|
|
3110
|
+
const asymmetricB = isAsymmetric(b);
|
|
3111
|
+
if (asymmetricA && asymmetricB)
|
|
3111
3112
|
return void 0;
|
|
3112
|
-
|
|
3113
|
-
if (asymmetricA) {
|
|
3113
|
+
if (asymmetricA)
|
|
3114
3114
|
return a.asymmetricMatch(b);
|
|
3115
|
-
|
|
3116
|
-
if (asymmetricB) {
|
|
3115
|
+
if (asymmetricB)
|
|
3117
3116
|
return b.asymmetricMatch(a);
|
|
3118
|
-
}
|
|
3119
3117
|
}
|
|
3120
3118
|
function eq(a, b, aStack, bStack, customTesters, hasKey2) {
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
if (asymmetricResult !== void 0)
|
|
3119
|
+
let result = true;
|
|
3120
|
+
const asymmetricResult = asymmetricMatch(a, b);
|
|
3121
|
+
if (asymmetricResult !== void 0)
|
|
3124
3122
|
return asymmetricResult;
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
if (customTesterResult !== void 0) {
|
|
3123
|
+
for (let i = 0; i < customTesters.length; i++) {
|
|
3124
|
+
const customTesterResult = customTesters[i](a, b);
|
|
3125
|
+
if (customTesterResult !== void 0)
|
|
3129
3126
|
return customTesterResult;
|
|
3130
|
-
}
|
|
3131
|
-
}
|
|
3132
|
-
if (a instanceof Error && b instanceof Error) {
|
|
3133
|
-
return a.message == b.message;
|
|
3134
3127
|
}
|
|
3135
|
-
if (
|
|
3128
|
+
if (a instanceof Error && b instanceof Error)
|
|
3129
|
+
return a.message === b.message;
|
|
3130
|
+
if (Object.is(a, b))
|
|
3136
3131
|
return true;
|
|
3137
|
-
|
|
3138
|
-
if (a === null || b === null) {
|
|
3132
|
+
if (a === null || b === null)
|
|
3139
3133
|
return a === b;
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
if (className != Object.prototype.toString.call(b)) {
|
|
3134
|
+
const className = Object.prototype.toString.call(a);
|
|
3135
|
+
if (className !== Object.prototype.toString.call(b))
|
|
3143
3136
|
return false;
|
|
3144
|
-
}
|
|
3145
3137
|
switch (className) {
|
|
3146
3138
|
case "[object Boolean]":
|
|
3147
3139
|
case "[object String]":
|
|
@@ -3154,51 +3146,45 @@ function eq(a, b, aStack, bStack, customTesters, hasKey2) {
|
|
|
3154
3146
|
return Object.is(a.valueOf(), b.valueOf());
|
|
3155
3147
|
}
|
|
3156
3148
|
case "[object Date]":
|
|
3157
|
-
return +a
|
|
3149
|
+
return +a === +b;
|
|
3158
3150
|
case "[object RegExp]":
|
|
3159
3151
|
return a.source === b.source && a.flags === b.flags;
|
|
3160
3152
|
}
|
|
3161
|
-
if (typeof a !== "object" || typeof b !== "object")
|
|
3153
|
+
if (typeof a !== "object" || typeof b !== "object")
|
|
3162
3154
|
return false;
|
|
3163
|
-
|
|
3164
|
-
if (isDomNode(a) && isDomNode(b)) {
|
|
3155
|
+
if (isDomNode(a) && isDomNode(b))
|
|
3165
3156
|
return a.isEqualNode(b);
|
|
3166
|
-
|
|
3167
|
-
var length = aStack.length;
|
|
3157
|
+
let length = aStack.length;
|
|
3168
3158
|
while (length--) {
|
|
3169
|
-
if (aStack[length] === a)
|
|
3159
|
+
if (aStack[length] === a)
|
|
3170
3160
|
return bStack[length] === b;
|
|
3171
|
-
|
|
3161
|
+
else if (bStack[length] === b)
|
|
3172
3162
|
return false;
|
|
3173
|
-
}
|
|
3174
3163
|
}
|
|
3175
3164
|
aStack.push(a);
|
|
3176
3165
|
bStack.push(b);
|
|
3177
|
-
if (className
|
|
3166
|
+
if (className === "[object Array]" && a.length !== b.length)
|
|
3178
3167
|
return false;
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
if (keys(b, hasKey2).length !== size)
|
|
3168
|
+
const aKeys = keys(a, hasKey2);
|
|
3169
|
+
let key;
|
|
3170
|
+
let size = aKeys.length;
|
|
3171
|
+
if (keys(b, hasKey2).length !== size)
|
|
3183
3172
|
return false;
|
|
3184
|
-
}
|
|
3185
3173
|
while (size--) {
|
|
3186
3174
|
key = aKeys[size];
|
|
3187
3175
|
result = hasKey2(b, key) && eq(a[key], b[key], aStack, bStack, customTesters, hasKey2);
|
|
3188
|
-
if (!result)
|
|
3176
|
+
if (!result)
|
|
3189
3177
|
return false;
|
|
3190
|
-
}
|
|
3191
3178
|
}
|
|
3192
3179
|
aStack.pop();
|
|
3193
3180
|
bStack.pop();
|
|
3194
3181
|
return result;
|
|
3195
3182
|
}
|
|
3196
3183
|
function keys(obj, hasKey2) {
|
|
3197
|
-
|
|
3198
|
-
for (
|
|
3199
|
-
if (hasKey2(obj, key))
|
|
3184
|
+
const keys2 = [];
|
|
3185
|
+
for (const key in obj) {
|
|
3186
|
+
if (hasKey2(obj, key))
|
|
3200
3187
|
keys2.push(key);
|
|
3201
|
-
}
|
|
3202
3188
|
}
|
|
3203
3189
|
return keys2.concat(Object.getOwnPropertySymbols(obj).filter((symbol) => Object.getOwnPropertyDescriptor(obj, symbol).enumerable));
|
|
3204
3190
|
}
|
|
@@ -3209,7 +3195,7 @@ function hasKey(obj, key) {
|
|
|
3209
3195
|
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
3210
3196
|
}
|
|
3211
3197
|
function isA(typeName, value) {
|
|
3212
|
-
return Object.prototype.toString.apply(value) ===
|
|
3198
|
+
return Object.prototype.toString.apply(value) === `[object ${typeName}]`;
|
|
3213
3199
|
}
|
|
3214
3200
|
function isDomNode(obj) {
|
|
3215
3201
|
return obj !== null && typeof obj === "object" && typeof obj.nodeType === "number" && typeof obj.nodeName === "string" && typeof obj.isEqualNode === "function";
|
|
@@ -3226,17 +3212,14 @@ function isImmutableUnorderedSet(maybeSet) {
|
|
|
3226
3212
|
const IteratorSymbol = Symbol.iterator;
|
|
3227
3213
|
const hasIterator = (object) => !!(object != null && object[IteratorSymbol]);
|
|
3228
3214
|
const iterableEquality = (a, b, aStack = [], bStack = []) => {
|
|
3229
|
-
if (typeof a !== "object" || typeof b !== "object" || Array.isArray(a) || Array.isArray(b) || !hasIterator(a) || !hasIterator(b))
|
|
3215
|
+
if (typeof a !== "object" || typeof b !== "object" || Array.isArray(a) || Array.isArray(b) || !hasIterator(a) || !hasIterator(b))
|
|
3230
3216
|
return void 0;
|
|
3231
|
-
|
|
3232
|
-
if (a.constructor !== b.constructor) {
|
|
3217
|
+
if (a.constructor !== b.constructor)
|
|
3233
3218
|
return false;
|
|
3234
|
-
}
|
|
3235
3219
|
let length = aStack.length;
|
|
3236
3220
|
while (length--) {
|
|
3237
|
-
if (aStack[length] === a)
|
|
3221
|
+
if (aStack[length] === a)
|
|
3238
3222
|
return bStack[length] === b;
|
|
3239
|
-
}
|
|
3240
3223
|
}
|
|
3241
3224
|
aStack.push(a);
|
|
3242
3225
|
bStack.push(b);
|
|
@@ -3251,9 +3234,8 @@ const iterableEquality = (a, b, aStack = [], bStack = []) => {
|
|
|
3251
3234
|
let has = false;
|
|
3252
3235
|
for (const bValue of b) {
|
|
3253
3236
|
const isEqual = equals(aValue, bValue, [iterableEqualityWithStack]);
|
|
3254
|
-
if (isEqual === true)
|
|
3237
|
+
if (isEqual === true)
|
|
3255
3238
|
has = true;
|
|
3256
|
-
}
|
|
3257
3239
|
}
|
|
3258
3240
|
if (has === false) {
|
|
3259
3241
|
allFound = false;
|
|
@@ -3279,9 +3261,8 @@ const iterableEquality = (a, b, aStack = [], bStack = []) => {
|
|
|
3279
3261
|
iterableEqualityWithStack
|
|
3280
3262
|
]);
|
|
3281
3263
|
}
|
|
3282
|
-
if (matchedValue === true)
|
|
3264
|
+
if (matchedValue === true)
|
|
3283
3265
|
has = true;
|
|
3284
|
-
}
|
|
3285
3266
|
}
|
|
3286
3267
|
if (has === false) {
|
|
3287
3268
|
allFound = false;
|
|
@@ -3297,35 +3278,30 @@ const iterableEquality = (a, b, aStack = [], bStack = []) => {
|
|
|
3297
3278
|
const bIterator = b[IteratorSymbol]();
|
|
3298
3279
|
for (const aValue of a) {
|
|
3299
3280
|
const nextB = bIterator.next();
|
|
3300
|
-
if (nextB.done || !equals(aValue, nextB.value, [iterableEqualityWithStack]))
|
|
3281
|
+
if (nextB.done || !equals(aValue, nextB.value, [iterableEqualityWithStack]))
|
|
3301
3282
|
return false;
|
|
3302
|
-
}
|
|
3303
3283
|
}
|
|
3304
|
-
if (!bIterator.next().done)
|
|
3284
|
+
if (!bIterator.next().done)
|
|
3305
3285
|
return false;
|
|
3306
|
-
}
|
|
3307
3286
|
aStack.pop();
|
|
3308
3287
|
bStack.pop();
|
|
3309
3288
|
return true;
|
|
3310
3289
|
};
|
|
3311
3290
|
const hasPropertyInObject = (object, key) => {
|
|
3312
3291
|
const shouldTerminate = !object || typeof object !== "object" || object === Object.prototype;
|
|
3313
|
-
if (shouldTerminate)
|
|
3292
|
+
if (shouldTerminate)
|
|
3314
3293
|
return false;
|
|
3315
|
-
}
|
|
3316
3294
|
return Object.prototype.hasOwnProperty.call(object, key) || hasPropertyInObject(Object.getPrototypeOf(object), key);
|
|
3317
3295
|
};
|
|
3318
3296
|
const isObjectWithKeys = (a) => isObject(a) && !(a instanceof Error) && !(a instanceof Array) && !(a instanceof Date);
|
|
3319
3297
|
const subsetEquality = (object, subset) => {
|
|
3320
3298
|
const subsetEqualityWithContext = (seenReferences = new WeakMap()) => (object2, subset2) => {
|
|
3321
|
-
if (!isObjectWithKeys(subset2))
|
|
3299
|
+
if (!isObjectWithKeys(subset2))
|
|
3322
3300
|
return void 0;
|
|
3323
|
-
}
|
|
3324
3301
|
return Object.keys(subset2).every((key) => {
|
|
3325
3302
|
if (isObjectWithKeys(subset2[key])) {
|
|
3326
|
-
if (seenReferences.has(subset2[key]))
|
|
3303
|
+
if (seenReferences.has(subset2[key]))
|
|
3327
3304
|
return equals(object2[key], subset2[key], [iterableEquality]);
|
|
3328
|
-
}
|
|
3329
3305
|
seenReferences.set(subset2[key], true);
|
|
3330
3306
|
}
|
|
3331
3307
|
const result = object2 != null && hasPropertyInObject(object2, key) && equals(object2[key], subset2[key], [
|
|
@@ -1576,14 +1576,29 @@ function resolveConfig(options, viteConfig) {
|
|
|
1576
1576
|
}
|
|
1577
1577
|
|
|
1578
1578
|
async function transformRequest(server, id) {
|
|
1579
|
+
let result = null;
|
|
1579
1580
|
if (id.match(/\.(?:[cm]?[jt]sx?|json)$/)) {
|
|
1580
|
-
|
|
1581
|
+
result = await server.transformRequest(id, { ssr: true });
|
|
1581
1582
|
} else {
|
|
1582
|
-
|
|
1583
|
-
if (
|
|
1584
|
-
|
|
1585
|
-
return await server.ssrTransform(result.code, result.map, id);
|
|
1583
|
+
result = await server.transformRequest(id);
|
|
1584
|
+
if (result)
|
|
1585
|
+
result = await server.ssrTransform(result.code, result.map, id);
|
|
1586
1586
|
}
|
|
1587
|
+
if (result && process.env.NODE_V8_COVERAGE)
|
|
1588
|
+
withInlineSourcemap(result);
|
|
1589
|
+
return result;
|
|
1590
|
+
}
|
|
1591
|
+
let SOURCEMAPPING_URL = "sourceMa";
|
|
1592
|
+
SOURCEMAPPING_URL += "ppingURL";
|
|
1593
|
+
async function withInlineSourcemap(result) {
|
|
1594
|
+
const { code, map } = result;
|
|
1595
|
+
if (code.includes(`${SOURCEMAPPING_URL}=`))
|
|
1596
|
+
return result;
|
|
1597
|
+
if (map)
|
|
1598
|
+
result.code = `${code}
|
|
1599
|
+
|
|
1600
|
+
//# ${SOURCEMAPPING_URL}=data:application/json;charset=utf-8;base64,${Buffer.from(JSON.stringify(map), "utf-8").toString("base64")}`;
|
|
1601
|
+
return result;
|
|
1587
1602
|
}
|
|
1588
1603
|
|
|
1589
1604
|
function createPool(ctx) {
|
|
@@ -1661,7 +1676,7 @@ function createChannel(ctx) {
|
|
|
1661
1676
|
case "snapshotSaved":
|
|
1662
1677
|
return send(() => ctx.snapshot.add(args[0]));
|
|
1663
1678
|
case "fetch":
|
|
1664
|
-
return send(() => transformRequest(ctx.server, ...args));
|
|
1679
|
+
return send(() => transformRequest(ctx.server, ...args).then((r) => r == null ? void 0 : r.code));
|
|
1665
1680
|
case "onCollected":
|
|
1666
1681
|
ctx.state.collectFiles(args[0]);
|
|
1667
1682
|
ctx.reporters.forEach((r) => {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Formatter } from 'picocolors/types';
|
|
2
|
-
import { TransformResult } from 'vite';
|
|
3
2
|
import { OptionsReceived } from 'pretty-format';
|
|
4
3
|
import { MessagePort } from 'worker_threads';
|
|
5
4
|
export { assert, default as chai, expect, should } from 'chai';
|
|
@@ -117,7 +116,7 @@ declare type ArgumentsType<T> = T extends (...args: infer U) => any ? U : never;
|
|
|
117
116
|
interface ModuleCache {
|
|
118
117
|
promise?: Promise<any>;
|
|
119
118
|
exports?: any;
|
|
120
|
-
|
|
119
|
+
code?: string;
|
|
121
120
|
}
|
|
122
121
|
interface EnvironmentReturn {
|
|
123
122
|
teardown: (global: any) => Awaitable<void>;
|
|
@@ -420,7 +419,7 @@ interface WorkerContext {
|
|
|
420
419
|
invalidates?: string[];
|
|
421
420
|
}
|
|
422
421
|
interface RpcMap {
|
|
423
|
-
fetch: [[id: string],
|
|
422
|
+
fetch: [[id: string], string | undefined];
|
|
424
423
|
log: [[UserConsoleLog], void];
|
|
425
424
|
processExit: [[code?: number], void];
|
|
426
425
|
onCollected: [[files: File[]], void];
|
package/dist/node.js
CHANGED
package/dist/worker.js
CHANGED
|
@@ -19,7 +19,8 @@ const defaultInline = [
|
|
|
19
19
|
/\.(es|esm|esm-browser|esm-bundler|es6).js$/
|
|
20
20
|
];
|
|
21
21
|
const depsExternal = [
|
|
22
|
-
/\.cjs.js
|
|
22
|
+
/\.cjs.js$/,
|
|
23
|
+
/\.mjs$/
|
|
23
24
|
];
|
|
24
25
|
const isWindows = process.platform === "win32";
|
|
25
26
|
const stubRequests = {
|
|
@@ -54,18 +55,6 @@ async function interpretedImport(path, interpretDefault) {
|
|
|
54
55
|
}
|
|
55
56
|
return mod;
|
|
56
57
|
}
|
|
57
|
-
let SOURCEMAPPING_URL = "sourceMa";
|
|
58
|
-
SOURCEMAPPING_URL += "ppingURL";
|
|
59
|
-
async function withInlineSourcemap(result) {
|
|
60
|
-
const { code, map } = result;
|
|
61
|
-
if (code.includes(`${SOURCEMAPPING_URL}=`))
|
|
62
|
-
return result;
|
|
63
|
-
if (map)
|
|
64
|
-
result.code = `${code}
|
|
65
|
-
|
|
66
|
-
//# ${SOURCEMAPPING_URL}=data:application/json;charset=utf-8;base64,${Buffer.from(JSON.stringify(map), "utf-8").toString("base64")}`;
|
|
67
|
-
return result;
|
|
68
|
-
}
|
|
69
58
|
async function executeInViteNode(options) {
|
|
70
59
|
const { moduleCache, root, files, fetch } = options;
|
|
71
60
|
const externaled = new Set(builtinModules);
|
|
@@ -89,18 +78,26 @@ ${[...callstack, dep].reverse().map((p) => `- ${p}`).join("\n")}`);
|
|
|
89
78
|
};
|
|
90
79
|
if (id in stubRequests)
|
|
91
80
|
return stubRequests[id];
|
|
92
|
-
const
|
|
93
|
-
if (!
|
|
81
|
+
const transformed = await fetch(id);
|
|
82
|
+
if (!transformed)
|
|
94
83
|
throw new Error(`failed to load ${id}`);
|
|
95
|
-
if (process.env.NODE_V8_COVERAGE)
|
|
96
|
-
withInlineSourcemap(result2);
|
|
97
84
|
const url = pathToFileURL(fsPath).href;
|
|
98
85
|
const exports = {};
|
|
99
|
-
setCache(fsPath, {
|
|
86
|
+
setCache(fsPath, { code: transformed, exports });
|
|
100
87
|
const __filename = fileURLToPath(url);
|
|
88
|
+
const moduleProxy = {
|
|
89
|
+
set exports(value) {
|
|
90
|
+
exportAll(exports, value);
|
|
91
|
+
exports.default = value;
|
|
92
|
+
},
|
|
93
|
+
get exports() {
|
|
94
|
+
return exports.default;
|
|
95
|
+
}
|
|
96
|
+
};
|
|
101
97
|
const context = {
|
|
102
98
|
require: createRequire(url),
|
|
103
99
|
exports,
|
|
100
|
+
module: moduleProxy,
|
|
104
101
|
__filename,
|
|
105
102
|
__dirname: dirname(__filename),
|
|
106
103
|
__vite_ssr_import__: request,
|
|
@@ -109,7 +106,7 @@ ${[...callstack, dep].reverse().map((p) => `- ${p}`).join("\n")}`);
|
|
|
109
106
|
__vite_ssr_exportAll__: (obj) => exportAll(exports, obj),
|
|
110
107
|
__vite_ssr_import_meta__: { url }
|
|
111
108
|
};
|
|
112
|
-
const fn = vm.runInThisContext(`async (${Object.keys(context).join(",")})=>{${
|
|
109
|
+
const fn = vm.runInThisContext(`async (${Object.keys(context).join(",")})=>{${transformed}
|
|
113
110
|
}`, {
|
|
114
111
|
filename: fsPath,
|
|
115
112
|
lineOffset: 0
|