vitest 2.1.3 → 2.1.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 (75) hide show
  1. package/LICENSE.md +1 -209
  2. package/dist/browser.d.ts +24 -24
  3. package/dist/browser.js +7 -7
  4. package/dist/chunks/{RandomSequencer.Bh5-tlNJ.js → RandomSequencer.CMRlh2v4.js} +143 -142
  5. package/dist/chunks/{base.BO5Jx7vw.js → base.BZZh4cSm.js} +3 -3
  6. package/dist/chunks/{benchmark.C8CRJYG4.js → benchmark.Cdu9hjj4.js} +2 -2
  7. package/dist/chunks/{benchmark.JVlTzojj.d.ts → benchmark.geERunq4.d.ts} +1 -1
  8. package/dist/chunks/{cac.BSMVokHR.js → cac.DWAW3Uh5.js} +11 -10
  9. package/dist/chunks/{cli-api.btGgw3PC.js → cli-api.BtqJwSCh.js} +828 -644
  10. package/dist/chunks/{config.Crbj2GAb.d.ts → config.Cy0C388Z.d.ts} +0 -1
  11. package/dist/chunks/{console.CfT1Wjed.js → console.BYGVloWk.js} +2 -6
  12. package/dist/chunks/{coverage.zlNdAMHK.js → coverage.BoMDb1ip.js} +1 -1
  13. package/dist/chunks/{creator.CBPphXqR.js → creator.IIqd8RWT.js} +8 -8
  14. package/dist/chunks/{execute._eQQfgI8.js → execute.2pr0rHgK.js} +8 -6
  15. package/dist/chunks/{globals.Bdzt04Qm.js → globals.D8ZVAdXd.js} +8 -13
  16. package/dist/chunks/{index.BpSiYbpB.js → index.68735LiX.js} +28 -5
  17. package/dist/chunks/{index.X0nbfr6-.js → index.BJDntFik.js} +7 -7
  18. package/dist/chunks/{index.CPD77dLA.js → index.CqYx2Nsr.js} +7 -7
  19. package/dist/chunks/{index.Dz2opmmU.js → index.DsZFoqi9.js} +3711 -3788
  20. package/dist/chunks/{index.lVXYBqEP.js → index.K90BXFOx.js} +186 -186
  21. package/dist/chunks/index.ckWaX2gY.js +54 -0
  22. package/dist/chunks/{index.4GFF2h22.js → index.nEwtF0bu.js} +6 -6
  23. package/dist/chunks/{node.Bx4JZjMG.js → node.AKq966Jp.js} +1 -5
  24. package/dist/chunks/{reporters.C4ZHgdxQ.d.ts → reporters.D7Jzd9GS.d.ts} +1246 -1221
  25. package/dist/chunks/{resolveConfig.Dha6ilPI.js → resolveConfig.RxKrDli4.js} +3196 -3176
  26. package/dist/chunks/{rpc.B7Mfb-Yf.js → rpc.C3q9uwRX.js} +2 -2
  27. package/dist/chunks/{run-once.Sxe67Wng.js → run-once.2ogXb3JV.js} +1 -1
  28. package/dist/chunks/{runBaseTests.Cx4wXyTR.js → runBaseTests.3qpJUEJM.js} +21 -25
  29. package/dist/chunks/{setup-common.BKyF15v_.js → setup-common.Dj6BZI3u.js} +3 -3
  30. package/dist/chunks/{suite.BMWOKiTe.d.ts → suite.B2jumIFP.d.ts} +2 -2
  31. package/dist/chunks/utils.C8RiOc4B.js +77 -0
  32. package/dist/chunks/{utils.CY6Spixo.js → utils.DNoFbBUZ.js} +7 -3
  33. package/dist/chunks/{vi.BskyZC5g.js → vi.DgezovHB.js} +177 -142
  34. package/dist/chunks/{vite.YH7MrecS.d.ts → vite.C-N5BBZe.d.ts} +1 -1
  35. package/dist/chunks/{vm.DB_hLchi.js → vm.Zr4qWzDJ.js} +8 -8
  36. package/dist/chunks/{worker.CcJLfX8w.d.ts → worker.B9FxPCaC.d.ts} +1 -1
  37. package/dist/chunks/{worker.B6RjTtbk.d.ts → worker.tN5KGIih.d.ts} +14 -4
  38. package/dist/cli.js +3 -4
  39. package/dist/config.cjs +4 -4
  40. package/dist/config.d.ts +11 -11
  41. package/dist/config.js +4 -4
  42. package/dist/coverage.d.ts +10 -10
  43. package/dist/coverage.js +8 -11
  44. package/dist/environments.d.ts +2 -2
  45. package/dist/environments.js +1 -1
  46. package/dist/execute.d.ts +54 -54
  47. package/dist/execute.js +7 -6
  48. package/dist/index.d.ts +106 -1101
  49. package/dist/index.js +7 -18
  50. package/dist/node.d.ts +44 -42
  51. package/dist/node.js +23 -29
  52. package/dist/path.js +1 -1
  53. package/dist/reporters.d.ts +10 -10
  54. package/dist/reporters.js +12 -18
  55. package/dist/runners.d.ts +12 -19
  56. package/dist/runners.js +142 -148
  57. package/dist/snapshot.js +2 -6
  58. package/dist/suite.d.ts +2 -2
  59. package/dist/suite.js +2 -6
  60. package/dist/worker.js +10 -7
  61. package/dist/workers/forks.js +9 -8
  62. package/dist/workers/runVmTests.js +16 -20
  63. package/dist/workers/threads.js +9 -8
  64. package/dist/workers/vmForks.js +9 -12
  65. package/dist/workers/vmThreads.js +9 -12
  66. package/dist/workers.d.ts +14 -14
  67. package/dist/workers.js +15 -18
  68. package/package.json +27 -27
  69. package/dist/chunks/base.DwXGwWst.js +0 -89
  70. package/dist/chunks/env.CmHVDJnw.js +0 -7
  71. package/dist/chunks/index.-d_XpZEA.js +0 -140
  72. package/dist/chunks/index.CxRxs566.js +0 -23
  73. package/dist/chunks/tasks.BZnCS9aT.js +0 -18
  74. package/dist/chunks/utils.Ck2hJTRs.js +0 -23
  75. package/dist/chunks/{environment.CzISCQ7o.d.ts → environment.LoooBwUu.d.ts} +24 -24
@@ -1,102 +1,5 @@
1
1
  import { Console } from 'node:console';
2
2
 
3
- const denyList = /* @__PURE__ */ new Set([
4
- "GLOBAL",
5
- "root",
6
- "global",
7
- "Buffer",
8
- "ArrayBuffer",
9
- "Uint8Array"
10
- ]);
11
- const nodeGlobals = new Map(
12
- Object.getOwnPropertyNames(globalThis).filter((global) => !denyList.has(global)).map((nodeGlobalsKey) => {
13
- const descriptor = Object.getOwnPropertyDescriptor(
14
- globalThis,
15
- nodeGlobalsKey
16
- );
17
- if (!descriptor) {
18
- throw new Error(
19
- `No property descriptor for ${nodeGlobalsKey}, this is a bug in Vitest.`
20
- );
21
- }
22
- return [nodeGlobalsKey, descriptor];
23
- })
24
- );
25
- var node = {
26
- name: "node",
27
- transformMode: "ssr",
28
- // this is largely copied from jest's node environment
29
- async setupVM() {
30
- const vm = await import('node:vm');
31
- let context = vm.createContext();
32
- let global = vm.runInContext("this", context);
33
- const contextGlobals = new Set(Object.getOwnPropertyNames(global));
34
- for (const [nodeGlobalsKey, descriptor] of nodeGlobals) {
35
- if (!contextGlobals.has(nodeGlobalsKey)) {
36
- if (descriptor.configurable) {
37
- Object.defineProperty(global, nodeGlobalsKey, {
38
- configurable: true,
39
- enumerable: descriptor.enumerable,
40
- get() {
41
- const val = globalThis[nodeGlobalsKey];
42
- Object.defineProperty(global, nodeGlobalsKey, {
43
- configurable: true,
44
- enumerable: descriptor.enumerable,
45
- value: val,
46
- writable: descriptor.writable === true || nodeGlobalsKey === "performance"
47
- });
48
- return val;
49
- },
50
- set(val) {
51
- Object.defineProperty(global, nodeGlobalsKey, {
52
- configurable: true,
53
- enumerable: descriptor.enumerable,
54
- value: val,
55
- writable: true
56
- });
57
- }
58
- });
59
- } else if ("value" in descriptor) {
60
- Object.defineProperty(global, nodeGlobalsKey, {
61
- configurable: false,
62
- enumerable: descriptor.enumerable,
63
- value: descriptor.value,
64
- writable: descriptor.writable
65
- });
66
- } else {
67
- Object.defineProperty(global, nodeGlobalsKey, {
68
- configurable: false,
69
- enumerable: descriptor.enumerable,
70
- get: descriptor.get,
71
- set: descriptor.set
72
- });
73
- }
74
- }
75
- }
76
- global.global = global;
77
- global.Buffer = Buffer;
78
- global.ArrayBuffer = ArrayBuffer;
79
- global.Uint8Array = Uint8Array;
80
- return {
81
- getVmContext() {
82
- return context;
83
- },
84
- teardown() {
85
- context = void 0;
86
- global = void 0;
87
- }
88
- };
89
- },
90
- async setup(global) {
91
- global.console.Console = Console;
92
- return {
93
- teardown(global2) {
94
- delete global2.console.Console;
95
- }
96
- };
97
- }
98
- };
99
-
100
3
  const LIVING_KEYS = [
101
4
  "DOMException",
102
5
  "URL",
@@ -409,6 +312,114 @@ function populateGlobal(global, win, options = {}) {
409
312
  };
410
313
  }
411
314
 
315
+ var edge = {
316
+ name: "edge-runtime",
317
+ transformMode: "ssr",
318
+ async setupVM() {
319
+ const { EdgeVM } = await import('@edge-runtime/vm');
320
+ const vm = new EdgeVM({
321
+ extend: (context) => {
322
+ context.global = context;
323
+ context.Buffer = Buffer;
324
+ return context;
325
+ }
326
+ });
327
+ return {
328
+ getVmContext() {
329
+ return vm.context;
330
+ },
331
+ teardown() {
332
+ }
333
+ };
334
+ },
335
+ async setup(global) {
336
+ const { EdgeVM } = await import('@edge-runtime/vm');
337
+ const vm = new EdgeVM({
338
+ extend: (context) => {
339
+ context.global = context;
340
+ context.Buffer = Buffer;
341
+ KEYS.forEach((key) => {
342
+ if (key in global) {
343
+ context[key] = global[key];
344
+ }
345
+ });
346
+ return context;
347
+ }
348
+ });
349
+ const { keys, originals } = populateGlobal(global, vm.context, {
350
+ bindFunctions: true
351
+ });
352
+ return {
353
+ teardown(global2) {
354
+ keys.forEach((key) => delete global2[key]);
355
+ originals.forEach((v, k) => global2[k] = v);
356
+ }
357
+ };
358
+ }
359
+ };
360
+
361
+ async function teardownWindow(win) {
362
+ if (win.close && win.happyDOM.abort) {
363
+ await win.happyDOM.abort();
364
+ win.close();
365
+ } else {
366
+ win.happyDOM.cancelAsync();
367
+ }
368
+ }
369
+ var happy = {
370
+ name: "happy-dom",
371
+ transformMode: "web",
372
+ async setupVM({ happyDOM = {} }) {
373
+ const { Window } = await import('happy-dom');
374
+ let win = new Window({
375
+ ...happyDOM,
376
+ console: console && globalThis.console ? globalThis.console : void 0,
377
+ url: happyDOM.url || "http://localhost:3000",
378
+ settings: {
379
+ ...happyDOM.settings,
380
+ disableErrorCapturing: true
381
+ }
382
+ });
383
+ win.Buffer = Buffer;
384
+ if (typeof structuredClone !== "undefined" && !win.structuredClone) {
385
+ win.structuredClone = structuredClone;
386
+ }
387
+ return {
388
+ getVmContext() {
389
+ return win;
390
+ },
391
+ async teardown() {
392
+ await teardownWindow(win);
393
+ win = void 0;
394
+ }
395
+ };
396
+ },
397
+ async setup(global, { happyDOM = {} }) {
398
+ const { Window, GlobalWindow } = await import('happy-dom');
399
+ const win = new (GlobalWindow || Window)({
400
+ ...happyDOM,
401
+ console: console && global.console ? global.console : void 0,
402
+ url: happyDOM.url || "http://localhost:3000",
403
+ settings: {
404
+ ...happyDOM.settings,
405
+ disableErrorCapturing: true
406
+ }
407
+ });
408
+ const { keys, originals } = populateGlobal(global, win, {
409
+ bindFunctions: true,
410
+ // jsdom doesn't support Request and Response, but happy-dom does
411
+ additionalKeys: ["Request", "Response", "MessagePort", "fetch"]
412
+ });
413
+ return {
414
+ async teardown(global2) {
415
+ await teardownWindow(win);
416
+ keys.forEach((key) => delete global2[key]);
417
+ originals.forEach((v, k) => global2[k] = v);
418
+ }
419
+ };
420
+ }
421
+ };
422
+
412
423
  function catchWindowErrors(window) {
413
424
  let userErrorListenerCount = 0;
414
425
  function throwUnhandlerError(e) {
@@ -540,109 +551,98 @@ var jsdom = {
540
551
  }
541
552
  };
542
553
 
543
- async function teardownWindow(win) {
544
- if (win.close && win.happyDOM.abort) {
545
- await win.happyDOM.abort();
546
- win.close();
547
- } else {
548
- win.happyDOM.cancelAsync();
549
- }
550
- }
551
- var happy = {
552
- name: "happy-dom",
553
- transformMode: "web",
554
- async setupVM({ happyDOM = {} }) {
555
- const { Window } = await import('happy-dom');
556
- let win = new Window({
557
- ...happyDOM,
558
- console: console && globalThis.console ? globalThis.console : void 0,
559
- url: happyDOM.url || "http://localhost:3000",
560
- settings: {
561
- ...happyDOM.settings,
562
- disableErrorCapturing: true
563
- }
564
- });
565
- win.Buffer = Buffer;
566
- if (typeof structuredClone !== "undefined" && !win.structuredClone) {
567
- win.structuredClone = structuredClone;
554
+ const denyList = /* @__PURE__ */ new Set([
555
+ "GLOBAL",
556
+ "root",
557
+ "global",
558
+ "Buffer",
559
+ "ArrayBuffer",
560
+ "Uint8Array"
561
+ ]);
562
+ const nodeGlobals = new Map(
563
+ Object.getOwnPropertyNames(globalThis).filter((global) => !denyList.has(global)).map((nodeGlobalsKey) => {
564
+ const descriptor = Object.getOwnPropertyDescriptor(
565
+ globalThis,
566
+ nodeGlobalsKey
567
+ );
568
+ if (!descriptor) {
569
+ throw new Error(
570
+ `No property descriptor for ${nodeGlobalsKey}, this is a bug in Vitest.`
571
+ );
568
572
  }
569
- return {
570
- getVmContext() {
571
- return win;
572
- },
573
- async teardown() {
574
- await teardownWindow(win);
575
- win = void 0;
576
- }
577
- };
578
- },
579
- async setup(global, { happyDOM = {} }) {
580
- const { Window, GlobalWindow } = await import('happy-dom');
581
- const win = new (GlobalWindow || Window)({
582
- ...happyDOM,
583
- console: console && global.console ? global.console : void 0,
584
- url: happyDOM.url || "http://localhost:3000",
585
- settings: {
586
- ...happyDOM.settings,
587
- disableErrorCapturing: true
588
- }
589
- });
590
- const { keys, originals } = populateGlobal(global, win, {
591
- bindFunctions: true,
592
- // jsdom doesn't support Request and Response, but happy-dom does
593
- additionalKeys: ["Request", "Response"]
594
- });
595
- return {
596
- async teardown(global2) {
597
- await teardownWindow(win);
598
- keys.forEach((key) => delete global2[key]);
599
- originals.forEach((v, k) => global2[k] = v);
600
- }
601
- };
602
- }
603
- };
604
-
605
- var edge = {
606
- name: "edge-runtime",
573
+ return [nodeGlobalsKey, descriptor];
574
+ })
575
+ );
576
+ var node = {
577
+ name: "node",
607
578
  transformMode: "ssr",
579
+ // this is largely copied from jest's node environment
608
580
  async setupVM() {
609
- const { EdgeVM } = await import('@edge-runtime/vm');
610
- const vm = new EdgeVM({
611
- extend: (context) => {
612
- context.global = context;
613
- context.Buffer = Buffer;
614
- return context;
581
+ const vm = await import('node:vm');
582
+ let context = vm.createContext();
583
+ let global = vm.runInContext("this", context);
584
+ const contextGlobals = new Set(Object.getOwnPropertyNames(global));
585
+ for (const [nodeGlobalsKey, descriptor] of nodeGlobals) {
586
+ if (!contextGlobals.has(nodeGlobalsKey)) {
587
+ if (descriptor.configurable) {
588
+ Object.defineProperty(global, nodeGlobalsKey, {
589
+ configurable: true,
590
+ enumerable: descriptor.enumerable,
591
+ get() {
592
+ const val = globalThis[nodeGlobalsKey];
593
+ Object.defineProperty(global, nodeGlobalsKey, {
594
+ configurable: true,
595
+ enumerable: descriptor.enumerable,
596
+ value: val,
597
+ writable: descriptor.writable === true || nodeGlobalsKey === "performance"
598
+ });
599
+ return val;
600
+ },
601
+ set(val) {
602
+ Object.defineProperty(global, nodeGlobalsKey, {
603
+ configurable: true,
604
+ enumerable: descriptor.enumerable,
605
+ value: val,
606
+ writable: true
607
+ });
608
+ }
609
+ });
610
+ } else if ("value" in descriptor) {
611
+ Object.defineProperty(global, nodeGlobalsKey, {
612
+ configurable: false,
613
+ enumerable: descriptor.enumerable,
614
+ value: descriptor.value,
615
+ writable: descriptor.writable
616
+ });
617
+ } else {
618
+ Object.defineProperty(global, nodeGlobalsKey, {
619
+ configurable: false,
620
+ enumerable: descriptor.enumerable,
621
+ get: descriptor.get,
622
+ set: descriptor.set
623
+ });
624
+ }
615
625
  }
616
- });
626
+ }
627
+ global.global = global;
628
+ global.Buffer = Buffer;
629
+ global.ArrayBuffer = ArrayBuffer;
630
+ global.Uint8Array = Uint8Array;
617
631
  return {
618
632
  getVmContext() {
619
- return vm.context;
633
+ return context;
620
634
  },
621
635
  teardown() {
636
+ context = void 0;
637
+ global = void 0;
622
638
  }
623
639
  };
624
640
  },
625
641
  async setup(global) {
626
- const { EdgeVM } = await import('@edge-runtime/vm');
627
- const vm = new EdgeVM({
628
- extend: (context) => {
629
- context.global = context;
630
- context.Buffer = Buffer;
631
- KEYS.forEach((key) => {
632
- if (key in global) {
633
- context[key] = global[key];
634
- }
635
- });
636
- return context;
637
- }
638
- });
639
- const { keys, originals } = populateGlobal(global, vm.context, {
640
- bindFunctions: true
641
- });
642
+ global.console.Console = Console;
642
643
  return {
643
644
  teardown(global2) {
644
- keys.forEach((key) => delete global2[key]);
645
- originals.forEach((v, k) => global2[k] = v);
645
+ delete global2.console.Console;
646
646
  }
647
647
  };
648
648
  }
@@ -0,0 +1,54 @@
1
+ import { c as createExpect, a as globalExpect, v as vi, b as vitest } from './vi.DgezovHB.js';
2
+ import { g as getWorkerState } from './utils.C8RiOc4B.js';
3
+ import { i as isFirstRun, a as runOnce } from './run-once.2ogXb3JV.js';
4
+ import { b as bench } from './benchmark.Cdu9hjj4.js';
5
+ import { expectTypeOf } from 'expect-type';
6
+ import { afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, onTestFinished, suite, test } from '@vitest/runner';
7
+ import * as chai from 'chai';
8
+ import { assert, should } from 'chai';
9
+
10
+ function inject(key) {
11
+ const workerState = getWorkerState();
12
+ return workerState.providedContext[key];
13
+ }
14
+
15
+ function getRunningMode() {
16
+ return process.env.VITEST_MODE === "WATCH" ? "watch" : "run";
17
+ }
18
+ function isWatchMode() {
19
+ return getRunningMode() === "watch";
20
+ }
21
+
22
+ const assertType = function assertType2() {
23
+ };
24
+
25
+ var VitestIndex = /*#__PURE__*/Object.freeze({
26
+ __proto__: null,
27
+ afterAll: afterAll,
28
+ afterEach: afterEach,
29
+ assert: assert,
30
+ assertType: assertType,
31
+ beforeAll: beforeAll,
32
+ beforeEach: beforeEach,
33
+ bench: bench,
34
+ chai: chai,
35
+ createExpect: createExpect,
36
+ describe: describe,
37
+ expect: globalExpect,
38
+ expectTypeOf: expectTypeOf,
39
+ getRunningMode: getRunningMode,
40
+ inject: inject,
41
+ isFirstRun: isFirstRun,
42
+ isWatchMode: isWatchMode,
43
+ it: it,
44
+ onTestFailed: onTestFailed,
45
+ onTestFinished: onTestFinished,
46
+ runOnce: runOnce,
47
+ should: should,
48
+ suite: suite,
49
+ test: test,
50
+ vi: vi,
51
+ vitest: vitest
52
+ });
53
+
54
+ export { VitestIndex as V, isWatchMode as a, assertType as b, getRunningMode as g, inject as i };
@@ -1,10 +1,10 @@
1
1
  import * as chai from 'chai';
2
- import { resolve } from 'pathe';
2
+ import { resolve } from 'node:path';
3
+ import { t as takeCoverageInsideWorker } from './coverage.BoMDb1ip.js';
3
4
  import { distDir } from '../path.js';
4
- import { g as getWorkerState } from './utils.Ck2hJTRs.js';
5
- import { r as rpc } from './rpc.B7Mfb-Yf.js';
6
- import { t as takeCoverageInsideWorker } from './coverage.zlNdAMHK.js';
7
- import { l as loadDiffConfig, a as loadSnapshotSerializers } from './setup-common.BKyF15v_.js';
5
+ import { r as rpc } from './rpc.C3q9uwRX.js';
6
+ import { l as loadDiffConfig, a as loadSnapshotSerializers } from './setup-common.Dj6BZI3u.js';
7
+ import { g as getWorkerState } from './utils.C8RiOc4B.js';
8
8
 
9
9
  function setupChaiConfig(config) {
10
10
  Object.assign(chai.config, config);
@@ -12,7 +12,7 @@ function setupChaiConfig(config) {
12
12
 
13
13
  async function resolveSnapshotEnvironment(config, executor) {
14
14
  if (!config.snapshotEnvironment) {
15
- const { VitestNodeSnapshotEnvironment } = await import('./node.Bx4JZjMG.js');
15
+ const { VitestNodeSnapshotEnvironment } = await import('./node.AKq966Jp.js');
16
16
  return new VitestNodeSnapshotEnvironment();
17
17
  }
18
18
  const mod = await executor.executeId(config.snapshotEnvironment);
@@ -1,10 +1,6 @@
1
1
  import { NodeSnapshotEnvironment } from '@vitest/snapshot/environment';
2
- import 'pathe';
3
- import '@vitest/runner/utils';
2
+ import { g as getWorkerState } from './utils.C8RiOc4B.js';
4
3
  import '@vitest/utils';
5
- import { g as getWorkerState } from './utils.Ck2hJTRs.js';
6
- import './env.CmHVDJnw.js';
7
- import 'std-env';
8
4
 
9
5
  class VitestNodeSnapshotEnvironment extends NodeSnapshotEnvironment {
10
6
  getHeader() {