vitest 4.0.0-beta.1 → 4.0.0-beta.11

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 (90) hide show
  1. package/LICENSE.md +83 -2
  2. package/dist/browser.d.ts +19 -16
  3. package/dist/browser.js +11 -7
  4. package/dist/chunks/{benchmark.CYdenmiT.js → benchmark.LXhJ0F0X.js} +7 -9
  5. package/dist/chunks/{benchmark.d.BwvBVTda.d.ts → benchmark.d.DAaHLpsq.d.ts} +4 -4
  6. package/dist/chunks/{browser.d.q8Z0P0q1.d.ts → browser.d.Dx7DO_Ce.d.ts} +5 -5
  7. package/dist/chunks/{cac.D3EzDDZd.js → cac.elvK37c9.js} +71 -153
  8. package/dist/chunks/{cli-api.Dn5gKePv.js → cli-api.C7plPyhs.js} +1376 -1693
  9. package/dist/chunks/{config.d.HJdfX-8k.d.ts → config.d.B_LthbQq.d.ts} +58 -63
  10. package/dist/chunks/{console.CtFJOzRO.js → console.CiTi59Jy.js} +35 -71
  11. package/dist/chunks/{constants.DnKduX2e.js → constants.D_Q9UYh-.js} +1 -9
  12. package/dist/chunks/{coverage.Cwa-XhJt.js → coverage.CG6Uhorw.js} +522 -792
  13. package/dist/chunks/{coverage.DVF1vEu8.js → coverage.D_JHT54q.js} +2 -2
  14. package/dist/chunks/{coverage.d.S9RMNXIe.d.ts → coverage.d.BZtK59WP.d.ts} +10 -8
  15. package/dist/chunks/{creator.GK6I-cL4.js → creator.08Gi-vCA.js} +93 -77
  16. package/dist/chunks/{date.Bq6ZW5rf.js → date.-jtEtIeV.js} +6 -17
  17. package/dist/chunks/{environment.d.CUq4cUgQ.d.ts → environment.d.BsToaxti.d.ts} +27 -6
  18. package/dist/chunks/{git.BVQ8w_Sw.js → git.BFNcloKD.js} +1 -2
  19. package/dist/chunks/{global.d.CVbXEflG.d.ts → global.d.BK3X7FW1.d.ts} +2 -5
  20. package/dist/chunks/{globals.Cxal6MLI.js → globals.BjvYA-AD.js} +11 -9
  21. package/dist/chunks/{index.BWf_gE5n.js → index.AZOjjqWP.js} +7 -6
  22. package/dist/chunks/{index.B521nVV-.js → index.Bgo3tNWt.js} +23 -4
  23. package/dist/chunks/{index.TfbsX-3I.js → index.BhY64fF0.js} +16 -26
  24. package/dist/chunks/{index.CZI_8rVt.js → index.BwBttQPf.js} +340 -663
  25. package/dist/chunks/{index.CmSc2RE5.js → index.DIWhzsUh.js} +72 -118
  26. package/dist/chunks/{inspector.C914Efll.js → inspector.CvQD-Nie.js} +10 -25
  27. package/dist/chunks/moduleRunner.d.BNa-CL9e.d.ts +201 -0
  28. package/dist/chunks/{node.fjCdwEIl.js → node.BsdMi6DV.js} +2 -2
  29. package/dist/chunks/{plugin.d.C2EcJUjo.d.ts → plugin.d.C5phQR6o.d.ts} +1 -1
  30. package/dist/chunks/{reporters.d.DxZg19fy.d.ts → reporters.d.CVzhsTvK.d.ts} +1233 -1293
  31. package/dist/chunks/resolveSnapshotEnvironment.DQVamkje.js +81 -0
  32. package/dist/chunks/rpc.jKGRSXIH.js +65 -0
  33. package/dist/chunks/{setup-common.D7ZqXFx-.js → setup-common.NAWRuMRP.js} +18 -30
  34. package/dist/chunks/startModuleRunner.oAuCu1yL.js +682 -0
  35. package/dist/chunks/{suite.d.FvehnV49.d.ts → suite.d.BJWk38HB.d.ts} +1 -1
  36. package/dist/chunks/test.KC5tH8hC.js +214 -0
  37. package/dist/chunks/typechecker.gXq-5P3n.js +1438 -0
  38. package/dist/chunks/{utils.XdZDrNZV.js → utils.DGKhod2J.js} +9 -28
  39. package/dist/chunks/{vi.bdSIJ99Y.js → vi.CiJ0Laa6.js} +159 -306
  40. package/dist/chunks/worker.d.B_Fd9M_w.d.ts +100 -0
  41. package/dist/chunks/worker.rPGLlbkW.js +200 -0
  42. package/dist/cli.js +8 -6
  43. package/dist/config.cjs +3 -9
  44. package/dist/config.d.ts +49 -54
  45. package/dist/config.js +1 -1
  46. package/dist/coverage.d.ts +27 -26
  47. package/dist/coverage.js +6 -8
  48. package/dist/environments.d.ts +9 -13
  49. package/dist/environments.js +1 -1
  50. package/dist/index.d.ts +38 -45
  51. package/dist/index.js +10 -10
  52. package/dist/module-evaluator.d.ts +13 -0
  53. package/dist/module-evaluator.js +276 -0
  54. package/dist/module-runner.js +15 -0
  55. package/dist/node.d.ts +44 -42
  56. package/dist/node.js +30 -36
  57. package/dist/reporters.d.ts +12 -13
  58. package/dist/reporters.js +7 -5
  59. package/dist/runners.d.ts +3 -3
  60. package/dist/runners.js +15 -232
  61. package/dist/snapshot.js +3 -3
  62. package/dist/suite.d.ts +2 -2
  63. package/dist/suite.js +4 -3
  64. package/dist/worker-base.js +203 -0
  65. package/dist/{chunks/vm.BThCzidc.js → worker-vm.js} +179 -228
  66. package/dist/workers/runVmTests.js +39 -56
  67. package/globals.d.ts +17 -17
  68. package/package.json +40 -38
  69. package/browser.d.ts +0 -1
  70. package/dist/chunks/base.Bj3pWTr1.js +0 -38
  71. package/dist/chunks/execute.B7h3T_Hc.js +0 -708
  72. package/dist/chunks/index.D-VkfKhf.js +0 -105
  73. package/dist/chunks/rpc.CsFtxqeq.js +0 -83
  74. package/dist/chunks/runBaseTests.BC7ZIH5L.js +0 -129
  75. package/dist/chunks/typechecker.CVytUJuF.js +0 -874
  76. package/dist/chunks/utils.CAioKnHs.js +0 -61
  77. package/dist/chunks/worker.d.CmvJfRGs.d.ts +0 -8
  78. package/dist/chunks/worker.d.DoNjFAiv.d.ts +0 -169
  79. package/dist/execute.d.ts +0 -148
  80. package/dist/execute.js +0 -13
  81. package/dist/worker.js +0 -124
  82. package/dist/workers/forks.js +0 -43
  83. package/dist/workers/threads.js +0 -31
  84. package/dist/workers/vmForks.js +0 -47
  85. package/dist/workers/vmThreads.js +0 -37
  86. package/dist/workers.d.ts +0 -37
  87. package/dist/workers.js +0 -30
  88. package/execute.d.ts +0 -1
  89. package/utils.d.ts +0 -1
  90. package/workers.d.ts +0 -1
package/LICENSE.md CHANGED
@@ -3,7 +3,7 @@ Vitest is released under the MIT license:
3
3
 
4
4
  MIT License
5
5
 
6
- Copyright (c) 2021-Present Vitest Team
6
+ Copyright (c) 2021-Present VoidZero Inc. and Vitest contributors
7
7
 
8
8
  Permission is hereby granted, free of charge, to any person obtaining a copy
9
9
  of this software and associated documentation files (the "Software"), to deal
@@ -57,6 +57,87 @@ Repository: git+https://github.com/antfu/install-pkg.git
57
57
 
58
58
  ---------------------------------------
59
59
 
60
+ ## @jridgewell/resolve-uri
61
+ License: MIT
62
+ By: Justin Ridgewell
63
+ Repository: https://github.com/jridgewell/resolve-uri
64
+
65
+ > Copyright 2019 Justin Ridgewell <jridgewell@google.com>
66
+ >
67
+ > Permission is hereby granted, free of charge, to any person obtaining a copy
68
+ > of this software and associated documentation files (the "Software"), to deal
69
+ > in the Software without restriction, including without limitation the rights
70
+ > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
71
+ > copies of the Software, and to permit persons to whom the Software is
72
+ > furnished to do so, subject to the following conditions:
73
+ >
74
+ > The above copyright notice and this permission notice shall be included in
75
+ > all copies or substantial portions of the Software.
76
+ >
77
+ > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
78
+ > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
79
+ > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
80
+ > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
81
+ > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
82
+ > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
83
+ > SOFTWARE.
84
+
85
+ ---------------------------------------
86
+
87
+ ## @jridgewell/sourcemap-codec
88
+ License: MIT
89
+ By: Justin Ridgewell
90
+ Repository: git+https://github.com/jridgewell/sourcemaps.git
91
+
92
+ > Copyright 2024 Justin Ridgewell <justin@ridgewell.name>
93
+ >
94
+ > Permission is hereby granted, free of charge, to any person obtaining a copy
95
+ > of this software and associated documentation files (the "Software"), to deal
96
+ > in the Software without restriction, including without limitation the rights
97
+ > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
98
+ > copies of the Software, and to permit persons to whom the Software is
99
+ > furnished to do so, subject to the following conditions:
100
+ >
101
+ > The above copyright notice and this permission notice shall be included in
102
+ > all copies or substantial portions of the Software.
103
+ >
104
+ > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
105
+ > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
106
+ > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
107
+ > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
108
+ > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
109
+ > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
110
+ > SOFTWARE.
111
+
112
+ ---------------------------------------
113
+
114
+ ## @jridgewell/trace-mapping
115
+ License: MIT
116
+ By: Justin Ridgewell
117
+ Repository: git+https://github.com/jridgewell/sourcemaps.git
118
+
119
+ > Copyright 2024 Justin Ridgewell <justin@ridgewell.name>
120
+ >
121
+ > Permission is hereby granted, free of charge, to any person obtaining a copy
122
+ > of this software and associated documentation files (the "Software"), to deal
123
+ > in the Software without restriction, including without limitation the rights
124
+ > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
125
+ > copies of the Software, and to permit persons to whom the Software is
126
+ > furnished to do so, subject to the following conditions:
127
+ >
128
+ > The above copyright notice and this permission notice shall be included in
129
+ > all copies or substantial portions of the Software.
130
+ >
131
+ > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
132
+ > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
133
+ > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
134
+ > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
135
+ > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
136
+ > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
137
+ > SOFTWARE.
138
+
139
+ ---------------------------------------
140
+
60
141
  ## @sinonjs/commons
61
142
  License: BSD-3-Clause
62
143
  Repository: git+https://github.com/sinonjs/commons.git
@@ -329,7 +410,7 @@ Repository: lukeed/kleur
329
410
  ## local-pkg
330
411
  License: MIT
331
412
  By: Anthony Fu
332
- Repository: git+https://github.com/antfu/local-pkg.git
413
+ Repository: git+https://github.com/antfu-collective/local-pkg.git
333
414
 
334
415
  > MIT License
335
416
  >
package/dist/browser.d.ts CHANGED
@@ -1,32 +1,35 @@
1
- import { S as SerializedCoverageConfig, a as SerializedConfig } from './chunks/config.d.HJdfX-8k.js';
2
- import { R as RuntimeCoverageModuleLoader } from './chunks/coverage.d.S9RMNXIe.js';
1
+ import { S as SerializedCoverageConfig, a as SerializedConfig } from './chunks/config.d.B_LthbQq.js';
2
+ import { R as RuntimeCoverageModuleLoader } from './chunks/coverage.d.BZtK59WP.js';
3
3
  import { SerializedDiffOptions } from '@vitest/utils/diff';
4
- import { VitestExecutor } from './execute.js';
5
- export { collectTests, processError, startTests } from '@vitest/runner';
6
- import * as spy from '@vitest/spy';
7
- export { spy as SpyModule };
8
- export { LoupeOptions, ParsedStack, StringifyOptions, format, getSafeTimers, inspect, stringify } from '@vitest/utils';
9
- export { TraceMap, originalPositionFor } from '@vitest/utils/source-map';
4
+ import { V as VitestModuleRunner } from './chunks/moduleRunner.d.BNa-CL9e.js';
5
+ export { collectTests, startTests } from '@vitest/runner';
6
+ import * as _vitest_spy from '@vitest/spy';
7
+ export { _vitest_spy as SpyModule };
8
+ export { LoupeOptions, ParsedStack, StringifyOptions } from '@vitest/utils';
9
+ export { format, inspect, stringify } from '@vitest/utils/display';
10
+ export { processError } from '@vitest/utils/error';
11
+ export { getType } from '@vitest/utils/helpers';
12
+ export { DecodedMap, getOriginalPosition } from '@vitest/utils/source-map';
13
+ export { getSafeTimers, setSafeTimers } from '@vitest/utils/timers';
10
14
  import '@vitest/pretty-format';
11
15
  import '@vitest/snapshot';
12
- import 'vite-node/client';
13
- import 'vite-node';
14
- import './chunks/worker.d.DoNjFAiv.js';
15
- import './chunks/environment.d.CUq4cUgQ.js';
16
16
  import 'node:vm';
17
+ import 'vite/module-runner';
18
+ import './chunks/worker.d.B_Fd9M_w.js';
19
+ import './chunks/environment.d.BsToaxti.js';
17
20
  import '@vitest/mocker';
18
21
  import './chunks/mocker.d.BE_2ls6u.js';
19
22
 
20
23
  declare function startCoverageInsideWorker(options: SerializedCoverageConfig | undefined, loader: RuntimeCoverageModuleLoader, runtimeOptions: {
21
- isolate: boolean
24
+ isolate: boolean;
22
25
  }): Promise<unknown>;
23
26
  declare function takeCoverageInsideWorker(options: SerializedCoverageConfig | undefined, loader: RuntimeCoverageModuleLoader): Promise<unknown>;
24
27
  declare function stopCoverageInsideWorker(options: SerializedCoverageConfig | undefined, loader: RuntimeCoverageModuleLoader, runtimeOptions: {
25
- isolate: boolean
28
+ isolate: boolean;
26
29
  }): Promise<unknown>;
27
30
 
28
31
  declare function setupCommonEnv(config: SerializedConfig): Promise<void>;
29
- declare function loadDiffConfig(config: SerializedConfig, executor: VitestExecutor): Promise<SerializedDiffOptions | undefined>;
30
- declare function loadSnapshotSerializers(config: SerializedConfig, executor: VitestExecutor): Promise<void>;
32
+ declare function loadDiffConfig(config: SerializedConfig, moduleRunner: VitestModuleRunner): Promise<SerializedDiffOptions | undefined>;
33
+ declare function loadSnapshotSerializers(config: SerializedConfig, moduleRunner: VitestModuleRunner): Promise<void>;
31
34
 
32
35
  export { loadDiffConfig, loadSnapshotSerializers, setupCommonEnv, startCoverageInsideWorker, stopCoverageInsideWorker, takeCoverageInsideWorker };
package/dist/browser.js CHANGED
@@ -1,8 +1,12 @@
1
- export { l as loadDiffConfig, b as loadSnapshotSerializers, c as setupCommonEnv, s as startCoverageInsideWorker, a as stopCoverageInsideWorker, t as takeCoverageInsideWorker } from './chunks/setup-common.D7ZqXFx-.js';
2
- export { collectTests, processError, startTests } from '@vitest/runner';
3
- import * as spy from '@vitest/spy';
4
- export { spy as SpyModule };
5
- export { format, getSafeTimers, inspect, stringify } from '@vitest/utils';
6
- export { TraceMap, originalPositionFor } from '@vitest/utils/source-map';
7
- import './chunks/coverage.DVF1vEu8.js';
1
+ export { l as loadDiffConfig, b as loadSnapshotSerializers, c as setupCommonEnv, s as startCoverageInsideWorker, a as stopCoverageInsideWorker, t as takeCoverageInsideWorker } from './chunks/setup-common.NAWRuMRP.js';
2
+ export { collectTests, startTests } from '@vitest/runner';
3
+ import * as spyModule from '@vitest/spy';
4
+ export { spyModule as SpyModule };
5
+ export { format, inspect, stringify } from '@vitest/utils/display';
6
+ export { processError } from '@vitest/utils/error';
7
+ export { getType } from '@vitest/utils/helpers';
8
+ export { DecodedMap, getOriginalPosition } from '@vitest/utils/source-map';
9
+ export { getSafeTimers, setSafeTimers } from '@vitest/utils/timers';
10
+ import './chunks/coverage.D_JHT54q.js';
8
11
  import '@vitest/snapshot';
12
+ import './chunks/utils.DGKhod2J.js';
@@ -1,10 +1,9 @@
1
1
  import { getCurrentSuite } from '@vitest/runner';
2
2
  import { createChainable } from '@vitest/runner/utils';
3
- import { noop } from '@vitest/utils';
4
- import { g as getWorkerState } from './utils.XdZDrNZV.js';
3
+ import { noop } from '@vitest/utils/helpers';
4
+ import { g as getWorkerState } from './utils.DGKhod2J.js';
5
5
 
6
- const benchFns = /* @__PURE__ */ new WeakMap();
7
- const benchOptsMap = /* @__PURE__ */ new WeakMap();
6
+ const benchFns = /* @__PURE__ */ new WeakMap(), benchOptsMap = /* @__PURE__ */ new WeakMap();
8
7
  function getBenchOptions(key) {
9
8
  return benchOptsMap.get(key);
10
9
  }
@@ -17,8 +16,9 @@ const bench = createBenchmark(function(name, fn = noop, options = {}) {
17
16
  ...this,
18
17
  meta: { benchmark: true }
19
18
  });
20
- benchFns.set(task, fn);
21
- benchOptsMap.set(task, options);
19
+ // vitest runner sets mode to `todo` if handler is not passed down
20
+ // but we store handler separetly
21
+ if (benchFns.set(task, fn), benchOptsMap.set(task, options), !this.todo && task.mode === "todo") task.mode = "run";
22
22
  });
23
23
  function createBenchmark(fn) {
24
24
  const benchmark = createChainable([
@@ -26,9 +26,7 @@ function createBenchmark(fn) {
26
26
  "only",
27
27
  "todo"
28
28
  ], fn);
29
- benchmark.skipIf = (condition) => condition ? benchmark.skip : benchmark;
30
- benchmark.runIf = (condition) => condition ? benchmark : benchmark.skip;
31
- return benchmark;
29
+ return benchmark.skipIf = (condition) => condition ? benchmark.skip : benchmark, benchmark.runIf = (condition) => condition ? benchmark : benchmark.skip, benchmark;
32
30
  }
33
31
  function formatName(name) {
34
32
  return typeof name === "string" ? name : typeof name === "function" ? name.name || "<anonymous>" : String(name);
@@ -4,8 +4,8 @@ import { TaskResult, Bench, Options } from 'tinybench';
4
4
 
5
5
  interface Benchmark extends Test {
6
6
  meta: {
7
- benchmark: true
8
- result?: TaskResult
7
+ benchmark: true;
8
+ result?: TaskResult;
9
9
  };
10
10
  }
11
11
  interface BenchmarkResult extends TaskResult {
@@ -17,8 +17,8 @@ interface BenchmarkResult extends TaskResult {
17
17
  type BenchFunction = (this: Bench) => Promise<void> | void;
18
18
  type ChainableBenchmarkAPI = ChainableFunction<"skip" | "only" | "todo", (name: string | Function, fn?: BenchFunction, options?: Options) => void>;
19
19
  type BenchmarkAPI = ChainableBenchmarkAPI & {
20
- skipIf: (condition: any) => ChainableBenchmarkAPI
21
- runIf: (condition: any) => ChainableBenchmarkAPI
20
+ skipIf: (condition: any) => ChainableBenchmarkAPI;
21
+ runIf: (condition: any) => ChainableBenchmarkAPI;
22
22
  };
23
23
 
24
24
  export type { BenchmarkResult as B, BenchFunction as a, Benchmark as b, BenchmarkAPI as c };
@@ -1,11 +1,11 @@
1
- import { T as TestExecutionMethod } from './worker.d.DoNjFAiv.js';
1
+ import { T as TestExecutionMethod } from './worker.d.B_Fd9M_w.js';
2
2
 
3
3
  type SerializedTestSpecification = [project: {
4
- name: string | undefined
5
- root: string
4
+ name: string | undefined;
5
+ root: string;
6
6
  }, file: string, options: {
7
- pool: string
8
- testLines?: number[] | undefined
7
+ pool: string;
8
+ testLines?: number[] | undefined;
9
9
  }];
10
10
 
11
11
  interface BrowserTesterOptions {