vitest 3.2.0-beta.3 → 3.2.1

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.
Files changed (65) hide show
  1. package/LICENSE.md +29 -0
  2. package/dist/browser.d.ts +1 -1
  3. package/dist/browser.js +2 -2
  4. package/dist/chunks/{base.D4119yLM.js → base.Cg0miDlQ.js} +10 -14
  5. package/dist/chunks/{benchmark.Cf_PACH1.js → benchmark.CYdenmiT.js} +4 -6
  6. package/dist/chunks/{cac.DWaWHIIE.js → cac.C8BzMmTW.js} +66 -136
  7. package/dist/chunks/{cli-api.CnmEXkxs.js → cli-api.DmupRhea.js} +1251 -1336
  8. package/dist/chunks/{console.Cwr-MFPV.js → console.CtFJOzRO.js} +24 -45
  9. package/dist/chunks/{coverage.0iPg4Wrz.js → coverage.DVF1vEu8.js} +4 -12
  10. package/dist/chunks/{coverage.C73DaDgS.js → coverage.EIiagJJP.js} +484 -1003
  11. package/dist/chunks/{creator.C8WKy2eW.js → creator.GK6I-cL4.js} +29 -76
  12. package/dist/chunks/{date.ByMsSlOr.js → date.Bq6ZW5rf.js} +3 -8
  13. package/dist/chunks/{defaults.DpVH7vbg.js → defaults.B7q_naMc.js} +1 -1
  14. package/dist/chunks/{env.Dq0hM4Xv.js → env.D4Lgay0q.js} +1 -1
  15. package/dist/chunks/{execute.B3q-2LPV.js → execute.B7h3T_Hc.js} +104 -220
  16. package/dist/chunks/{git.DXfdBEfR.js → git.BVQ8w_Sw.js} +1 -3
  17. package/dist/chunks/{global.d.BNLIi6yo.d.ts → global.d.MAmajcmJ.d.ts} +2 -0
  18. package/dist/chunks/{globals.CI21aWXF.js → globals.DEHgCU4V.js} +5 -5
  19. package/dist/chunks/{index.Bter3jj9.js → index.BZ0g1JD2.js} +366 -628
  20. package/dist/chunks/{index.CbT4iuwc.js → index.BbB8_kAK.js} +22 -24
  21. package/dist/chunks/{index.JOzufsrU.js → index.CIyJn3t1.js} +37 -82
  22. package/dist/chunks/{index.DNgLEKsQ.js → index.CdQS2e2Q.js} +2 -2
  23. package/dist/chunks/{index.2jgTs_Q5.js → index.CmSc2RE5.js} +69 -107
  24. package/dist/chunks/{inspector.BFsh5KO0.js → inspector.C914Efll.js} +1 -1
  25. package/dist/chunks/{node.Be-ntJnD.js → node.fjCdwEIl.js} +1 -1
  26. package/dist/chunks/{reporters.d.Bt4IGtsa.d.ts → reporters.d.C1ogPriE.d.ts} +24 -4
  27. package/dist/chunks/{rpc.BKExFSRG.js → rpc.Iovn4oWe.js} +9 -19
  28. package/dist/chunks/{runBaseTests.B_M1TTsK.js → runBaseTests.Dd85QTll.js} +18 -31
  29. package/dist/chunks/{setup-common.CF-O-dZX.js → setup-common.Dd054P77.js} +15 -42
  30. package/dist/chunks/{typechecker.BgzF-6iO.js → typechecker.DRKU1-1g.js} +106 -186
  31. package/dist/chunks/{utils.DPCq3gzW.js → utils.CAioKnHs.js} +6 -14
  32. package/dist/chunks/{utils.BlI4TC7Y.js → utils.XdZDrNZV.js} +5 -13
  33. package/dist/chunks/{vi.pkoYCV6A.js → vi.bdSIJ99Y.js} +118 -267
  34. package/dist/chunks/{vite.d.B-Kx3KCF.d.ts → vite.d.DqE4-hhK.d.ts} +1 -1
  35. package/dist/chunks/{vm.DPYem2so.js → vm.BThCzidc.js} +98 -214
  36. package/dist/chunks/{worker.d.Bl1O4kuf.d.ts → worker.d.DvqK5Vmu.d.ts} +1 -1
  37. package/dist/chunks/{worker.d.BKbBp2ga.d.ts → worker.d.tQu2eJQy.d.ts} +3 -1
  38. package/dist/cli.js +4 -4
  39. package/dist/config.cjs +1 -1
  40. package/dist/config.d.ts +4 -4
  41. package/dist/config.js +2 -2
  42. package/dist/coverage.d.ts +2 -2
  43. package/dist/coverage.js +5 -5
  44. package/dist/environments.js +1 -1
  45. package/dist/execute.d.ts +1 -1
  46. package/dist/execute.js +1 -1
  47. package/dist/index.d.ts +12 -11
  48. package/dist/index.js +5 -5
  49. package/dist/node.d.ts +7 -7
  50. package/dist/node.js +12 -14
  51. package/dist/reporters.d.ts +2 -2
  52. package/dist/reporters.js +4 -4
  53. package/dist/runners.d.ts +5 -2
  54. package/dist/runners.js +51 -80
  55. package/dist/snapshot.js +2 -2
  56. package/dist/suite.js +2 -2
  57. package/dist/worker.js +36 -42
  58. package/dist/workers/forks.js +4 -4
  59. package/dist/workers/runVmTests.js +15 -21
  60. package/dist/workers/threads.js +4 -4
  61. package/dist/workers/vmForks.js +6 -6
  62. package/dist/workers/vmThreads.js +6 -6
  63. package/dist/workers.d.ts +2 -2
  64. package/dist/workers.js +10 -10
  65. package/package.json +16 -14
@@ -1,5 +1,5 @@
1
1
  import { HookHandler } from 'vite';
2
- import { V as Vitest, T as TestProject, b as TestProjectConfiguration, I as InlineConfig } from './reporters.d.Bt4IGtsa.js';
2
+ import { V as Vitest, T as TestProject, b as TestProjectConfiguration, I as InlineConfig } from './reporters.d.C1ogPriE.js';
3
3
 
4
4
  interface VitestPluginContext {
5
5
  vitest: Vitest;
@@ -2,23 +2,21 @@ import { fileURLToPath, pathToFileURL } from 'node:url';
2
2
  import vm, { isContext } from 'node:vm';
3
3
  import { dirname, basename, extname, normalize, join, resolve } from 'pathe';
4
4
  import { distDir } from '../path.js';
5
- import { createCustomConsole } from './console.Cwr-MFPV.js';
6
- import { g as getDefaultRequestStubs, s as startVitestExecutor } from './execute.B3q-2LPV.js';
5
+ import { createCustomConsole } from './console.CtFJOzRO.js';
6
+ import { g as getDefaultRequestStubs, s as startVitestExecutor } from './execute.B7h3T_Hc.js';
7
7
  import fs from 'node:fs';
8
8
  import { dirname as dirname$1 } from 'node:path';
9
9
  import { isPrimitive, isNodeBuiltin, toArray, getCachedData, setCacheData, isBareImport } from 'vite-node/utils';
10
10
  import { createRequire, Module } from 'node:module';
11
11
  import { CSS_LANGS_RE, KNOWN_ASSET_RE } from 'vite-node/constants';
12
- import { p as provideWorkerState } from './utils.BlI4TC7Y.js';
12
+ import { p as provideWorkerState } from './utils.XdZDrNZV.js';
13
13
 
14
14
  function interopCommonJsModule(interopDefault, mod) {
15
- if (isPrimitive(mod) || Array.isArray(mod) || mod instanceof Promise) {
16
- return {
17
- keys: [],
18
- moduleExports: {},
19
- defaultExport: mod
20
- };
21
- }
15
+ if (isPrimitive(mod) || Array.isArray(mod) || mod instanceof Promise) return {
16
+ keys: [],
17
+ moduleExports: {},
18
+ defaultExport: mod
19
+ };
22
20
  if (interopDefault !== false && "__esModule" in mod && !isPrimitive(mod.default)) {
23
21
  const defaultKets = Object.keys(mod.default);
24
22
  const moduleKeys = Object.keys(mod);
@@ -42,12 +40,12 @@ const SyntheticModule = vm.SyntheticModule;
42
40
  const SourceTextModule = vm.SourceTextModule;
43
41
 
44
42
  const _require = createRequire(import.meta.url);
45
- const requiresCache = new WeakMap();
43
+ const requiresCache = /* @__PURE__ */ new WeakMap();
46
44
  class CommonjsExecutor {
47
45
  context;
48
- requireCache = new Map();
46
+ requireCache = /* @__PURE__ */ new Map();
49
47
  publicRequireCache = this.createProxyCache();
50
- moduleCache = new Map();
48
+ moduleCache = /* @__PURE__ */ new Map();
51
49
  builtinCache = Object.create(null);
52
50
  extensions = Object.create(null);
53
51
  fs;
@@ -81,9 +79,7 @@ class CommonjsExecutor {
81
79
  }
82
80
  get require() {
83
81
  const require = requiresCache.get(this);
84
- if (require) {
85
- return require;
86
- }
82
+ if (require) return require;
87
83
  const _require = Module$1.createRequire(this.id);
88
84
  requiresCache.set(this, _require);
89
85
  return _require;
@@ -170,9 +166,7 @@ class CommonjsExecutor {
170
166
  const require = (id) => {
171
167
  const resolved = _require.resolve(id);
172
168
  const ext = extname(resolved);
173
- if (ext === ".node" || isNodeBuiltin(resolved)) {
174
- return this.requireCoreModule(resolved);
175
- }
169
+ if (ext === ".node" || isNodeBuiltin(resolved)) return this.requireCoreModule(resolved);
176
170
  const module = new this.Module(resolved);
177
171
  return this.loadCommonJSModule(module, resolved);
178
172
  };
@@ -182,7 +176,7 @@ class CommonjsExecutor {
182
176
  set: () => {},
183
177
  configurable: true
184
178
  });
185
- require.main = undefined;
179
+ require.main = void 0;
186
180
  require.cache = this.publicRequireCache;
187
181
  return require;
188
182
  };
@@ -205,9 +199,7 @@ class CommonjsExecutor {
205
199
  // very naive implementation for Node.js require
206
200
  loadCommonJSModule(module, filename) {
207
201
  const cached = this.requireCache.get(filename);
208
- if (cached) {
209
- return cached.exports;
210
- }
202
+ if (cached) return cached.exports;
211
203
  const extension = this.findLongestRegisteredExtension(filename);
212
204
  const loader = this.extensions[extension] || this.extensions[".js"];
213
205
  loader(module, filename);
@@ -221,26 +213,18 @@ class CommonjsExecutor {
221
213
  // eslint-disable-next-line no-cond-assign
222
214
  while ((index = name.indexOf(".", startIndex)) !== -1) {
223
215
  startIndex = index + 1;
224
- if (index === 0) {
225
- continue;
226
- }
216
+ if (index === 0) continue;
227
217
  currentExtension = name.slice(index);
228
- if (this.extensions[currentExtension]) {
229
- return currentExtension;
230
- }
218
+ if (this.extensions[currentExtension]) return currentExtension;
231
219
  }
232
220
  return ".js";
233
221
  }
234
222
  getCoreSyntheticModule(identifier) {
235
- if (this.moduleCache.has(identifier)) {
236
- return this.moduleCache.get(identifier);
237
- }
223
+ if (this.moduleCache.has(identifier)) return this.moduleCache.get(identifier);
238
224
  const exports = this.require(identifier);
239
225
  const keys = Object.keys(exports);
240
226
  const module = new SyntheticModule([...keys, "default"], () => {
241
- for (const key of keys) {
242
- module.setExport(key, exports[key]);
243
- }
227
+ for (const key of keys) module.setExport(key, exports[key]);
244
228
  module.setExport("default", exports);
245
229
  }, {
246
230
  context: this.context,
@@ -250,16 +234,12 @@ class CommonjsExecutor {
250
234
  return module;
251
235
  }
252
236
  getCjsSyntheticModule(path, identifier) {
253
- if (this.moduleCache.has(identifier)) {
254
- return this.moduleCache.get(identifier);
255
- }
237
+ if (this.moduleCache.has(identifier)) return this.moduleCache.get(identifier);
256
238
  const exports = this.require(path);
257
239
  // TODO: technically module should be parsed to find static exports, implement for strict mode in #2854
258
240
  const { keys, moduleExports, defaultExport } = interopCommonJsModule(this.interopDefault, exports);
259
241
  const module = new SyntheticModule([...keys, "default"], function() {
260
- for (const key of keys) {
261
- this.setExport(key, moduleExports[key]);
262
- }
242
+ for (const key of keys) this.setExport(key, moduleExports[key]);
263
243
  this.setExport("default", defaultExport);
264
244
  }, {
265
245
  context: this.context,
@@ -306,17 +286,13 @@ class CommonjsExecutor {
306
286
  // }
307
287
  require(identifier) {
308
288
  const ext = extname(identifier);
309
- if (ext === ".node" || isNodeBuiltin(identifier)) {
310
- return this.requireCoreModule(identifier);
311
- }
289
+ if (ext === ".node" || isNodeBuiltin(identifier)) return this.requireCoreModule(identifier);
312
290
  const module = new this.Module(identifier);
313
291
  return this.loadCommonJSModule(module, identifier);
314
292
  }
315
293
  requireCoreModule(identifier) {
316
294
  const normalized = identifier.replace(/^node:/, "");
317
- if (this.builtinCache[normalized]) {
318
- return this.builtinCache[normalized].exports;
319
- }
295
+ if (this.builtinCache[normalized]) return this.builtinCache[normalized].exports;
320
296
  const moduleExports = _require(identifier);
321
297
  if (identifier === "node:module" || identifier === "module") {
322
298
  const module = new this.Module("/module.js");
@@ -332,8 +308,8 @@ class CommonjsExecutor {
332
308
 
333
309
  const dataURIRegex = /^data:(?<mime>text\/javascript|application\/json|application\/wasm)(?:;(?<encoding>charset=utf-8|base64))?,(?<code>.*)$/;
334
310
  class EsmExecutor {
335
- moduleCache = new Map();
336
- esmLinkMap = new WeakMap();
311
+ moduleCache = /* @__PURE__ */ new Map();
312
+ esmLinkMap = /* @__PURE__ */ new WeakMap();
337
313
  context;
338
314
  #httpIp = IPnumber("127.0.0.0");
339
315
  constructor(executor, options) {
@@ -341,20 +317,14 @@ class EsmExecutor {
341
317
  this.context = options.context;
342
318
  }
343
319
  async evaluateModule(m) {
344
- if (m.status === "unlinked") {
345
- this.esmLinkMap.set(m, m.link((identifier, referencer) => this.executor.resolveModule(identifier, referencer.identifier)));
346
- }
320
+ if (m.status === "unlinked") this.esmLinkMap.set(m, m.link((identifier, referencer) => this.executor.resolveModule(identifier, referencer.identifier)));
347
321
  await this.esmLinkMap.get(m);
348
- if (m.status === "linked") {
349
- await m.evaluate();
350
- }
322
+ if (m.status === "linked") await m.evaluate();
351
323
  return m;
352
324
  }
353
325
  async createEsModule(fileURL, getCode) {
354
326
  const cached = this.moduleCache.get(fileURL);
355
- if (cached) {
356
- return cached;
357
- }
327
+ if (cached) return cached;
358
328
  const promise = this.loadEsModule(fileURL, getCode);
359
329
  this.moduleCache.set(fileURL, promise);
360
330
  return promise;
@@ -391,9 +361,7 @@ class EsmExecutor {
391
361
  }
392
362
  async createWebAssemblyModule(fileUrl, getCode) {
393
363
  const cached = this.moduleCache.get(fileUrl);
394
- if (cached) {
395
- return cached;
396
- }
364
+ if (cached) return cached;
397
365
  const m = this.loadWebAssemblyModule(getCode(), fileUrl);
398
366
  this.moduleCache.set(fileUrl, m);
399
367
  return m;
@@ -402,43 +370,31 @@ class EsmExecutor {
402
370
  // https://nodejs.org/api/esm.html#https-and-http-imports
403
371
  if (fileUrl.startsWith("http:")) {
404
372
  const url = new URL(fileUrl);
405
- if (url.hostname !== "localhost" && url.hostname !== "::1" && (IPnumber(url.hostname) & IPmask(8)) !== this.#httpIp) {
406
- throw new Error(
407
- // we don't know the importer, so it's undefined (the same happens in --pool=threads)
408
- `import of '${fileUrl}' by undefined is not supported: ` + "http can only be used to load local resources (use https instead)."
409
- );
410
- }
373
+ if (url.hostname !== "localhost" && url.hostname !== "::1" && (IPnumber(url.hostname) & IPmask(8)) !== this.#httpIp) throw new Error(
374
+ // we don't know the importer, so it's undefined (the same happens in --pool=threads)
375
+ `import of '${fileUrl}' by undefined is not supported: http can only be used to load local resources (use https instead).`
376
+ );
411
377
  }
412
378
  return this.createEsModule(fileUrl, () => fetch(fileUrl).then((r) => r.text()));
413
379
  }
414
380
  async loadWebAssemblyModule(source, identifier) {
415
381
  const cached = this.moduleCache.get(identifier);
416
- if (cached) {
417
- return cached;
418
- }
382
+ if (cached) return cached;
419
383
  const wasmModule = await WebAssembly.compile(source);
420
384
  const exports = WebAssembly.Module.exports(wasmModule);
421
385
  const imports = WebAssembly.Module.imports(wasmModule);
422
386
  const moduleLookup = {};
423
- for (const { module } of imports) {
424
- if (moduleLookup[module] === undefined) {
425
- moduleLookup[module] = await this.executor.resolveModule(module, identifier);
426
- }
427
- }
387
+ for (const { module } of imports) if (moduleLookup[module] === void 0) moduleLookup[module] = await this.executor.resolveModule(module, identifier);
428
388
  const evaluateModule = (module) => this.evaluateModule(module);
429
389
  const syntheticModule = new SyntheticModule(exports.map(({ name }) => name), async function() {
430
390
  const importsObject = {};
431
391
  for (const { module, name } of imports) {
432
- if (!importsObject[module]) {
433
- importsObject[module] = {};
434
- }
392
+ if (!importsObject[module]) importsObject[module] = {};
435
393
  await evaluateModule(moduleLookup[module]);
436
394
  importsObject[module][name] = moduleLookup[module].namespace[name];
437
395
  }
438
396
  const wasmInstance = new WebAssembly.Instance(wasmModule, importsObject);
439
- for (const { name } of exports) {
440
- this.setExport(name, wasmInstance.exports[name]);
441
- }
397
+ for (const { name } of exports) this.setExport(name, wasmInstance.exports[name]);
442
398
  }, {
443
399
  context: this.context,
444
400
  identifier
@@ -453,34 +409,22 @@ class EsmExecutor {
453
409
  }
454
410
  async createDataModule(identifier) {
455
411
  const cached = this.moduleCache.get(identifier);
456
- if (cached) {
457
- return cached;
458
- }
412
+ if (cached) return cached;
459
413
  const match = identifier.match(dataURIRegex);
460
- if (!match || !match.groups) {
461
- throw new Error("Invalid data URI");
462
- }
414
+ if (!match || !match.groups) throw new Error("Invalid data URI");
463
415
  const mime = match.groups.mime;
464
416
  const encoding = match.groups.encoding;
465
417
  if (mime === "application/wasm") {
466
- if (!encoding) {
467
- throw new Error("Missing data URI encoding");
468
- }
469
- if (encoding !== "base64") {
470
- throw new Error(`Invalid data URI encoding: ${encoding}`);
471
- }
418
+ if (!encoding) throw new Error("Missing data URI encoding");
419
+ if (encoding !== "base64") throw new Error(`Invalid data URI encoding: ${encoding}`);
472
420
  const module = this.loadWebAssemblyModule(Buffer.from(match.groups.code, "base64"), identifier);
473
421
  this.moduleCache.set(identifier, module);
474
422
  return module;
475
423
  }
476
424
  let code = match.groups.code;
477
- if (!encoding || encoding === "charset=utf-8") {
478
- code = decodeURIComponent(code);
479
- } else if (encoding === "base64") {
480
- code = Buffer.from(code, "base64").toString();
481
- } else {
482
- throw new Error(`Invalid data URI encoding: ${encoding}`);
483
- }
425
+ if (!encoding || encoding === "charset=utf-8") code = decodeURIComponent(code);
426
+ else if (encoding === "base64") code = Buffer.from(code, "base64").toString();
427
+ else throw new Error(`Invalid data URI encoding: ${encoding}`);
484
428
  if (mime === "application/json") {
485
429
  const module = new SyntheticModule(["default"], function() {
486
430
  const obj = JSON.parse(code);
@@ -497,9 +441,7 @@ class EsmExecutor {
497
441
  }
498
442
  function IPnumber(address) {
499
443
  const ip = address.match(/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/);
500
- if (ip) {
501
- return (+ip[1] << 24) + (+ip[2] << 16) + (+ip[3] << 8) + +ip[4];
502
- }
444
+ if (ip) return (+ip[1] << 24) + (+ip[2] << 16) + (+ip[3] << 8) + +ip[4];
503
445
  throw new Error(`Expected IP address, received ${address}`);
504
446
  }
505
447
  function IPmask(maskSize) {
@@ -516,9 +458,7 @@ class ViteExecutor {
516
458
  }
517
459
  resolve = (identifier, parent) => {
518
460
  if (identifier === CLIENT_ID) {
519
- if (this.workerState.environment.transformMode === "web") {
520
- return identifier;
521
- }
461
+ if (this.workerState.environment.transformMode === "web") return identifier;
522
462
  const packageName = this.getPackageName(parent);
523
463
  throw new Error(`[vitest] Vitest cannot handle ${CLIENT_ID} imported in ${parent} when running in SSR environment. Add "${packageName}" to "ssr.noExternal" if you are using Vite SSR, or to "server.deps.inline" if you are using Vite Node.`);
524
464
  }
@@ -529,27 +469,18 @@ class ViteExecutor {
529
469
  getPackageName(modulePath) {
530
470
  const path = normalize(modulePath);
531
471
  let name = path.split("/node_modules/").pop() || "";
532
- if (name?.startsWith("@")) {
533
- name = name.split("/").slice(0, 2).join("/");
534
- } else {
535
- name = name.split("/")[0];
536
- }
472
+ if (name?.startsWith("@")) name = name.split("/").slice(0, 2).join("/");
473
+ else name = name.split("/")[0];
537
474
  return name;
538
475
  }
539
476
  async createViteModule(fileUrl) {
540
- if (fileUrl === CLIENT_FILE) {
541
- return this.createViteClientModule();
542
- }
477
+ if (fileUrl === CLIENT_FILE) return this.createViteClientModule();
543
478
  const cached = this.esm.resolveCachedModule(fileUrl);
544
- if (cached) {
545
- return cached;
546
- }
479
+ if (cached) return cached;
547
480
  return this.esm.createEsModule(fileUrl, async () => {
548
481
  try {
549
482
  const result = await this.options.transform(fileUrl, "web");
550
- if (result.code) {
551
- return result.code;
552
- }
483
+ if (result.code) return result.code;
553
484
  } catch (cause) {
554
485
  // rethrow vite error if it cannot load the module because it's not resolved
555
486
  if (typeof cause === "object" && cause.code === "ERR_LOAD_URL" || typeof cause?.message === "string" && cause.message.includes("Failed to load url")) {
@@ -564,9 +495,7 @@ class ViteExecutor {
564
495
  createViteClientModule() {
565
496
  const identifier = CLIENT_ID;
566
497
  const cached = this.esm.resolveCachedModule(identifier);
567
- if (cached) {
568
- return cached;
569
- }
498
+ if (cached) return cached;
570
499
  const stub = this.options.viteClientModule;
571
500
  const moduleKeys = Object.keys(stub);
572
501
  const module = new SyntheticModule(moduleKeys, function() {
@@ -582,23 +511,13 @@ class ViteExecutor {
582
511
  }
583
512
  canResolve = (fileUrl) => {
584
513
  const transformMode = this.workerState.environment.transformMode;
585
- if (transformMode !== "web") {
586
- return false;
587
- }
588
- if (fileUrl === CLIENT_FILE) {
589
- return true;
590
- }
514
+ if (transformMode !== "web") return false;
515
+ if (fileUrl === CLIENT_FILE) return true;
591
516
  const config = this.workerState.config.deps?.web || {};
592
517
  const [modulePath] = fileUrl.split("?");
593
- if (config.transformCss && CSS_LANGS_RE.test(modulePath)) {
594
- return true;
595
- }
596
- if (config.transformAssets && KNOWN_ASSET_RE.test(modulePath)) {
597
- return true;
598
- }
599
- if (toArray(config.transformGlobPattern).some((pattern) => pattern.test(modulePath))) {
600
- return true;
601
- }
518
+ if (config.transformCss && CSS_LANGS_RE.test(modulePath)) return true;
519
+ if (config.transformAssets && KNOWN_ASSET_RE.test(modulePath)) return true;
520
+ if (toArray(config.transformGlobPattern).some((pattern) => pattern.test(modulePath))) return true;
602
521
  return false;
603
522
  };
604
523
  }
@@ -652,17 +571,13 @@ class ExternalModulesExecutor {
652
571
  };
653
572
  resolveModule = async (specifier, referencer) => {
654
573
  let identifier = this.resolve(specifier, referencer);
655
- if (identifier instanceof Promise) {
656
- identifier = await identifier;
657
- }
574
+ if (identifier instanceof Promise) identifier = await identifier;
658
575
  return await this.createModule(identifier);
659
576
  };
660
577
  resolve(specifier, parent) {
661
578
  for (const resolver of this.resolvers) {
662
579
  const id = resolver(specifier, parent);
663
- if (id) {
664
- return id;
665
- }
580
+ if (id) return id;
666
581
  }
667
582
  // import.meta.resolve can be asynchronous in older +18 Node versions
668
583
  return nativeResolve(specifier, parent);
@@ -672,65 +587,50 @@ class ExternalModulesExecutor {
672
587
  const packageCache = this.options.packageCache;
673
588
  while (basedir) {
674
589
  const cached = getCachedData(packageCache, basedir, originalBasedir);
675
- if (cached) {
676
- return cached;
677
- }
590
+ if (cached) return cached;
678
591
  const pkgPath = join(basedir, "package.json");
679
592
  try {
680
593
  if (statSync(pkgPath, { throwIfNoEntry: false })?.isFile()) {
681
594
  const pkgData = JSON.parse(this.fs.readFile(pkgPath));
682
- if (packageCache) {
683
- setCacheData(packageCache, pkgData, basedir, originalBasedir);
684
- }
595
+ if (packageCache) setCacheData(packageCache, pkgData, basedir, originalBasedir);
685
596
  return pkgData;
686
597
  }
687
598
  } catch {}
688
599
  const nextBasedir = dirname$1(basedir);
689
- if (nextBasedir === basedir) {
690
- break;
691
- }
600
+ if (nextBasedir === basedir) break;
692
601
  basedir = nextBasedir;
693
602
  }
694
603
  return {};
695
604
  }
696
605
  getModuleInformation(identifier) {
697
- if (identifier.startsWith("data:")) {
698
- return {
699
- type: "data",
700
- url: identifier,
701
- path: identifier
702
- };
703
- }
606
+ if (identifier.startsWith("data:")) return {
607
+ type: "data",
608
+ url: identifier,
609
+ path: identifier
610
+ };
704
611
  const extension = extname(identifier);
705
- if (extension === ".node" || isNodeBuiltin(identifier)) {
706
- return {
707
- type: "builtin",
708
- url: identifier,
709
- path: identifier
710
- };
711
- }
712
- if (this.isNetworkSupported && (identifier.startsWith("http:") || identifier.startsWith("https:"))) {
713
- return {
714
- type: "network",
715
- url: identifier,
716
- path: identifier
717
- };
718
- }
612
+ if (extension === ".node" || isNodeBuiltin(identifier)) return {
613
+ type: "builtin",
614
+ url: identifier,
615
+ path: identifier
616
+ };
617
+ if (this.isNetworkSupported && (identifier.startsWith("http:") || identifier.startsWith("https:"))) return {
618
+ type: "network",
619
+ url: identifier,
620
+ path: identifier
621
+ };
719
622
  const isFileUrl = identifier.startsWith("file://");
720
623
  const pathUrl = isFileUrl ? fileURLToPath(identifier.split("?")[0]) : identifier;
721
624
  const fileUrl = isFileUrl ? identifier : pathToFileURL(pathUrl).toString();
722
625
  let type;
723
- if (this.vite.canResolve(fileUrl)) {
724
- type = "vite";
725
- } else if (extension === ".mjs") {
726
- type = "module";
727
- } else if (extension === ".cjs") {
728
- type = "commonjs";
729
- } else if (extension === ".wasm") {
730
- // still experimental on NodeJS --experimental-wasm-modules
731
- // cf. ESM_FILE_FORMAT(url) in https://nodejs.org/docs/latest-v20.x/api/esm.html#resolution-algorithm
732
- type = "wasm";
733
- } else {
626
+ if (this.vite.canResolve(fileUrl)) type = "vite";
627
+ else if (extension === ".mjs") type = "module";
628
+ else if (extension === ".cjs") type = "commonjs";
629
+ else if (extension === ".wasm")
630
+ // still experimental on NodeJS --experimental-wasm-modules
631
+ // cf. ESM_FILE_FORMAT(url) in https://nodejs.org/docs/latest-v20.x/api/esm.html#resolution-algorithm
632
+ type = "wasm";
633
+ else {
734
634
  const pkgData = this.findNearestPackageData(normalize(pathUrl));
735
635
  type = pkgData.type === "module" ? "module" : "commonjs";
736
636
  }
@@ -764,46 +664,34 @@ class ExternalModulesExecutor {
764
664
  }
765
665
  }
766
666
  get isNetworkSupported() {
767
- if (this.#networkSupported == null) {
768
- if (process.execArgv.includes("--experimental-network-imports")) {
769
- this.#networkSupported = true;
770
- } else if (process.env.NODE_OPTIONS?.includes("--experimental-network-imports")) {
771
- this.#networkSupported = true;
772
- } else {
773
- this.#networkSupported = false;
774
- }
775
- }
667
+ if (this.#networkSupported == null) if (process.execArgv.includes("--experimental-network-imports")) this.#networkSupported = true;
668
+ else if (process.env.NODE_OPTIONS?.includes("--experimental-network-imports")) this.#networkSupported = true;
669
+ else this.#networkSupported = false;
776
670
  return this.#networkSupported;
777
671
  }
778
672
  }
779
673
 
780
674
  const { promises, readFileSync } = fs;
781
675
  class FileMap {
782
- fsCache = new Map();
783
- fsBufferCache = new Map();
676
+ fsCache = /* @__PURE__ */ new Map();
677
+ fsBufferCache = /* @__PURE__ */ new Map();
784
678
  async readFileAsync(path) {
785
679
  const cached = this.fsCache.get(path);
786
- if (cached != null) {
787
- return cached;
788
- }
680
+ if (cached != null) return cached;
789
681
  const source = await promises.readFile(path, "utf-8");
790
682
  this.fsCache.set(path, source);
791
683
  return source;
792
684
  }
793
685
  readFile(path) {
794
686
  const cached = this.fsCache.get(path);
795
- if (cached != null) {
796
- return cached;
797
- }
687
+ if (cached != null) return cached;
798
688
  const source = readFileSync(path, "utf-8");
799
689
  this.fsCache.set(path, source);
800
690
  return source;
801
691
  }
802
692
  readBuffer(path) {
803
693
  const cached = this.fsBufferCache.get(path);
804
- if (cached != null) {
805
- return cached;
806
- }
694
+ if (cached != null) return cached;
807
695
  const buffer = readFileSync(path);
808
696
  this.fsBufferCache.set(path, buffer);
809
697
  return buffer;
@@ -812,24 +700,20 @@ class FileMap {
812
700
 
813
701
  const entryFile = pathToFileURL(resolve(distDir, "workers/runVmTests.js")).href;
814
702
  const fileMap = new FileMap();
815
- const packageCache = new Map();
703
+ const packageCache = /* @__PURE__ */ new Map();
816
704
  async function runVmTests(method, state) {
817
705
  const { environment, ctx, rpc } = state;
818
706
  if (!environment.setupVM) {
819
707
  const envName = ctx.environment.name;
820
708
  const packageId = envName[0] === "." ? envName : `vitest-environment-${envName}`;
821
- throw new TypeError(`Environment "${ctx.environment.name}" is not a valid environment. ` + `Path "${packageId}" doesn't support vm environment because it doesn't provide "setupVM" method.`);
709
+ throw new TypeError(`Environment "${ctx.environment.name}" is not a valid environment. Path "${packageId}" doesn't support vm environment because it doesn't provide "setupVM" method.`);
822
710
  }
823
711
  const vm = await environment.setupVM(ctx.environment.options || ctx.config.environmentOptions || {});
824
712
  state.durations.environment = performance.now() - state.durations.environment;
825
713
  process.env.VITEST_VM_POOL = "1";
826
- if (!vm.getVmContext) {
827
- throw new TypeError(`Environment ${environment.name} doesn't provide "getVmContext" method. It should return a context created by "vm.createContext" method.`);
828
- }
714
+ if (!vm.getVmContext) throw new TypeError(`Environment ${environment.name} doesn't provide "getVmContext" method. It should return a context created by "vm.createContext" method.`);
829
715
  const context = vm.getVmContext();
830
- if (!isContext(context)) {
831
- throw new TypeError(`Environment ${environment.name} doesn't provide a valid context. It should be created by "vm.createContext" method.`);
832
- }
716
+ if (!isContext(context)) throw new TypeError(`Environment ${environment.name} doesn't provide a valid context. It should be created by "vm.createContext" method.`);
833
717
  provideWorkerState(context, state);
834
718
  // this is unfortunately needed for our own dependencies
835
719
  // we need to find a way to not rely on this by default
@@ -859,7 +743,7 @@ async function runVmTests(method, state) {
859
743
  const { run } = await executor.importExternalModule(entryFile);
860
744
  const fileSpecs = ctx.files.map((f) => typeof f === "string" ? {
861
745
  filepath: f,
862
- testLocations: undefined
746
+ testLocations: void 0
863
747
  } : f);
864
748
  try {
865
749
  await run(method, fileSpecs, ctx.config, executor);
@@ -1,5 +1,5 @@
1
1
  import { MessagePort } from 'node:worker_threads';
2
- import { C as ContextRPC } from './worker.d.BKbBp2ga.js';
2
+ import { C as ContextRPC } from './worker.d.tQu2eJQy.js';
3
3
 
4
4
  interface WorkerContext extends ContextRPC {
5
5
  port: MessagePort;
@@ -1,4 +1,4 @@
1
- import { File, TaskResultPack, TaskEventPack, CancelReason, FileSpecification, Task } from '@vitest/runner';
1
+ import { File, TestAnnotation, TaskResultPack, TaskEventPack, CancelReason, FileSpecification, Task } from '@vitest/runner';
2
2
  import { ViteNodeResolveId, ModuleCacheMap, ModuleExecutionInfo } from 'vite-node';
3
3
  import { a as SerializedConfig } from './config.d.D2ROskhv.js';
4
4
  import { T as TransformMode, U as UserConsoleLog, A as AfterSuiteRunMeta, E as Environment } from './environment.d.cL3nLXbE.js';
@@ -121,6 +121,7 @@ interface RuntimeRPC {
121
121
  onQueued: (file: File) => void;
122
122
  onCollected: (files: File[]) => Promise<void>;
123
123
  onAfterSuiteRun: (meta: AfterSuiteRunMeta) => void;
124
+ onTaskAnnotate: (testId: string, annotation: TestAnnotation) => Promise<TestAnnotation>;
124
125
  onTaskUpdate: (pack: TaskResultPack[], events: TaskEventPack[]) => Promise<void>;
125
126
  onCancel: (reason: CancelReason) => void;
126
127
  getCountOfFailedTests: () => number;
@@ -162,6 +163,7 @@ interface WorkerGlobalState {
162
163
  onCancel: Promise<CancelReason>;
163
164
  moduleCache: ModuleCacheMap;
164
165
  moduleExecutionInfo?: ModuleExecutionInfo;
166
+ onCleanup: (listener: () => unknown) => void;
165
167
  providedContext: Record<string, any>;
166
168
  durations: {
167
169
  environment: number
package/dist/cli.js CHANGED
@@ -1,16 +1,16 @@
1
- import { c as createCLI } from './chunks/cac.DWaWHIIE.js';
1
+ import { c as createCLI } from './chunks/cac.C8BzMmTW.js';
2
2
  import '@vitest/utils';
3
3
  import 'events';
4
4
  import 'pathe';
5
5
  import 'tinyrainbow';
6
6
  import './chunks/constants.DnKduX2e.js';
7
- import './chunks/index.Bter3jj9.js';
7
+ import './chunks/index.BZ0g1JD2.js';
8
8
  import 'node:perf_hooks';
9
9
  import '@vitest/runner/utils';
10
10
  import '@vitest/utils/source-map';
11
- import './chunks/env.Dq0hM4Xv.js';
11
+ import './chunks/env.D4Lgay0q.js';
12
12
  import 'std-env';
13
- import './chunks/typechecker.BgzF-6iO.js';
13
+ import './chunks/typechecker.DRKU1-1g.js';
14
14
  import 'node:os';
15
15
  import 'tinyexec';
16
16
  import './path.js';
package/dist/config.cjs CHANGED
@@ -13,7 +13,7 @@ const extraInlineDeps = [
13
13
  ];
14
14
 
15
15
  const isNode = typeof process < "u" && typeof process.stdout < "u" && !process.versions?.deno && !globalThis.window;
16
- const isDeno = typeof process < "u" && typeof process.stdout < "u" && process.versions?.deno !== undefined;
16
+ const isDeno = typeof process < "u" && typeof process.stdout < "u" && process.versions?.deno !== void 0;
17
17
  (isNode || isDeno) && process.platform === "win32";
18
18
  (isNode || isDeno) && process.stdout?.isTTY && !stdEnv.isCI;
19
19