vitest 0.19.1 → 0.20.2
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/browser.d.ts +48 -3
- package/dist/browser.mjs +9 -7
- package/dist/{chunk-api-setup.0cf2c96a.mjs → chunk-api-setup.7c4c8879.mjs} +7 -6
- package/dist/{chunk-constants.38b43a44.mjs → chunk-constants.16825f0c.mjs} +3 -2
- package/dist/{chunk-defaults.ed196a9a.mjs → chunk-defaults.1c51d585.mjs} +6 -4
- package/dist/chunk-integrations-globals.56a11010.mjs +26 -0
- package/dist/{chunk-utils-global.2aa95025.mjs → chunk-mock-date.9160e13b.mjs} +6 -36
- package/dist/{chunk-node-git.9058b82a.mjs → chunk-node-git.43dbdd42.mjs} +1 -1
- package/dist/{chunk-runtime-chain.f2e00f4c.mjs → chunk-runtime-chain.b6c2cdbc.mjs} +5 -3
- package/dist/{chunk-runtime-error.606e0393.mjs → chunk-runtime-error.0aa0dc06.mjs} +17 -13
- package/dist/{chunk-runtime-hooks.d4cadf47.mjs → chunk-runtime-hooks.3ee34848.mjs} +7 -4
- package/dist/{chunk-runtime-mocker.dfdfd57b.mjs → chunk-runtime-mocker.0a8f7c5e.mjs} +23 -17
- package/dist/{chunk-runtime-rpc.45d8ee19.mjs → chunk-runtime-rpc.dbf0b31d.mjs} +3 -1
- package/dist/chunk-utils-global.fa20c2f6.mjs +5 -0
- package/dist/{chunk-utils-source-map.8b066ce2.mjs → chunk-utils-source-map.8198ebd9.mjs} +1 -1
- package/dist/chunk-utils-timers.b48455ed.mjs +27 -0
- package/dist/chunk-vite-node-client.a247c2c2.mjs +320 -0
- package/dist/chunk-vite-node-debug.c5887932.mjs +76 -0
- package/dist/{chunk-vite-node-externalize.e9af6472.mjs → chunk-vite-node-externalize.45323563.mjs} +76 -22
- package/dist/{chunk-vite-node-utils.ad73f2ab.mjs → chunk-vite-node-utils.9dfd1e3f.mjs} +4 -323
- package/dist/cli.mjs +9 -7
- package/dist/config.cjs +3 -2
- package/dist/config.d.ts +1 -0
- package/dist/config.mjs +3 -2
- package/dist/entry.mjs +10 -8
- package/dist/index.d.ts +49 -4
- package/dist/index.mjs +7 -5
- package/dist/loader.mjs +36 -0
- package/dist/node.d.ts +49 -3
- package/dist/node.mjs +10 -7
- package/dist/suite.mjs +6 -4
- package/dist/worker.mjs +9 -6
- package/package.json +6 -5
- package/suppress-warnings.cjs +20 -0
- package/dist/chunk-integrations-globals.1018e651.mjs +0 -24
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import { builtinModules
|
|
2
|
-
import { pathToFileURL, fileURLToPath as fileURLToPath$1, URL as URL$1 } from 'url';
|
|
3
|
-
import vm from 'vm';
|
|
4
|
-
import { C as resolve$1, d as dirname, F as isAbsolute$1, S as extname$1 } from './chunk-utils-global.2aa95025.mjs';
|
|
1
|
+
import { builtinModules } from 'module';
|
|
5
2
|
import path from 'path';
|
|
3
|
+
import { pathToFileURL, fileURLToPath as fileURLToPath$1, URL as URL$1 } from 'url';
|
|
6
4
|
import fs, { promises, statSync, existsSync, realpathSync, Stats } from 'fs';
|
|
7
5
|
import assert from 'assert';
|
|
8
6
|
import { format, inspect } from 'util';
|
|
9
|
-
import
|
|
7
|
+
import { y as resolve$1 } from './chunk-mock-date.9160e13b.mjs';
|
|
10
8
|
|
|
11
9
|
function normalizeWindowsPath(input = "") {
|
|
12
10
|
if (!input.includes("\\")) {
|
|
@@ -1113,321 +1111,4 @@ function toArray(array) {
|
|
|
1113
1111
|
return [array];
|
|
1114
1112
|
}
|
|
1115
1113
|
|
|
1116
|
-
|
|
1117
|
-
const debugNative = createDebug("vite-node:client:native");
|
|
1118
|
-
const DEFAULT_REQUEST_STUBS = {
|
|
1119
|
-
"/@vite/client": {
|
|
1120
|
-
injectQuery: (id) => id,
|
|
1121
|
-
createHotContext() {
|
|
1122
|
-
return {
|
|
1123
|
-
accept: () => {
|
|
1124
|
-
},
|
|
1125
|
-
prune: () => {
|
|
1126
|
-
},
|
|
1127
|
-
dispose: () => {
|
|
1128
|
-
},
|
|
1129
|
-
decline: () => {
|
|
1130
|
-
},
|
|
1131
|
-
invalidate: () => {
|
|
1132
|
-
},
|
|
1133
|
-
on: () => {
|
|
1134
|
-
}
|
|
1135
|
-
};
|
|
1136
|
-
},
|
|
1137
|
-
updateStyle(id, css) {
|
|
1138
|
-
if (typeof document === "undefined")
|
|
1139
|
-
return;
|
|
1140
|
-
const element = document.getElementById(id);
|
|
1141
|
-
if (element)
|
|
1142
|
-
element.remove();
|
|
1143
|
-
const head = document.querySelector("head");
|
|
1144
|
-
const style = document.createElement("style");
|
|
1145
|
-
style.setAttribute("type", "text/css");
|
|
1146
|
-
style.id = id;
|
|
1147
|
-
style.innerHTML = css;
|
|
1148
|
-
head == null ? void 0 : head.appendChild(style);
|
|
1149
|
-
}
|
|
1150
|
-
}
|
|
1151
|
-
};
|
|
1152
|
-
class ModuleCacheMap extends Map {
|
|
1153
|
-
normalizePath(fsPath) {
|
|
1154
|
-
return normalizeModuleId(fsPath);
|
|
1155
|
-
}
|
|
1156
|
-
set(fsPath, mod) {
|
|
1157
|
-
fsPath = this.normalizePath(fsPath);
|
|
1158
|
-
if (!super.has(fsPath))
|
|
1159
|
-
super.set(fsPath, mod);
|
|
1160
|
-
else
|
|
1161
|
-
Object.assign(super.get(fsPath), mod);
|
|
1162
|
-
return this;
|
|
1163
|
-
}
|
|
1164
|
-
get(fsPath) {
|
|
1165
|
-
fsPath = this.normalizePath(fsPath);
|
|
1166
|
-
return super.get(fsPath);
|
|
1167
|
-
}
|
|
1168
|
-
delete(fsPath) {
|
|
1169
|
-
fsPath = this.normalizePath(fsPath);
|
|
1170
|
-
return super.delete(fsPath);
|
|
1171
|
-
}
|
|
1172
|
-
}
|
|
1173
|
-
class ViteNodeRunner {
|
|
1174
|
-
constructor(options) {
|
|
1175
|
-
this.options = options;
|
|
1176
|
-
this.root = options.root ?? process.cwd();
|
|
1177
|
-
this.moduleCache = options.moduleCache ?? new ModuleCacheMap();
|
|
1178
|
-
this.debug = options.debug ?? (typeof process !== "undefined" ? !!process.env.VITE_NODE_DEBUG : false);
|
|
1179
|
-
}
|
|
1180
|
-
async executeFile(file) {
|
|
1181
|
-
return await this.cachedRequest(`/@fs/${slash(resolve$1(file))}`, []);
|
|
1182
|
-
}
|
|
1183
|
-
async executeId(id) {
|
|
1184
|
-
return await this.cachedRequest(id, []);
|
|
1185
|
-
}
|
|
1186
|
-
async cachedRequest(rawId, callstack) {
|
|
1187
|
-
var _a, _b, _c, _d;
|
|
1188
|
-
const id = normalizeRequestId(rawId, this.options.base);
|
|
1189
|
-
const fsPath = toFilePath(id, this.root);
|
|
1190
|
-
if (callstack.includes(fsPath) && ((_a = this.moduleCache.get(fsPath)) == null ? void 0 : _a.exports))
|
|
1191
|
-
return (_b = this.moduleCache.get(fsPath)) == null ? void 0 : _b.exports;
|
|
1192
|
-
if ((_c = this.moduleCache.get(fsPath)) == null ? void 0 : _c.promise)
|
|
1193
|
-
return (_d = this.moduleCache.get(fsPath)) == null ? void 0 : _d.promise;
|
|
1194
|
-
const promise = this.directRequest(id, fsPath, callstack);
|
|
1195
|
-
this.moduleCache.set(fsPath, { promise });
|
|
1196
|
-
return await promise;
|
|
1197
|
-
}
|
|
1198
|
-
async directRequest(id, fsPath, _callstack) {
|
|
1199
|
-
const callstack = [..._callstack, fsPath];
|
|
1200
|
-
const request = async (dep) => {
|
|
1201
|
-
var _a;
|
|
1202
|
-
const fsPath2 = toFilePath(normalizeRequestId(dep, this.options.base), this.root);
|
|
1203
|
-
const getStack = () => {
|
|
1204
|
-
return `stack:
|
|
1205
|
-
${[...callstack, fsPath2].reverse().map((p) => `- ${p}`).join("\n")}`;
|
|
1206
|
-
};
|
|
1207
|
-
let debugTimer;
|
|
1208
|
-
if (this.debug)
|
|
1209
|
-
debugTimer = setTimeout(() => this.debugLog(() => `module ${fsPath2} takes over 2s to load.
|
|
1210
|
-
${getStack()}`), 2e3);
|
|
1211
|
-
try {
|
|
1212
|
-
if (callstack.includes(fsPath2)) {
|
|
1213
|
-
this.debugLog(() => `circular dependency, ${getStack()}`);
|
|
1214
|
-
const depExports = (_a = this.moduleCache.get(fsPath2)) == null ? void 0 : _a.exports;
|
|
1215
|
-
if (depExports)
|
|
1216
|
-
return depExports;
|
|
1217
|
-
throw new Error(`[vite-node] Failed to resolve circular dependency, ${getStack()}`);
|
|
1218
|
-
}
|
|
1219
|
-
const mod = await this.cachedRequest(dep, callstack);
|
|
1220
|
-
return mod;
|
|
1221
|
-
} finally {
|
|
1222
|
-
if (debugTimer)
|
|
1223
|
-
clearTimeout(debugTimer);
|
|
1224
|
-
}
|
|
1225
|
-
};
|
|
1226
|
-
Object.defineProperty(request, "callstack", { get: () => callstack });
|
|
1227
|
-
const resolveId = async (dep, callstackPosition = 1) => {
|
|
1228
|
-
if (this.options.resolveId && this.shouldResolveId(dep)) {
|
|
1229
|
-
let importer = callstack[callstack.length - callstackPosition];
|
|
1230
|
-
if (importer && importer.startsWith("mock:"))
|
|
1231
|
-
importer = importer.slice(5);
|
|
1232
|
-
const { id: id2 } = await this.options.resolveId(dep, importer) || {};
|
|
1233
|
-
dep = id2 && isAbsolute$1(id2) ? mergeSlashes(`/@fs/${id2}`) : id2 || dep;
|
|
1234
|
-
}
|
|
1235
|
-
return dep;
|
|
1236
|
-
};
|
|
1237
|
-
id = await resolveId(id, 2);
|
|
1238
|
-
const requestStubs = this.options.requestStubs || DEFAULT_REQUEST_STUBS;
|
|
1239
|
-
if (id in requestStubs)
|
|
1240
|
-
return requestStubs[id];
|
|
1241
|
-
let { code: transformed, externalize } = await this.options.fetchModule(id);
|
|
1242
|
-
if (externalize) {
|
|
1243
|
-
debugNative(externalize);
|
|
1244
|
-
const mod = await this.interopedImport(externalize);
|
|
1245
|
-
this.moduleCache.set(fsPath, { exports: mod });
|
|
1246
|
-
return mod;
|
|
1247
|
-
}
|
|
1248
|
-
if (transformed == null)
|
|
1249
|
-
throw new Error(`[vite-node] Failed to load ${id}`);
|
|
1250
|
-
const url = pathToFileURL(fsPath).href;
|
|
1251
|
-
const meta = { url };
|
|
1252
|
-
const exports = /* @__PURE__ */ Object.create(null);
|
|
1253
|
-
exports[Symbol.toStringTag] = "Module";
|
|
1254
|
-
this.moduleCache.set(fsPath, { code: transformed, exports });
|
|
1255
|
-
const __filename = fileURLToPath$1(url);
|
|
1256
|
-
const moduleProxy = {
|
|
1257
|
-
set exports(value) {
|
|
1258
|
-
exportAll(exports, value);
|
|
1259
|
-
exports.default = value;
|
|
1260
|
-
},
|
|
1261
|
-
get exports() {
|
|
1262
|
-
return exports;
|
|
1263
|
-
}
|
|
1264
|
-
};
|
|
1265
|
-
let hotContext;
|
|
1266
|
-
if (this.options.createHotContext) {
|
|
1267
|
-
Object.defineProperty(meta, "hot", {
|
|
1268
|
-
enumerable: true,
|
|
1269
|
-
get: () => {
|
|
1270
|
-
var _a, _b;
|
|
1271
|
-
hotContext || (hotContext = (_b = (_a = this.options).createHotContext) == null ? void 0 : _b.call(_a, this, `/@fs/${fsPath}`));
|
|
1272
|
-
return hotContext;
|
|
1273
|
-
}
|
|
1274
|
-
});
|
|
1275
|
-
}
|
|
1276
|
-
const context = this.prepareContext({
|
|
1277
|
-
__vite_ssr_import__: request,
|
|
1278
|
-
__vite_ssr_dynamic_import__: request,
|
|
1279
|
-
__vite_ssr_exports__: exports,
|
|
1280
|
-
__vite_ssr_exportAll__: (obj) => exportAll(exports, obj),
|
|
1281
|
-
__vite_ssr_import_meta__: meta,
|
|
1282
|
-
__vitest_resolve_id__: resolveId,
|
|
1283
|
-
require: createRequire(url),
|
|
1284
|
-
exports,
|
|
1285
|
-
module: moduleProxy,
|
|
1286
|
-
__filename,
|
|
1287
|
-
__dirname: dirname(__filename)
|
|
1288
|
-
});
|
|
1289
|
-
debugExecute(__filename);
|
|
1290
|
-
if (transformed[0] === "#")
|
|
1291
|
-
transformed = transformed.replace(/^\#\!.*/, (s) => " ".repeat(s.length));
|
|
1292
|
-
const fn = vm.runInThisContext(`'use strict';async (${Object.keys(context).join(",")})=>{{${transformed}
|
|
1293
|
-
}}`, {
|
|
1294
|
-
filename: fsPath,
|
|
1295
|
-
lineOffset: 0
|
|
1296
|
-
});
|
|
1297
|
-
await fn(...Object.values(context));
|
|
1298
|
-
return exports;
|
|
1299
|
-
}
|
|
1300
|
-
prepareContext(context) {
|
|
1301
|
-
return context;
|
|
1302
|
-
}
|
|
1303
|
-
shouldResolveId(dep) {
|
|
1304
|
-
if (isNodeBuiltin(dep) || dep in (this.options.requestStubs || DEFAULT_REQUEST_STUBS) || dep.startsWith("/@vite"))
|
|
1305
|
-
return false;
|
|
1306
|
-
return !isAbsolute$1(dep) || !extname$1(dep);
|
|
1307
|
-
}
|
|
1308
|
-
shouldInterop(path, mod) {
|
|
1309
|
-
if (this.options.interopDefault === false)
|
|
1310
|
-
return false;
|
|
1311
|
-
return !path.endsWith(".mjs") && "default" in mod;
|
|
1312
|
-
}
|
|
1313
|
-
async interopedImport(path) {
|
|
1314
|
-
const mod = await import(path);
|
|
1315
|
-
if (this.shouldInterop(path, mod)) {
|
|
1316
|
-
const tryDefault = this.hasNestedDefault(mod);
|
|
1317
|
-
return new Proxy(mod, {
|
|
1318
|
-
get: proxyMethod("get", tryDefault),
|
|
1319
|
-
set: proxyMethod("set", tryDefault),
|
|
1320
|
-
has: proxyMethod("has", tryDefault),
|
|
1321
|
-
deleteProperty: proxyMethod("deleteProperty", tryDefault)
|
|
1322
|
-
});
|
|
1323
|
-
}
|
|
1324
|
-
return mod;
|
|
1325
|
-
}
|
|
1326
|
-
hasNestedDefault(target) {
|
|
1327
|
-
return "__esModule" in target && target.__esModule && "default" in target.default;
|
|
1328
|
-
}
|
|
1329
|
-
debugLog(msg) {
|
|
1330
|
-
if (this.debug)
|
|
1331
|
-
console.log(`[vite-node] ${msg()}`);
|
|
1332
|
-
}
|
|
1333
|
-
}
|
|
1334
|
-
function proxyMethod(name, tryDefault) {
|
|
1335
|
-
return function(target, key, ...args) {
|
|
1336
|
-
const result = Reflect[name](target, key, ...args);
|
|
1337
|
-
if (isPrimitive(target.default))
|
|
1338
|
-
return result;
|
|
1339
|
-
if (tryDefault && key === "default" || typeof result === "undefined")
|
|
1340
|
-
return Reflect[name](target.default, key, ...args);
|
|
1341
|
-
return result;
|
|
1342
|
-
};
|
|
1343
|
-
}
|
|
1344
|
-
function exportAll(exports, sourceModule) {
|
|
1345
|
-
if (exports === sourceModule)
|
|
1346
|
-
return;
|
|
1347
|
-
for (const key in sourceModule) {
|
|
1348
|
-
if (key !== "default") {
|
|
1349
|
-
try {
|
|
1350
|
-
Object.defineProperty(exports, key, {
|
|
1351
|
-
enumerable: true,
|
|
1352
|
-
configurable: true,
|
|
1353
|
-
get() {
|
|
1354
|
-
return sourceModule[key];
|
|
1355
|
-
}
|
|
1356
|
-
});
|
|
1357
|
-
} catch (_err) {
|
|
1358
|
-
}
|
|
1359
|
-
}
|
|
1360
|
-
}
|
|
1361
|
-
}
|
|
1362
|
-
|
|
1363
|
-
const DEFAULT_TIMEOUT = 6e4;
|
|
1364
|
-
function createBirpc(functions, options) {
|
|
1365
|
-
const {
|
|
1366
|
-
post,
|
|
1367
|
-
on,
|
|
1368
|
-
eventNames = [],
|
|
1369
|
-
serialize = (i) => i,
|
|
1370
|
-
deserialize = (i) => i,
|
|
1371
|
-
timeout = DEFAULT_TIMEOUT
|
|
1372
|
-
} = options;
|
|
1373
|
-
const rpcPromiseMap = /* @__PURE__ */ new Map();
|
|
1374
|
-
const rpc = new Proxy({}, {
|
|
1375
|
-
get(_, method) {
|
|
1376
|
-
const sendEvent = (...args) => {
|
|
1377
|
-
post(serialize({ m: method, a: args, t: "q" }));
|
|
1378
|
-
};
|
|
1379
|
-
if (eventNames.includes(method)) {
|
|
1380
|
-
sendEvent.asEvent = sendEvent;
|
|
1381
|
-
return sendEvent;
|
|
1382
|
-
}
|
|
1383
|
-
const sendCall = (...args) => {
|
|
1384
|
-
return new Promise((resolve, reject) => {
|
|
1385
|
-
const id = nanoid();
|
|
1386
|
-
rpcPromiseMap.set(id, { resolve, reject });
|
|
1387
|
-
post(serialize({ m: method, a: args, i: id, t: "q" }));
|
|
1388
|
-
if (timeout >= 0) {
|
|
1389
|
-
setTimeout(() => {
|
|
1390
|
-
reject(new Error(`[birpc] timeout on calling "${method}"`));
|
|
1391
|
-
rpcPromiseMap.delete(id);
|
|
1392
|
-
}, timeout);
|
|
1393
|
-
}
|
|
1394
|
-
});
|
|
1395
|
-
};
|
|
1396
|
-
sendCall.asEvent = sendEvent;
|
|
1397
|
-
return sendCall;
|
|
1398
|
-
}
|
|
1399
|
-
});
|
|
1400
|
-
on(async (data, ...extra) => {
|
|
1401
|
-
const msg = deserialize(data);
|
|
1402
|
-
if (msg.t === "q") {
|
|
1403
|
-
const { m: method, a: args } = msg;
|
|
1404
|
-
let result, error;
|
|
1405
|
-
try {
|
|
1406
|
-
result = await functions[method].apply(rpc, args);
|
|
1407
|
-
} catch (e) {
|
|
1408
|
-
error = e;
|
|
1409
|
-
}
|
|
1410
|
-
if (msg.i)
|
|
1411
|
-
post(serialize({ t: "s", i: msg.i, r: result, e: error }), ...extra);
|
|
1412
|
-
} else {
|
|
1413
|
-
const { i: ack, r: result, e: error } = msg;
|
|
1414
|
-
const promise = rpcPromiseMap.get(ack);
|
|
1415
|
-
if (error)
|
|
1416
|
-
promise?.reject(error);
|
|
1417
|
-
else
|
|
1418
|
-
promise?.resolve(result);
|
|
1419
|
-
rpcPromiseMap.delete(ack);
|
|
1420
|
-
}
|
|
1421
|
-
});
|
|
1422
|
-
return rpc;
|
|
1423
|
-
}
|
|
1424
|
-
const urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
|
1425
|
-
function nanoid(size = 21) {
|
|
1426
|
-
let id = "";
|
|
1427
|
-
let i = size;
|
|
1428
|
-
while (i--)
|
|
1429
|
-
id += urlAlphabet[Math.random() * 64 | 0];
|
|
1430
|
-
return id;
|
|
1431
|
-
}
|
|
1432
|
-
|
|
1433
|
-
export { ModuleCacheMap as M, ViteNodeRunner as V, isValidNodeImport as a, toFilePath as b, createBirpc as c, isNodeBuiltin as i, normalizeRequestId as n, slash as s, toArray as t, withInlineSourcemap as w };
|
|
1114
|
+
export { isValidNodeImport as a, toFilePath as b, isPrimitive as c, normalizeModuleId as d, isNodeBuiltin as i, mergeSlashes as m, normalizeRequestId as n, slash as s, toArray as t, withInlineSourcemap as w };
|
package/dist/cli.mjs
CHANGED
|
@@ -1,28 +1,30 @@
|
|
|
1
1
|
import { EventEmitter } from 'events';
|
|
2
|
-
import { p as picocolors } from './chunk-
|
|
3
|
-
import { v as version, s as startVitest, d as divider } from './chunk-vite-node-externalize.
|
|
2
|
+
import { p as picocolors } from './chunk-mock-date.9160e13b.mjs';
|
|
3
|
+
import { v as version, s as startVitest, d as divider } from './chunk-vite-node-externalize.45323563.mjs';
|
|
4
4
|
import 'path';
|
|
5
5
|
import 'tty';
|
|
6
6
|
import 'local-pkg';
|
|
7
|
-
import './chunk-defaults.
|
|
7
|
+
import './chunk-defaults.1c51d585.mjs';
|
|
8
8
|
import 'fs';
|
|
9
9
|
import 'module';
|
|
10
10
|
import 'url';
|
|
11
11
|
import 'vite';
|
|
12
12
|
import 'process';
|
|
13
|
-
import './chunk-constants.
|
|
13
|
+
import './chunk-constants.16825f0c.mjs';
|
|
14
14
|
import 'os';
|
|
15
15
|
import 'util';
|
|
16
16
|
import 'stream';
|
|
17
17
|
import './vendor-_commonjsHelpers.4da45ef5.mjs';
|
|
18
|
-
import './chunk-vite-node-
|
|
18
|
+
import './chunk-vite-node-client.a247c2c2.mjs';
|
|
19
19
|
import 'vm';
|
|
20
|
+
import './chunk-vite-node-utils.9dfd1e3f.mjs';
|
|
20
21
|
import 'assert';
|
|
21
22
|
import 'debug';
|
|
22
23
|
import 'worker_threads';
|
|
23
24
|
import 'tinypool';
|
|
24
25
|
import 'perf_hooks';
|
|
25
|
-
import './chunk-utils-source-map.
|
|
26
|
+
import './chunk-utils-source-map.8198ebd9.mjs';
|
|
27
|
+
import './chunk-utils-timers.b48455ed.mjs';
|
|
26
28
|
import 'crypto';
|
|
27
29
|
import './vendor-index.61438b77.mjs';
|
|
28
30
|
import './chunk-magic-string.efe26975.mjs';
|
|
@@ -643,7 +645,7 @@ class CAC extends EventEmitter {
|
|
|
643
645
|
const cac = (name = "") => new CAC(name);
|
|
644
646
|
|
|
645
647
|
const cli = cac("vitest");
|
|
646
|
-
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("-t, --testNamePattern <pattern>", "run tests with full names matching the specified pattern").option("--dir <path>", "base directory to scan for the test files").option("--ui", "enable UI").option("--open", "open UI automatically (default: !process.env.CI))").option("--api [api]", "serve API, available options: --api.port <port>, --api.host [host] and --api.strictPort").option("--threads", "enabled threads (default: true)").option("--silent", "silent console output from tests").option("--isolate", "isolate environment for each test file (default: true)").option("--reporter <name>", "reporter").option("--outputTruncateLength <length>", "diff output length (default: 80)").option("--outputDiffLines <lines>", "number of diff output lines (default: 15)").option("--outputFile <filename/-s>", "write test results to a file when the --reporter=json or --reporter=junit option is also specified, use cac's dot notation for individual outputs of mutliple reporters").option("--coverage", "use c8 for coverage").option("--run", "do not watch").option("--mode <name>", "override Vite mode (default: test)").option("--globals", "inject apis globally").option("--dom", "mock browser api with happy-dom").option("--browser", "run tests in browser").option("--environment <env>", "runner environment (default: node)").option("--passWithNoTests", "pass when no tests found").option("--allowOnly", "Allow tests and suites that are marked as only (default: !process.env.CI)").option("--shard <shard>", "Test suite shard to execute in a format of <index>/<count>").option("--changed [since]", "Run tests that are affected by the changed files (default: false)").option("--sequence <options>", "Define in what order to run tests (use --sequence.shuffle to run tests in random order)").help();
|
|
648
|
+
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("-t, --testNamePattern <pattern>", "run tests with full names matching the specified pattern").option("--dir <path>", "base directory to scan for the test files").option("--ui", "enable UI").option("--open", "open UI automatically (default: !process.env.CI))").option("--api [api]", "serve API, available options: --api.port <port>, --api.host [host] and --api.strictPort").option("--threads", "enabled threads (default: true)").option("--silent", "silent console output from tests").option("--isolate", "isolate environment for each test file (default: true)").option("--reporter <name>", "reporter").option("--outputTruncateLength <length>", "diff output length (default: 80)").option("--outputDiffLines <lines>", "number of diff output lines (default: 15)").option("--outputFile <filename/-s>", "write test results to a file when the --reporter=json or --reporter=junit option is also specified, use cac's dot notation for individual outputs of mutliple reporters").option("--coverage", "use c8 for coverage").option("--run", "do not watch").option("--mode <name>", "override Vite mode (default: test)").option("--globals", "inject apis globally").option("--dom", "mock browser api with happy-dom").option("--browser", "run tests in browser").option("--environment <env>", "runner environment (default: node)").option("--passWithNoTests", "pass when no tests found").option("--allowOnly", "Allow tests and suites that are marked as only (default: !process.env.CI)").option("--dangerouslyIgnoreUnhandledErrors", "Ignore any unhandled errors that occur").option("--shard <shard>", "Test suite shard to execute in a format of <index>/<count>").option("--changed [since]", "Run tests that are affected by the changed files (default: false)").option("--sequence <options>", "Define in what order to run tests (use --sequence.shuffle to run tests in random order)").help();
|
|
647
649
|
cli.command("run [...filters]").action(run);
|
|
648
650
|
cli.command("related [...filters]").action(runRelated);
|
|
649
651
|
cli.command("watch [...filters]").action(start);
|
package/dist/config.cjs
CHANGED
|
@@ -25,7 +25,7 @@ const coverageConfigDefaults = {
|
|
|
25
25
|
reportsDirectory: "./coverage",
|
|
26
26
|
excludeNodeModules: true,
|
|
27
27
|
exclude: defaultCoverageExcludes,
|
|
28
|
-
reporter: ["text", "html"],
|
|
28
|
+
reporter: ["text", "html", "clover"],
|
|
29
29
|
allowExternal: false,
|
|
30
30
|
extension: [".js", ".cjs", ".mjs", ".ts", ".tsx", ".jsx", ".vue", ".svelte"]
|
|
31
31
|
};
|
|
@@ -75,7 +75,8 @@ const config = {
|
|
|
75
75
|
},
|
|
76
76
|
coverage: coverageConfigDefaults,
|
|
77
77
|
fakeTimers: fakeTimersDefaults,
|
|
78
|
-
maxConcurrency: 5
|
|
78
|
+
maxConcurrency: 5,
|
|
79
|
+
dangerouslyIgnoreUnhandledErrors: false
|
|
79
80
|
};
|
|
80
81
|
const configDefaults = Object.freeze(config);
|
|
81
82
|
|
package/dist/config.d.ts
CHANGED
|
@@ -98,6 +98,7 @@ declare const config: {
|
|
|
98
98
|
coverage: ResolvedC8Options;
|
|
99
99
|
fakeTimers: FakeTimerInstallOpts;
|
|
100
100
|
maxConcurrency: number;
|
|
101
|
+
dangerouslyIgnoreUnhandledErrors: boolean;
|
|
101
102
|
};
|
|
102
103
|
declare const configDefaults: Required<Pick<UserConfig$1, keyof typeof config>>;
|
|
103
104
|
|
package/dist/config.mjs
CHANGED
|
@@ -21,7 +21,7 @@ const coverageConfigDefaults = {
|
|
|
21
21
|
reportsDirectory: "./coverage",
|
|
22
22
|
excludeNodeModules: true,
|
|
23
23
|
exclude: defaultCoverageExcludes,
|
|
24
|
-
reporter: ["text", "html"],
|
|
24
|
+
reporter: ["text", "html", "clover"],
|
|
25
25
|
allowExternal: false,
|
|
26
26
|
extension: [".js", ".cjs", ".mjs", ".ts", ".tsx", ".jsx", ".vue", ".svelte"]
|
|
27
27
|
};
|
|
@@ -71,7 +71,8 @@ const config = {
|
|
|
71
71
|
},
|
|
72
72
|
coverage: coverageConfigDefaults,
|
|
73
73
|
fakeTimers: fakeTimersDefaults,
|
|
74
|
-
maxConcurrency: 5
|
|
74
|
+
maxConcurrency: 5,
|
|
75
|
+
dangerouslyIgnoreUnhandledErrors: false
|
|
75
76
|
};
|
|
76
77
|
const configDefaults = Object.freeze(config);
|
|
77
78
|
|
package/dist/entry.mjs
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
import { promises } from 'fs';
|
|
2
|
-
import {
|
|
3
|
-
import { f as envs } from './chunk-defaults.
|
|
4
|
-
import { a as setupGlobalEnv, s as startTests, w as withEnv } from './chunk-runtime-error.
|
|
2
|
+
import { a as resetModules } from './chunk-mock-date.9160e13b.mjs';
|
|
3
|
+
import { f as envs } from './chunk-defaults.1c51d585.mjs';
|
|
4
|
+
import { a as setupGlobalEnv, s as startTests, w as withEnv } from './chunk-runtime-error.0aa0dc06.mjs';
|
|
5
|
+
import { g as getWorkerState } from './chunk-utils-global.fa20c2f6.mjs';
|
|
5
6
|
import 'path';
|
|
6
7
|
import 'tty';
|
|
7
8
|
import 'local-pkg';
|
|
8
9
|
import 'module';
|
|
9
10
|
import 'url';
|
|
10
|
-
import './chunk-runtime-hooks.
|
|
11
|
-
import './chunk-runtime-chain.
|
|
11
|
+
import './chunk-runtime-hooks.3ee34848.mjs';
|
|
12
|
+
import './chunk-runtime-chain.b6c2cdbc.mjs';
|
|
12
13
|
import 'util';
|
|
13
14
|
import 'chai';
|
|
14
15
|
import './vendor-_commonjsHelpers.4da45ef5.mjs';
|
|
15
|
-
import './chunk-runtime-rpc.
|
|
16
|
-
import './chunk-utils-
|
|
16
|
+
import './chunk-runtime-rpc.dbf0b31d.mjs';
|
|
17
|
+
import './chunk-utils-timers.b48455ed.mjs';
|
|
18
|
+
import './chunk-utils-source-map.8198ebd9.mjs';
|
|
17
19
|
import './spy.mjs';
|
|
18
20
|
import 'tinyspy';
|
|
19
21
|
|
|
@@ -49,7 +51,7 @@ async function run(files, config) {
|
|
|
49
51
|
await withEnv(environment, config.environmentOptions || {}, async () => {
|
|
50
52
|
for (const file of files2) {
|
|
51
53
|
workerState.mockMap.clear();
|
|
52
|
-
resetModules();
|
|
54
|
+
resetModules(workerState.moduleCache, true);
|
|
53
55
|
workerState.filepath = file;
|
|
54
56
|
await startTests([file], config);
|
|
55
57
|
workerState.filepath = void 0;
|
package/dist/index.d.ts
CHANGED
|
@@ -266,7 +266,6 @@ declare class ViteNodeRunner {
|
|
|
266
266
|
*/
|
|
267
267
|
interopedImport(path: string): Promise<any>;
|
|
268
268
|
hasNestedDefault(target: any): any;
|
|
269
|
-
private debugLog;
|
|
270
269
|
}
|
|
271
270
|
interface DepsHandlingOptions {
|
|
272
271
|
external?: (string | RegExp)[];
|
|
@@ -337,6 +336,33 @@ interface ViteNodeServerOptions {
|
|
|
337
336
|
ssr?: RegExp[];
|
|
338
337
|
web?: RegExp[];
|
|
339
338
|
};
|
|
339
|
+
debug?: DebuggerOptions;
|
|
340
|
+
}
|
|
341
|
+
interface DebuggerOptions {
|
|
342
|
+
/**
|
|
343
|
+
* Dump the transformed module to filesystem
|
|
344
|
+
* Passing a string will dump to the specified path
|
|
345
|
+
*/
|
|
346
|
+
dumpModules?: boolean | string;
|
|
347
|
+
/**
|
|
348
|
+
* Read dumpped module from filesystem whenever exists.
|
|
349
|
+
* Useful for debugging by modifying the dump result from the filesystem.
|
|
350
|
+
*/
|
|
351
|
+
loadDumppedModules?: boolean;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
declare class Debugger {
|
|
355
|
+
options: DebuggerOptions;
|
|
356
|
+
dumpDir: string | undefined;
|
|
357
|
+
initPromise: Promise<void> | undefined;
|
|
358
|
+
externalizeMap: Map<string, string>;
|
|
359
|
+
constructor(root: string, options: DebuggerOptions);
|
|
360
|
+
clearDump(): Promise<void>;
|
|
361
|
+
encodeId(id: string): string;
|
|
362
|
+
recordExternalize(id: string, path: string): Promise<void>;
|
|
363
|
+
dumpFile(id: string, result: TransformResult | null): Promise<void>;
|
|
364
|
+
loadDump(id: string): Promise<TransformResult | null>;
|
|
365
|
+
writeInfo(): Promise<void>;
|
|
340
366
|
}
|
|
341
367
|
|
|
342
368
|
declare class ViteNodeServer {
|
|
@@ -348,6 +374,8 @@ declare class ViteNodeServer {
|
|
|
348
374
|
timestamp: number;
|
|
349
375
|
result: FetchResult;
|
|
350
376
|
}>;
|
|
377
|
+
externalizeCache: Map<string, Promise<string | false>>;
|
|
378
|
+
debugger?: Debugger;
|
|
351
379
|
constructor(server: ViteDevServer, options?: ViteNodeServerOptions);
|
|
352
380
|
shouldExternalize(id: string): Promise<string | false>;
|
|
353
381
|
resolveId(id: string, importer?: string): Promise<ViteNodeResolveId | null>;
|
|
@@ -374,16 +402,23 @@ interface WorkerPool {
|
|
|
374
402
|
close: () => Promise<void>;
|
|
375
403
|
}
|
|
376
404
|
|
|
405
|
+
interface CollectingPromise {
|
|
406
|
+
promise: Promise<void>;
|
|
407
|
+
resolve: () => void;
|
|
408
|
+
}
|
|
377
409
|
declare class StateManager {
|
|
378
410
|
filesMap: Map<string, File>;
|
|
379
411
|
pathsSet: Set<string>;
|
|
412
|
+
collectingPromise: CollectingPromise | undefined;
|
|
380
413
|
idMap: Map<string, Task>;
|
|
381
414
|
taskFileMap: WeakMap<Task, File>;
|
|
382
415
|
errorsSet: Set<unknown>;
|
|
383
416
|
catchError(err: unknown, type: string): void;
|
|
384
417
|
clearErrors(): void;
|
|
385
418
|
getUnhandledErrors(): unknown[];
|
|
386
|
-
|
|
419
|
+
startCollectingPaths(): void;
|
|
420
|
+
finishCollectingPaths(): void;
|
|
421
|
+
getPaths(): Promise<string[]>;
|
|
387
422
|
getFiles(keys?: string[]): File[];
|
|
388
423
|
getFilepaths(): string[];
|
|
389
424
|
getFailedFilepaths(): string[];
|
|
@@ -892,6 +927,7 @@ interface Suite extends TaskBase {
|
|
|
892
927
|
interface File extends Suite {
|
|
893
928
|
filepath: string;
|
|
894
929
|
collectDuration?: number;
|
|
930
|
+
setupDuration?: number;
|
|
895
931
|
}
|
|
896
932
|
interface Test<ExtraContext = {}> extends TaskBase {
|
|
897
933
|
type: 'test';
|
|
@@ -1100,6 +1136,11 @@ interface InlineConfig {
|
|
|
1100
1136
|
* @default false
|
|
1101
1137
|
*/
|
|
1102
1138
|
fallbackCJS?: boolean;
|
|
1139
|
+
/**
|
|
1140
|
+
* Use experimental Node loader to resolve imports inside node_modules using Vite resolve algorithm.
|
|
1141
|
+
* @default true
|
|
1142
|
+
*/
|
|
1143
|
+
registerNodeLoader?: boolean;
|
|
1103
1144
|
};
|
|
1104
1145
|
/**
|
|
1105
1146
|
* Base directory to scan for the test files
|
|
@@ -1387,6 +1428,10 @@ interface InlineConfig {
|
|
|
1387
1428
|
* Will be merged with the default aliases inside `resolve.alias`.
|
|
1388
1429
|
*/
|
|
1389
1430
|
alias?: AliasOptions;
|
|
1431
|
+
/**
|
|
1432
|
+
* Ignore any unhandled errors that occur
|
|
1433
|
+
*/
|
|
1434
|
+
dangerouslyIgnoreUnhandledErrors?: boolean;
|
|
1390
1435
|
}
|
|
1391
1436
|
interface UserConfig extends InlineConfig {
|
|
1392
1437
|
/**
|
|
@@ -1831,7 +1876,7 @@ declare type MaybeMocked<T> = T extends Procedure ? MockedFunction<T> : T extend
|
|
|
1831
1876
|
interface Constructable {
|
|
1832
1877
|
new (...args: any[]): any;
|
|
1833
1878
|
}
|
|
1834
|
-
declare type MockedClass<T extends Constructable> = MockInstance<
|
|
1879
|
+
declare type MockedClass<T extends Constructable> = MockInstance<T extends new (...args: infer P) => any ? P : never, InstanceType<T>> & {
|
|
1835
1880
|
prototype: T extends {
|
|
1836
1881
|
prototype: any;
|
|
1837
1882
|
} ? Mocked<T['prototype']> : never;
|
|
@@ -1994,7 +2039,7 @@ interface WebSocketHandlers {
|
|
|
1994
2039
|
onCollected(files?: File[]): Promise<void>;
|
|
1995
2040
|
onTaskUpdate(packs: TaskResultPack[]): void;
|
|
1996
2041
|
getFiles(): File[];
|
|
1997
|
-
getPaths(): string[]
|
|
2042
|
+
getPaths(): Promise<string[]>;
|
|
1998
2043
|
getConfig(): ResolvedConfig;
|
|
1999
2044
|
getModuleGraph(id: string): Promise<ModuleGraphData>;
|
|
2000
2045
|
getTransformResult(id: string): Promise<TransformResultWithSource | undefined>;
|
package/dist/index.mjs
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
export { c as createExpect, d as describe, b as expect, i as it, s as suite, t as test } from './chunk-runtime-chain.
|
|
2
|
-
export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach, h as getRunningMode, f as isFirstRun, j as isWatchMode, e as runOnce, v as vi, g as vitest, w as withCallback } from './chunk-runtime-hooks.
|
|
1
|
+
export { c as createExpect, d as describe, b as expect, i as it, s as suite, t as test } from './chunk-runtime-chain.b6c2cdbc.mjs';
|
|
2
|
+
export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach, h as getRunningMode, f as isFirstRun, j as isWatchMode, e as runOnce, v as vi, g as vitest, w as withCallback } from './chunk-runtime-hooks.3ee34848.mjs';
|
|
3
3
|
import * as chai from 'chai';
|
|
4
4
|
export { chai };
|
|
5
5
|
export { assert, should } from 'chai';
|
|
6
6
|
import 'util';
|
|
7
|
-
import './chunk-
|
|
7
|
+
import './chunk-mock-date.9160e13b.mjs';
|
|
8
8
|
import 'path';
|
|
9
9
|
import 'tty';
|
|
10
10
|
import 'local-pkg';
|
|
11
11
|
import './vendor-_commonjsHelpers.4da45ef5.mjs';
|
|
12
|
-
import './chunk-runtime-rpc.
|
|
12
|
+
import './chunk-runtime-rpc.dbf0b31d.mjs';
|
|
13
|
+
import './chunk-utils-global.fa20c2f6.mjs';
|
|
14
|
+
import './chunk-utils-timers.b48455ed.mjs';
|
|
13
15
|
import 'fs';
|
|
14
|
-
import './chunk-utils-source-map.
|
|
16
|
+
import './chunk-utils-source-map.8198ebd9.mjs';
|
|
15
17
|
import './spy.mjs';
|
|
16
18
|
import 'tinyspy';
|
package/dist/loader.mjs
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { pathToFileURL } from 'url';
|
|
2
|
+
import { i as isNodeBuiltin, d as normalizeModuleId } from './chunk-vite-node-utils.9dfd1e3f.mjs';
|
|
3
|
+
import './chunk-mock-date.9160e13b.mjs';
|
|
4
|
+
import { g as getWorkerState } from './chunk-utils-global.fa20c2f6.mjs';
|
|
5
|
+
import 'module';
|
|
6
|
+
import 'path';
|
|
7
|
+
import 'fs';
|
|
8
|
+
import 'assert';
|
|
9
|
+
import 'util';
|
|
10
|
+
import 'tty';
|
|
11
|
+
import 'local-pkg';
|
|
12
|
+
|
|
13
|
+
const resolve = async (url, context, next) => {
|
|
14
|
+
const { parentURL } = context;
|
|
15
|
+
if (!parentURL || !parentURL.includes("node_modules") || isNodeBuiltin(url))
|
|
16
|
+
return next(url, context, next);
|
|
17
|
+
const id = normalizeModuleId(url);
|
|
18
|
+
const importer = normalizeModuleId(parentURL);
|
|
19
|
+
const state = getWorkerState();
|
|
20
|
+
const resolver = state == null ? void 0 : state.rpc.resolveId;
|
|
21
|
+
if (resolver) {
|
|
22
|
+
const resolved = await resolver(id, importer);
|
|
23
|
+
if (resolved) {
|
|
24
|
+
return {
|
|
25
|
+
url: pathToFileURL(resolved.id).toString(),
|
|
26
|
+
shortCircuit: true
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return next(url, context, next);
|
|
31
|
+
};
|
|
32
|
+
const load = (url, context, next) => {
|
|
33
|
+
return next(url, context, next);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export { load, resolve };
|