vitest 2.0.3 → 2.0.5

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 (78) hide show
  1. package/LICENSE.md +21 -0
  2. package/dist/browser.d.ts +21 -42
  3. package/dist/browser.js +5 -5
  4. package/dist/{vendor/base.CC6UHsNs.js → chunks/base.CC5R_kgU.js} +3 -3
  5. package/dist/{vendor/base.CTYV4Gnz.js → chunks/base.DSsbfkDg.js} +5 -4
  6. package/dist/{vendor/benchmark.B6pblCp2.js → chunks/benchmark.DDmpNjj-.js} +1 -1
  7. package/dist/chunks/benchmark.puBFxyfE.d.ts +22 -0
  8. package/dist/{vendor/cac.DUiZvzF_.js → chunks/cac.DGgmCKmU.js} +18 -21
  9. package/dist/{vendor/cli-api.CsgSG1Ir.js → chunks/cli-api.OKfd3qJ0.js} +666 -487
  10. package/dist/chunks/config.DCnyCTbs.d.ts +203 -0
  11. package/dist/chunks/{runtime-console.C2L2zykk.js → console.Bgn7_A1x.js} +11 -14
  12. package/dist/{vendor/constants.CsnA4eRy.js → chunks/constants.CaAN7icJ.js} +1 -3
  13. package/dist/{vendor/coverage.BhYSDdTT.js → chunks/coverage.CqfT4xaf.js} +4 -7
  14. package/dist/chunks/{browser-creator.CyaOd8pl.js → creator.a3OfuIEW.js} +8 -8
  15. package/dist/{vendor/env.2ltrQNq0.js → chunks/env.BU041cs9.js} +2 -3
  16. package/dist/chunks/environment.0M5R1SX_.d.ts +173 -0
  17. package/dist/{vendor/execute.Dx503nGn.js → chunks/execute.Cjlr2CRw.js} +28 -20
  18. package/dist/chunks/globals.BliuJFNR.js +31 -0
  19. package/dist/{vendor/index.Hqvcg1pf.js → chunks/index.BfeNhc0N.js} +43 -43
  20. package/dist/{vendor/index.D6GZqexG.js → chunks/index.CM5UI-4O.js} +2 -2
  21. package/dist/{vendor/index.BJmtb_7W.js → chunks/index.DYufA6CZ.js} +2 -2
  22. package/dist/{vendor/index.BCwvoAaf.js → chunks/index.JbiJutJ_.js} +516 -258
  23. package/dist/{vendor/index.CROIsoiT.js → chunks/index.R1VjssW9.js} +11 -12
  24. package/dist/{vendor/index.D4nqnQWz.js → chunks/index.lVXYBqEP.js} +1 -18
  25. package/dist/{vendor/inspector.-FCQUzqR.js → chunks/inspector.70d6emsh.js} +4 -5
  26. package/dist/chunks/{environments-node.XE5FbRPQ.js → node.DS3zEPa7.js} +2 -2
  27. package/dist/{reporters-BECoY4-b.d.ts → chunks/reporters.C_zwCd4j.d.ts} +850 -1003
  28. package/dist/{vendor/rpc.BGx7q_k2.js → chunks/rpc.B7Mfb-Yf.js} +3 -5
  29. package/dist/{vendor/run-once.Db8Hgq9X.js → chunks/run-once.Sxe67Wng.js} +1 -1
  30. package/dist/chunks/{runtime-runBaseTests.hkIOeriM.js → runBaseTests.CyvqmuC9.js} +35 -27
  31. package/dist/{vendor/setup-common.yHaxjRhz.js → chunks/setup-common.CNzatKMx.js} +2 -2
  32. package/dist/{suite-BWgaIsVn.d.ts → chunks/suite.CcK46U-P.d.ts} +1 -1
  33. package/dist/{vendor/tasks.DhVtQBtW.js → chunks/tasks.BZnCS9aT.js} +2 -3
  34. package/dist/{vendor/utils.DkxLWvS1.js → chunks/utils.C3_cBsyn.js} +3 -4
  35. package/dist/{vendor/global.7bFbnyXl.js → chunks/utils.Ck2hJTRs.js} +1 -1
  36. package/dist/{vendor/utils.DyTe1Nxn.js → chunks/utils.DpP_sDwr.js} +8 -21
  37. package/dist/{vendor/vi.DXACdGTu.js → chunks/vi.fiQ7lMRF.js} +13 -18
  38. package/dist/{vendor/vm.D1T5Rxan.js → chunks/vm.DcSuuaHr.js} +40 -68
  39. package/dist/chunks/worker.C5iHKIaJ.d.ts +144 -0
  40. package/dist/chunks/worker.DKkAC4Qw.d.ts +8 -0
  41. package/dist/cli.js +3 -3
  42. package/dist/config.cjs +6 -9
  43. package/dist/config.d.ts +10 -8
  44. package/dist/config.js +6 -9
  45. package/dist/coverage.d.ts +10 -8
  46. package/dist/coverage.js +11 -7
  47. package/dist/environments.d.ts +3 -19
  48. package/dist/environments.js +1 -1
  49. package/dist/execute.d.ts +8 -17
  50. package/dist/execute.js +2 -2
  51. package/dist/index.d.ts +267 -34
  52. package/dist/index.js +12 -12
  53. package/dist/node.d.ts +15 -9
  54. package/dist/node.js +16 -19
  55. package/dist/reporters.d.ts +10 -8
  56. package/dist/reporters.js +12 -15
  57. package/dist/runners.d.ts +7 -19
  58. package/dist/runners.js +12 -13
  59. package/dist/snapshot.js +3 -3
  60. package/dist/suite.d.ts +2 -16
  61. package/dist/suite.js +4 -4
  62. package/dist/worker.js +7 -8
  63. package/dist/workers/forks.js +5 -5
  64. package/dist/workers/runVmTests.js +32 -23
  65. package/dist/workers/threads.js +5 -5
  66. package/dist/workers/vmForks.js +8 -8
  67. package/dist/workers/vmThreads.js +8 -8
  68. package/dist/workers.d.ts +13 -8
  69. package/dist/workers.js +13 -13
  70. package/package.json +15 -15
  71. package/dist/chunks/integrations-globals.CzYWb38r.js +0 -31
  72. /package/dist/{vendor → chunks}/_commonjsHelpers.BFTU3MAI.js +0 -0
  73. /package/dist/{vendor → chunks}/date.W2xKR2qe.js +0 -0
  74. /package/dist/chunks/{node-git.ZtkbKc8u.js → git.ZtkbKc8u.js} +0 -0
  75. /package/dist/{vendor → chunks}/index.BMmMjLIQ.js +0 -0
  76. /package/dist/{vendor → chunks}/index.BpSiYbpB.js +0 -0
  77. /package/dist/chunks/{install-pkg.DNUmWFkO.js → index.DNUmWFkO.js} +0 -0
  78. /package/dist/{vendor → chunks}/spy.Cf_4R5Oe.js +0 -0
@@ -1,8 +1,8 @@
1
1
  import vm, { isContext } from 'node:vm';
2
2
  import { fileURLToPath, pathToFileURL } from 'node:url';
3
3
  import { dirname, basename, extname, normalize, join, resolve } from 'pathe';
4
- import { createCustomConsole } from '../chunks/runtime-console.C2L2zykk.js';
5
- import { g as getDefaultRequestStubs, s as startVitestExecutor } from './execute.Dx503nGn.js';
4
+ import { createCustomConsole } from './console.Bgn7_A1x.js';
5
+ import { g as getDefaultRequestStubs, s as startVitestExecutor } from './execute.Cjlr2CRw.js';
6
6
  import { distDir } from '../path.js';
7
7
  import { dirname as dirname$1 } from 'node:path';
8
8
  import fs from 'node:fs';
@@ -11,8 +11,8 @@ import { createRequire, Module } from 'node:module';
11
11
  import { CSS_LANGS_RE, KNOWN_ASSET_RE } from 'vite-node/constants';
12
12
  import '@vitest/runner/utils';
13
13
  import '@vitest/utils';
14
- import { p as provideWorkerState } from './global.7bFbnyXl.js';
15
- import './env.2ltrQNq0.js';
14
+ import { p as provideWorkerState } from './utils.Ck2hJTRs.js';
15
+ import './env.BU041cs9.js';
16
16
 
17
17
  const _require = createRequire(import.meta.url);
18
18
  const requiresCache = /* @__PURE__ */ new WeakMap();
@@ -84,7 +84,7 @@ class CommonjsExecutor {
84
84
  }
85
85
  // exposed for external use, Node.js does the opposite
86
86
  static _load = (request, parent, _isMain) => {
87
- const require = Module$1.createRequire((parent == null ? void 0 : parent.filename) ?? request);
87
+ const require = Module$1.createRequire(parent?.filename ?? request);
88
88
  return require(request);
89
89
  };
90
90
  static wrap = (script) => {
@@ -240,8 +240,7 @@ function interopCommonJsModule(interopDefault, mod) {
240
240
  keys: Array.from(allKeys),
241
241
  moduleExports: new Proxy(mod, {
242
242
  get(mod2, prop) {
243
- var _a;
244
- return mod2[prop] ?? ((_a = mod2.default) == null ? void 0 : _a[prop]);
243
+ return mod2[prop] ?? mod2.default?.[prop];
245
244
  }
246
245
  }),
247
246
  defaultExport: mod
@@ -256,26 +255,16 @@ function interopCommonJsModule(interopDefault, mod) {
256
255
  const SyntheticModule$1 = vm.SyntheticModule;
257
256
  const SourceTextModule = vm.SourceTextModule;
258
257
 
259
- var __defProp$1 = Object.defineProperty;
260
- var __typeError$1 = (msg) => {
261
- throw TypeError(msg);
262
- };
263
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
264
- var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
265
- var __accessCheck$1 = (obj, member, msg) => member.has(obj) || __typeError$1("Cannot " + msg);
266
- var __privateGet$1 = (obj, member, getter) => (__accessCheck$1(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
267
- var __privateAdd$1 = (obj, member, value) => member.has(obj) ? __typeError$1("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
268
- var _httpIp;
269
258
  const dataURIRegex = /^data:(?<mime>text\/javascript|application\/json|application\/wasm)(?:;(?<encoding>charset=utf-8|base64))?,(?<code>.*)$/;
270
259
  class EsmExecutor {
271
260
  constructor(executor, options) {
272
261
  this.executor = executor;
273
- __publicField$1(this, "moduleCache", /* @__PURE__ */ new Map());
274
- __publicField$1(this, "esmLinkMap", /* @__PURE__ */ new WeakMap());
275
- __publicField$1(this, "context");
276
- __privateAdd$1(this, _httpIp, IPnumber("127.0.0.0"));
277
262
  this.context = options.context;
278
263
  }
264
+ moduleCache = /* @__PURE__ */ new Map();
265
+ esmLinkMap = /* @__PURE__ */ new WeakMap();
266
+ context;
267
+ #httpIp = IPnumber("127.0.0.0");
279
268
  async evaluateModule(m) {
280
269
  if (m.status === "unlinked") {
281
270
  this.esmLinkMap.set(
@@ -344,7 +333,7 @@ class EsmExecutor {
344
333
  async createNetworkModule(fileUrl) {
345
334
  if (fileUrl.startsWith("http:")) {
346
335
  const url = new URL(fileUrl);
347
- if (url.hostname !== "localhost" && url.hostname !== "::1" && (IPnumber(url.hostname) & IPmask(8)) !== __privateGet$1(this, _httpIp)) {
336
+ if (url.hostname !== "localhost" && url.hostname !== "::1" && (IPnumber(url.hostname) & IPmask(8)) !== this.#httpIp) {
348
337
  throw new Error(
349
338
  // we don't know the importer, so it's undefined (the same happens in --pool=threads)
350
339
  `import of '${fileUrl}' by undefined is not supported: http can only be used to load local resources (use https instead).`
@@ -447,7 +436,6 @@ class EsmExecutor {
447
436
  return this.createEsModule(identifier, () => code);
448
437
  }
449
438
  }
450
- _httpIp = new WeakMap();
451
439
  function IPnumber(address) {
452
440
  const ip = address.match(/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/);
453
441
  if (ip) {
@@ -484,7 +472,7 @@ class ViteExecutor {
484
472
  getPackageName(modulePath) {
485
473
  const path = normalize(modulePath);
486
474
  let name = path.split("/node_modules/").pop() || "";
487
- if (name == null ? void 0 : name.startsWith("@")) {
475
+ if (name?.startsWith("@")) {
488
476
  name = name.split("/").slice(0, 2).join("/");
489
477
  } else {
490
478
  name = name.split("/")[0];
@@ -530,7 +518,6 @@ class ViteExecutor {
530
518
  return module;
531
519
  }
532
520
  canResolve = (fileUrl) => {
533
- var _a;
534
521
  const transformMode = this.workerState.environment.transformMode;
535
522
  if (transformMode !== "web") {
536
523
  return false;
@@ -538,7 +525,7 @@ class ViteExecutor {
538
525
  if (fileUrl === CLIENT_FILE) {
539
526
  return true;
540
527
  }
541
- const config = ((_a = this.workerState.config.deps) == null ? void 0 : _a.web) || {};
528
+ const config = this.workerState.config.deps?.web || {};
542
529
  const [modulePath] = fileUrl.split("?");
543
530
  if (config.transformCss && CSS_LANGS_RE.test(modulePath)) {
544
531
  return true;
@@ -555,42 +542,12 @@ class ViteExecutor {
555
542
  };
556
543
  }
557
544
 
558
- var __defProp = Object.defineProperty;
559
- var __typeError = (msg) => {
560
- throw TypeError(msg);
561
- };
562
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
563
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
564
- var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
565
- var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
566
- var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
567
- var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value);
568
- var _networkSupported;
569
545
  const SyntheticModule = vm.SyntheticModule;
570
546
  const { existsSync, statSync } = fs;
571
547
  const nativeResolve = import.meta.resolve;
572
548
  class ExternalModulesExecutor {
573
549
  constructor(options) {
574
550
  this.options = options;
575
- __publicField(this, "cjs");
576
- __publicField(this, "esm");
577
- __publicField(this, "vite");
578
- __publicField(this, "context");
579
- __publicField(this, "fs");
580
- __publicField(this, "resolvers", []);
581
- __privateAdd(this, _networkSupported, null);
582
- // dynamic import can be used in both ESM and CJS, so we have it in the executor
583
- __publicField(this, "importModuleDynamically", async (specifier, referencer) => {
584
- const module = await this.resolveModule(specifier, referencer.identifier);
585
- return await this.esm.evaluateModule(module);
586
- });
587
- __publicField(this, "resolveModule", async (specifier, referencer) => {
588
- let identifier = this.resolve(specifier, referencer);
589
- if (identifier instanceof Promise) {
590
- identifier = await identifier;
591
- }
592
- return await this.createModule(identifier);
593
- });
594
551
  this.context = options.context;
595
552
  this.fs = options.fileMap;
596
553
  this.esm = new EsmExecutor(this, {
@@ -609,6 +566,13 @@ class ExternalModulesExecutor {
609
566
  });
610
567
  this.resolvers = [this.vite.resolve];
611
568
  }
569
+ cjs;
570
+ esm;
571
+ vite;
572
+ context;
573
+ fs;
574
+ resolvers = [];
575
+ #networkSupported = null;
612
576
  async import(identifier) {
613
577
  const module = await this.createModule(identifier);
614
578
  await this.esm.evaluateModule(module);
@@ -620,6 +584,18 @@ class ExternalModulesExecutor {
620
584
  createRequire(identifier) {
621
585
  return this.cjs.createRequire(identifier);
622
586
  }
587
+ // dynamic import can be used in both ESM and CJS, so we have it in the executor
588
+ importModuleDynamically = async (specifier, referencer) => {
589
+ const module = await this.resolveModule(specifier, referencer.identifier);
590
+ return await this.esm.evaluateModule(module);
591
+ };
592
+ resolveModule = async (specifier, referencer) => {
593
+ let identifier = this.resolve(specifier, referencer);
594
+ if (identifier instanceof Promise) {
595
+ identifier = await identifier;
596
+ }
597
+ return await this.createModule(identifier);
598
+ };
623
599
  resolve(specifier, parent) {
624
600
  for (const resolver of this.resolvers) {
625
601
  const id = resolver(specifier, parent);
@@ -630,7 +606,6 @@ class ExternalModulesExecutor {
630
606
  return nativeResolve(specifier, parent);
631
607
  }
632
608
  findNearestPackageData(basedir) {
633
- var _a;
634
609
  const originalBasedir = basedir;
635
610
  const packageCache = this.options.packageCache;
636
611
  while (basedir) {
@@ -640,7 +615,7 @@ class ExternalModulesExecutor {
640
615
  }
641
616
  const pkgPath = join(basedir, "package.json");
642
617
  try {
643
- if ((_a = statSync(pkgPath, { throwIfNoEntry: false })) == null ? void 0 : _a.isFile()) {
618
+ if (statSync(pkgPath, { throwIfNoEntry: false })?.isFile()) {
644
619
  const pkgData = JSON.parse(this.fs.readFile(pkgPath));
645
620
  if (packageCache) {
646
621
  setCacheData(packageCache, pkgData, basedir, originalBasedir);
@@ -756,20 +731,18 @@ class ExternalModulesExecutor {
756
731
  }
757
732
  }
758
733
  get isNetworkSupported() {
759
- var _a;
760
- if (__privateGet(this, _networkSupported) == null) {
734
+ if (this.#networkSupported == null) {
761
735
  if (process.execArgv.includes("--experimental-network-imports")) {
762
- __privateSet(this, _networkSupported, true);
763
- } else if ((_a = process.env.NODE_OPTIONS) == null ? void 0 : _a.includes("--experimental-network-imports")) {
764
- __privateSet(this, _networkSupported, true);
736
+ this.#networkSupported = true;
737
+ } else if (process.env.NODE_OPTIONS?.includes("--experimental-network-imports")) {
738
+ this.#networkSupported = true;
765
739
  } else {
766
- __privateSet(this, _networkSupported, false);
740
+ this.#networkSupported = false;
767
741
  }
768
742
  }
769
- return __privateGet(this, _networkSupported);
743
+ return this.#networkSupported;
770
744
  }
771
745
  }
772
- _networkSupported = new WeakMap();
773
746
 
774
747
  const { promises, readFileSync } = fs;
775
748
  class FileMap {
@@ -808,7 +781,6 @@ const entryFile = pathToFileURL(resolve(distDir, "workers/runVmTests.js")).href;
808
781
  const fileMap = new FileMap();
809
782
  const packageCache = /* @__PURE__ */ new Map();
810
783
  async function runVmTests(method, state) {
811
- var _a;
812
784
  const { environment, ctx, rpc } = state;
813
785
  if (!environment.setupVM) {
814
786
  const envName = ctx.environment.name;
@@ -862,7 +834,7 @@ async function runVmTests(method, state) {
862
834
  try {
863
835
  await run(method, ctx.files, ctx.config, executor);
864
836
  } finally {
865
- await ((_a = vm.teardown) == null ? void 0 : _a.call(vm));
837
+ await vm.teardown?.();
866
838
  state.environmentTeardownRun = true;
867
839
  }
868
840
  }
@@ -0,0 +1,144 @@
1
+ import { FetchResult, ViteNodeResolveId, RawSourceMap, ModuleCacheMap } from 'vite-node';
2
+ import { File, TaskResultPack, CancelReason, Task } from '@vitest/runner';
3
+ import { S as SerializedConfig } from './config.DCnyCTbs.js';
4
+ import { SnapshotResult } from '@vitest/snapshot';
5
+ import { T as TransformMode, U as UserConsoleLog, A as AfterSuiteRunMeta, E as Environment } from './environment.0M5R1SX_.js';
6
+
7
+ type MockFactoryWithHelper<M = unknown> = (importOriginal: <T extends M>() => Promise<T>) => any;
8
+ type MockFactory = () => any;
9
+ type MockMap = Map<string, Record<string, string | null | MockFactory>>;
10
+ interface PendingSuiteMock {
11
+ id: string;
12
+ importer: string;
13
+ type: 'mock' | 'unmock';
14
+ throwIfCached: boolean;
15
+ factory?: MockFactory;
16
+ }
17
+
18
+ interface RuntimeRPC {
19
+ fetch: (id: string, transformMode: TransformMode) => Promise<{
20
+ externalize?: string;
21
+ id?: string;
22
+ }>;
23
+ transform: (id: string, transformMode: TransformMode) => Promise<FetchResult>;
24
+ resolveId: (id: string, importer: string | undefined, transformMode: TransformMode) => Promise<ViteNodeResolveId | null>;
25
+ getSourceMap: (id: string, force?: boolean) => Promise<RawSourceMap | undefined>;
26
+ onFinished: (files: File[], errors?: unknown[]) => void;
27
+ onPathsCollected: (paths: string[]) => void;
28
+ onUserConsoleLog: (log: UserConsoleLog) => void;
29
+ onUnhandledError: (err: unknown, type: string) => void;
30
+ onCollected: (files: File[]) => Promise<void>;
31
+ onAfterSuiteRun: (meta: AfterSuiteRunMeta) => void;
32
+ onTaskUpdate: (pack: TaskResultPack[]) => Promise<void>;
33
+ onCancel: (reason: CancelReason) => void;
34
+ getCountOfFailedTests: () => number;
35
+ snapshotSaved: (snapshot: SnapshotResult) => void;
36
+ resolveSnapshotPath: (testPath: string) => string;
37
+ }
38
+ interface RunnerRPC {
39
+ onCancel: (reason: CancelReason) => void;
40
+ }
41
+
42
+ type ArgumentsType<T> = T extends (...args: infer A) => any ? A : never;
43
+ type ReturnType<T> = T extends (...args: any) => infer R ? R : never;
44
+ type PromisifyFn<T> = ReturnType<T> extends Promise<any> ? T : (...args: ArgumentsType<T>) => Promise<Awaited<ReturnType<T>>>;
45
+ type BirpcResolver = (name: string, resolved: (...args: unknown[]) => unknown) => ((...args: unknown[]) => unknown) | undefined;
46
+ interface ChannelOptions {
47
+ /**
48
+ * Function to post raw message
49
+ */
50
+ post: (data: any, ...extras: any[]) => any | Promise<any>;
51
+ /**
52
+ * Listener to receive raw message
53
+ */
54
+ on: (fn: (data: any, ...extras: any[]) => void) => any | Promise<any>;
55
+ /**
56
+ * Custom function to serialize data
57
+ *
58
+ * by default it passes the data as-is
59
+ */
60
+ serialize?: (data: any) => any;
61
+ /**
62
+ * Custom function to deserialize data
63
+ *
64
+ * by default it passes the data as-is
65
+ */
66
+ deserialize?: (data: any) => any;
67
+ }
68
+ interface EventOptions<Remote> {
69
+ /**
70
+ * Names of remote functions that do not need response.
71
+ */
72
+ eventNames?: (keyof Remote)[];
73
+ /**
74
+ * Maximum timeout for waiting for response, in milliseconds.
75
+ *
76
+ * @default 60_000
77
+ */
78
+ timeout?: number;
79
+ /**
80
+ * Custom resolver to resolve function to be called
81
+ *
82
+ * For advanced use cases only
83
+ */
84
+ resolver?: BirpcResolver;
85
+ /**
86
+ * Custom error handler
87
+ */
88
+ onError?: (error: Error, functionName: string, args: any[]) => boolean | void;
89
+ /**
90
+ * Custom error handler for timeouts
91
+ */
92
+ onTimeoutError?: (functionName: string, args: any[]) => boolean | void;
93
+ }
94
+ type BirpcOptions<Remote> = EventOptions<Remote> & ChannelOptions;
95
+ type BirpcFn<T> = PromisifyFn<T> & {
96
+ /**
97
+ * Send event without asking for response
98
+ */
99
+ asEvent: (...args: ArgumentsType<T>) => void;
100
+ };
101
+ type BirpcReturn<RemoteFunctions, LocalFunctions = Record<string, never>> = {
102
+ [K in keyof RemoteFunctions]: BirpcFn<RemoteFunctions[K]>;
103
+ } & {
104
+ $functions: LocalFunctions;
105
+ };
106
+
107
+ /** @deprecated unused */
108
+ type ResolveIdFunction = (id: string, importer?: string) => Promise<ViteNodeResolveId | null>;
109
+ type WorkerRPC = BirpcReturn<RuntimeRPC, RunnerRPC>;
110
+ interface ContextTestEnvironment {
111
+ name: string;
112
+ transformMode?: TransformMode;
113
+ options: Record<string, any> | null;
114
+ }
115
+ interface ContextRPC {
116
+ pool: string;
117
+ worker: string;
118
+ workerId: number;
119
+ config: SerializedConfig;
120
+ projectName: string;
121
+ files: string[];
122
+ environment: ContextTestEnvironment;
123
+ providedContext: Record<string, any>;
124
+ invalidates?: string[];
125
+ }
126
+ interface WorkerGlobalState {
127
+ ctx: ContextRPC;
128
+ config: SerializedConfig;
129
+ rpc: WorkerRPC;
130
+ current?: Task;
131
+ filepath?: string;
132
+ environment: Environment;
133
+ environmentTeardownRun?: boolean;
134
+ onCancel: Promise<CancelReason>;
135
+ moduleCache: ModuleCacheMap;
136
+ mockMap: MockMap;
137
+ providedContext: Record<string, any>;
138
+ durations: {
139
+ environment: number;
140
+ prepare: number;
141
+ };
142
+ }
143
+
144
+ export type { BirpcOptions as B, ContextRPC as C, MockFactoryWithHelper as M, PendingSuiteMock as P, RuntimeRPC as R, WorkerGlobalState as W, BirpcReturn as a, RunnerRPC as b, ResolveIdFunction as c, WorkerRPC as d, ContextTestEnvironment as e, MockFactory as f, MockMap as g };
@@ -0,0 +1,8 @@
1
+ import { MessagePort } from 'node:worker_threads';
2
+ import { C as ContextRPC } from './worker.C5iHKIaJ.js';
3
+
4
+ interface WorkerContext extends ContextRPC {
5
+ port: MessagePort;
6
+ }
7
+
8
+ export type { WorkerContext as W };
package/dist/cli.js CHANGED
@@ -1,9 +1,9 @@
1
- import { c as createCLI } from './vendor/cac.DUiZvzF_.js';
1
+ import { c as createCLI } from './chunks/cac.DGgmCKmU.js';
2
2
  import 'pathe';
3
3
  import 'events';
4
4
  import 'tinyrainbow';
5
- import './vendor/base.CTYV4Gnz.js';
5
+ import './chunks/base.DSsbfkDg.js';
6
6
  import '@vitest/utils';
7
- import './vendor/constants.CsnA4eRy.js';
7
+ import './chunks/constants.CaAN7icJ.js';
8
8
 
9
9
  createCLI().parse();
package/dist/config.cjs CHANGED
@@ -4,9 +4,8 @@ var os = require('node:os');
4
4
  var stdEnv = require('std-env');
5
5
  var vite = require('vite');
6
6
 
7
- var _a$1, _b$1;
8
- const isNode = typeof process < "u" && typeof process.stdout < "u" && !((_a$1 = process.versions) == null ? void 0 : _a$1.deno) && !globalThis.window;
9
- const isDeno = typeof process < "u" && typeof process.stdout < "u" && ((_b$1 = process.versions) == null ? void 0 : _b$1.deno) !== void 0;
7
+ const isNode = typeof process < "u" && typeof process.stdout < "u" && !process.versions?.deno && !globalThis.window;
8
+ const isDeno = typeof process < "u" && typeof process.stdout < "u" && process.versions?.deno !== void 0;
10
9
  (isNode || isDeno) && process.platform === "win32";
11
10
 
12
11
  const defaultBrowserPort = 63315;
@@ -14,12 +13,9 @@ const extraInlineDeps = [
14
13
  /^(?!.*node_modules).*\.mjs$/,
15
14
  /^(?!.*node_modules).*\.cjs\.js$/,
16
15
  // Vite client
17
- /vite\w*\/dist\/client\/env.mjs/,
18
- // Nuxt
19
- "@nuxt/test-utils"
16
+ /vite\w*\/dist\/client\/env.mjs/
20
17
  ];
21
18
 
22
- var _a, _b;
23
19
  const defaultInclude = ["**/*.{test,spec}.?(c|m)[jt]s?(x)"];
24
20
  const defaultExclude = [
25
21
  "**/node_modules/**",
@@ -68,7 +64,6 @@ const coverageConfigDefaults = {
68
64
  ".mjs",
69
65
  ".ts",
70
66
  ".mts",
71
- ".cts",
72
67
  ".tsx",
73
68
  ".jsx",
74
69
  ".vue",
@@ -79,7 +74,7 @@ const coverageConfigDefaults = {
79
74
  ignoreEmptyLines: true,
80
75
  processingConcurrency: Math.min(
81
76
  20,
82
- ((_b = (_a = os).availableParallelism) == null ? void 0 : _b.call(_a)) ?? os.cpus().length
77
+ os.availableParallelism?.() ?? os.cpus().length
83
78
  )
84
79
  };
85
80
  const fakeTimersDefaults = {
@@ -105,6 +100,8 @@ const config = {
105
100
  clearMocks: false,
106
101
  restoreMocks: false,
107
102
  mockReset: false,
103
+ unstubGlobals: false,
104
+ unstubEnvs: false,
108
105
  include: defaultInclude,
109
106
  exclude: defaultExclude,
110
107
  teardownTimeout: 1e4,
package/dist/config.d.ts CHANGED
@@ -1,18 +1,20 @@
1
+ export { ap as UserConfigExport, ao as UserConfigFn, am as UserConfigFnObject, an as UserConfigFnPromise, ar as UserProjectConfigExport, aq as UserProjectConfigFn, z as UserWorkspaceConfig, aw as configDefaults, az as coverageConfigDefaults, av as defaultBrowserPort, ay as defaultExclude, ax as defaultInclude, as as defineConfig, at as defineProject, au as defineWorkspace, aA as extraInlineDeps } from './chunks/reporters.C_zwCd4j.js';
1
2
  export { ConfigEnv, Plugin, UserConfig, mergeConfig } from 'vite';
2
- export { aO as UserConfigExport, aN as UserConfigFn, aL as UserConfigFnObject, aM as UserConfigFnPromise, aQ as UserProjectConfigExport, aP as UserProjectConfigFn, K as UserWorkspaceConfig, aV as configDefaults, aY as coverageConfigDefaults, aU as defaultBrowserPort, aX as defaultExclude, aW as defaultInclude, aR as defineConfig, aS as defineProject, aT as defineWorkspace, aZ as extraInlineDeps } from './reporters-BECoY4-b.js';
3
- import '@vitest/pretty-format';
4
3
  import '@vitest/runner';
5
- import 'vite-node';
4
+ import '@vitest/pretty-format';
5
+ import './chunks/config.DCnyCTbs.js';
6
6
  import '@vitest/snapshot';
7
- import '@vitest/expect';
8
- import '@vitest/runner/utils';
9
- import '@vitest/utils';
10
- import 'tinybench';
7
+ import '@vitest/snapshot/environment';
8
+ import 'vite-node';
9
+ import './chunks/environment.0M5R1SX_.js';
11
10
  import 'node:stream';
12
11
  import 'vite-node/client';
13
12
  import '@vitest/snapshot/manager';
14
13
  import 'vite-node/server';
15
- import 'node:worker_threads';
14
+ import '@vitest/utils';
16
15
  import '@vitest/utils/source-map';
17
16
  import 'node:fs';
18
17
  import 'chai';
18
+ import './chunks/benchmark.puBFxyfE.js';
19
+ import '@vitest/runner/utils';
20
+ import 'tinybench';
package/dist/config.js CHANGED
@@ -2,9 +2,8 @@ import os from 'node:os';
2
2
  import { isCI } from 'std-env';
3
3
  export { mergeConfig } from 'vite';
4
4
 
5
- var _a$1, _b$1;
6
- const isNode = typeof process < "u" && typeof process.stdout < "u" && !((_a$1 = process.versions) == null ? void 0 : _a$1.deno) && !globalThis.window;
7
- const isDeno = typeof process < "u" && typeof process.stdout < "u" && ((_b$1 = process.versions) == null ? void 0 : _b$1.deno) !== void 0;
5
+ const isNode = typeof process < "u" && typeof process.stdout < "u" && !process.versions?.deno && !globalThis.window;
6
+ const isDeno = typeof process < "u" && typeof process.stdout < "u" && process.versions?.deno !== void 0;
8
7
  (isNode || isDeno) && process.platform === "win32";
9
8
 
10
9
  const defaultBrowserPort = 63315;
@@ -12,12 +11,9 @@ const extraInlineDeps = [
12
11
  /^(?!.*node_modules).*\.mjs$/,
13
12
  /^(?!.*node_modules).*\.cjs\.js$/,
14
13
  // Vite client
15
- /vite\w*\/dist\/client\/env.mjs/,
16
- // Nuxt
17
- "@nuxt/test-utils"
14
+ /vite\w*\/dist\/client\/env.mjs/
18
15
  ];
19
16
 
20
- var _a, _b;
21
17
  const defaultInclude = ["**/*.{test,spec}.?(c|m)[jt]s?(x)"];
22
18
  const defaultExclude = [
23
19
  "**/node_modules/**",
@@ -66,7 +62,6 @@ const coverageConfigDefaults = {
66
62
  ".mjs",
67
63
  ".ts",
68
64
  ".mts",
69
- ".cts",
70
65
  ".tsx",
71
66
  ".jsx",
72
67
  ".vue",
@@ -77,7 +72,7 @@ const coverageConfigDefaults = {
77
72
  ignoreEmptyLines: true,
78
73
  processingConcurrency: Math.min(
79
74
  20,
80
- ((_b = (_a = os).availableParallelism) == null ? void 0 : _b.call(_a)) ?? os.cpus().length
75
+ os.availableParallelism?.() ?? os.cpus().length
81
76
  )
82
77
  };
83
78
  const fakeTimersDefaults = {
@@ -103,6 +98,8 @@ const config = {
103
98
  clearMocks: false,
104
99
  restoreMocks: false,
105
100
  mockReset: false,
101
+ unstubGlobals: false,
102
+ unstubEnvs: false,
106
103
  include: defaultInclude,
107
104
  exclude: defaultExclude,
108
105
  teardownTimeout: 1e4,
@@ -1,21 +1,23 @@
1
- import { B as BaseCoverageOptions, a as ResolvedCoverageOptions } from './reporters-BECoY4-b.js';
1
+ import { B as BaseCoverageOptions, R as ResolvedCoverageOptions } from './chunks/reporters.C_zwCd4j.js';
2
+ import '@vitest/runner';
2
3
  import 'vite';
3
4
  import '@vitest/pretty-format';
4
- import '@vitest/runner';
5
- import 'vite-node';
5
+ import './chunks/config.DCnyCTbs.js';
6
6
  import '@vitest/snapshot';
7
- import '@vitest/expect';
8
- import '@vitest/runner/utils';
9
- import '@vitest/utils';
10
- import 'tinybench';
7
+ import '@vitest/snapshot/environment';
8
+ import 'vite-node';
9
+ import './chunks/environment.0M5R1SX_.js';
11
10
  import 'node:stream';
12
11
  import 'vite-node/client';
13
12
  import '@vitest/snapshot/manager';
14
13
  import 'vite-node/server';
15
- import 'node:worker_threads';
14
+ import '@vitest/utils';
16
15
  import '@vitest/utils/source-map';
17
16
  import 'node:fs';
18
17
  import 'chai';
18
+ import './chunks/benchmark.puBFxyfE.js';
19
+ import '@vitest/runner/utils';
20
+ import 'tinybench';
19
21
 
20
22
  interface CoverageSummaryData {
21
23
  lines: Totals;
package/dist/coverage.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { relative } from 'pathe';
2
- import { m as mm } from './vendor/index.BMmMjLIQ.js';
3
- import './vendor/_commonjsHelpers.BFTU3MAI.js';
2
+ import { m as mm } from './chunks/index.BMmMjLIQ.js';
3
+ import './chunks/_commonjsHelpers.BFTU3MAI.js';
4
4
  import 'util';
5
5
  import 'path';
6
6
 
@@ -118,7 +118,6 @@ class BaseCoverageProvider {
118
118
  }) {
119
119
  const resolvedThresholds = [];
120
120
  const files = coverageMap.files();
121
- const filesMatchedByGlobs = [];
122
121
  const globalCoverageMap = createCoverageMap();
123
122
  for (const key of Object.keys(
124
123
  thresholds
@@ -132,7 +131,6 @@ class BaseCoverageProvider {
132
131
  const matchingFiles = files.filter(
133
132
  (file) => mm.isMatch(relative(root, file), glob)
134
133
  );
135
- filesMatchedByGlobs.push(...matchingFiles);
136
134
  for (const file of matchingFiles) {
137
135
  const fileCoverage = coverageMap.fileCoverageFor(file);
138
136
  globCoverageMap.addFileCoverage(fileCoverage);
@@ -143,9 +141,7 @@ class BaseCoverageProvider {
143
141
  thresholds: globThresholds
144
142
  });
145
143
  }
146
- for (const file of files.filter(
147
- (file2) => !filesMatchedByGlobs.includes(file2)
148
- )) {
144
+ for (const file of files) {
149
145
  const fileCoverage = coverageMap.fileCoverageFor(file);
150
146
  globalCoverageMap.addFileCoverage(fileCoverage);
151
147
  }
@@ -201,6 +197,14 @@ function resolveGlobThresholds(thresholds) {
201
197
  if (!thresholds || typeof thresholds !== "object") {
202
198
  return {};
203
199
  }
200
+ if (100 in thresholds && thresholds[100] === true) {
201
+ return {
202
+ lines: 100,
203
+ branches: 100,
204
+ functions: 100,
205
+ statements: 100
206
+ };
207
+ }
204
208
  return {
205
209
  lines: "lines" in thresholds && typeof thresholds.lines === "number" ? thresholds.lines : void 0,
206
210
  branches: "branches" in thresholds && typeof thresholds.branches === "number" ? thresholds.branches : void 0,
@@ -1,21 +1,5 @@
1
- import { E as Environment } from './reporters-BECoY4-b.js';
2
- import 'vite';
3
- import '@vitest/pretty-format';
4
- import '@vitest/runner';
5
- import 'vite-node';
6
- import '@vitest/snapshot';
7
- import '@vitest/expect';
8
- import '@vitest/runner/utils';
9
- import '@vitest/utils';
10
- import 'tinybench';
11
- import 'node:stream';
12
- import 'vite-node/client';
13
- import '@vitest/snapshot/manager';
14
- import 'vite-node/server';
15
- import 'node:worker_threads';
16
- import '@vitest/utils/source-map';
17
- import 'node:fs';
18
- import 'chai';
1
+ import { E as Environment } from './chunks/environment.0M5R1SX_.js';
2
+ export { a as EnvironmentReturn, V as VmEnvironmentReturn } from './chunks/environment.0M5R1SX_.js';
19
3
 
20
4
  declare const environments: {
21
5
  node: Environment;
@@ -34,4 +18,4 @@ declare function populateGlobal(global: any, win: any, options?: PopulateOptions
34
18
  originals: Map<string | symbol, any>;
35
19
  };
36
20
 
37
- export { environments as builtinEnvironments, populateGlobal };
21
+ export { Environment, environments as builtinEnvironments, populateGlobal };
@@ -1,2 +1,2 @@
1
- export { e as builtinEnvironments, p as populateGlobal } from './vendor/index.D4nqnQWz.js';
1
+ export { e as builtinEnvironments, p as populateGlobal } from './chunks/index.lVXYBqEP.js';
2
2
  import 'node:console';