vitest 4.1.12 → 5.1.0

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 (121) hide show
  1. package/LICENSE.md +192 -10
  2. package/browser/context.d.ts +7 -1
  3. package/browser/context.js +5 -5
  4. package/config.d.ts +0 -2
  5. package/dist/browser.d.ts +52 -21
  6. package/dist/browser.js +12 -13
  7. package/dist/chunks/{acorn.B2iPLyUM.js → acorn.C1kjbUFw.js} +30 -30
  8. package/dist/chunks/{base.B6Opl8PE.js → base.Cof-UHJf.js} +81 -52
  9. package/dist/chunks/{browser.d.BcoexmFG.d.ts → browser.d.C7tWgUvw.d.ts} +17 -14
  10. package/dist/chunks/{cac.DzDtg8hz.js → cac.BYbt0aJp.js} +143 -87
  11. package/dist/chunks/{cli-api.B0Pz1_R7.js → cli-api.COfZo8lK.js} +7160 -7189
  12. package/dist/chunks/config.d.B3YV4t0O.d.ts +3873 -0
  13. package/dist/chunks/{console.3WNpx0tS.js → console.CQZ877Hi.js} +69 -63
  14. package/dist/chunks/{constants.CPYnjOGj.js → constants.DLYM6cZY.js} +2 -2
  15. package/dist/chunks/coverage.9iqXE2gN.js +26 -0
  16. package/dist/chunks/{coverage.CTzCuANN.js → coverage.jGCktcGP.js} +7 -2
  17. package/dist/chunks/{creator.DgVhQm5q.js → creator.DHWmytIK.js} +65 -28
  18. package/dist/chunks/{defaults.9aQKnqFk.js → defaults.B1FCaFfh.js} +16 -9
  19. package/dist/chunks/display.BlTmubjj.js +194 -0
  20. package/dist/chunks/doctor.B-oPbwps.js +465 -0
  21. package/dist/chunks/{env.D4Lgay0q.js → env.BKKtU2WC.js} +2 -1
  22. package/dist/chunks/{environment.d.CrsxCzP1.d.ts → environment.d.BFQtFKdZ.d.ts} +9 -1
  23. package/dist/chunks/globals.ZKtKSkEf.js +29 -0
  24. package/dist/chunks/index.Bi0NXYPf.js +1708 -0
  25. package/dist/chunks/{index.CMESou6r.js → index.BoyTG_B7.js} +82 -81
  26. package/dist/chunks/index.CZzC1gGg.js +8501 -0
  27. package/dist/chunks/index.D0heQG4v.js +1318 -0
  28. package/dist/chunks/index.Di8au7q4.js +15665 -0
  29. package/dist/chunks/{index.Chj8NDwU.js → index.DmDMHCg8.js} +6 -12
  30. package/dist/chunks/{index.DXx9Dtk7.js → index.w_oBZ9N8.js} +25 -12
  31. package/dist/chunks/{init-forks.H5ZuobOQ.js → init-forks.BaDXQSD8.js} +7 -10
  32. package/dist/chunks/{init-threads.6kl1khcL.js → init-threads.ZX_Vov0z.js} +1 -1
  33. package/dist/chunks/{init.k9zZ9sLh.js → init.CO4AB7HZ.js} +113 -38
  34. package/dist/chunks/module-dependencies._2Eei3FO.js +71 -0
  35. package/dist/chunks/{native.DPzPHdi5.js → native.upB-V0CK.js} +50 -37
  36. package/dist/chunks/{nativeModuleMocker.BkNfQMkH.js → nativeModuleMocker.Dh5azSB4.js} +48 -19
  37. package/dist/chunks/{index.BCY_7LL2.js → nativeModuleRunner.9xPIMzi7.js} +110 -42
  38. package/dist/chunks/node.B9mkVmLH.js +47 -0
  39. package/dist/chunks/offset.Dy-5Fdfn.js +24 -0
  40. package/dist/chunks/pathe.M-eThtNZ.zq3TM4NT.js +492 -0
  41. package/dist/chunks/{reporters.d.DtoKVV2s.d.ts → plugin.d.LRFSN46m.d.ts} +2573 -1453
  42. package/dist/chunks/plugins.DPQHVT0p.js +37 -0
  43. package/dist/chunks/rawSnapshot.DqSiqIEx.js +356 -0
  44. package/dist/chunks/resolver.BzpmeQeT.js +48 -0
  45. package/dist/chunks/rpc.Uhkwr2NM.js +93 -0
  46. package/dist/chunks/rpc.d.3FOhdFx8.d.ts +75 -0
  47. package/dist/chunks/run.CjdgFZiW.js +4231 -0
  48. package/dist/chunks/setup-common.CqAQCXzx.js +36 -0
  49. package/dist/chunks/source-map.DakdQc29.js +1788 -0
  50. package/dist/chunks/source-map.d.BkG8YK_3.d.ts +89 -0
  51. package/dist/chunks/spy.DDMXghXv.js +509 -0
  52. package/dist/chunks/task-utils.d.D-gFPNFi.d.ts +144 -0
  53. package/dist/chunks/tinyrainbow.Do8I1XRG.js +88 -0
  54. package/dist/chunks/{utils.BS4fH3nR.js → utils.BBk_icFG.js} +50 -52
  55. package/dist/chunks/{utils.BX5Fg8C4.js → utils.DYj33du9.js} +1 -17
  56. package/dist/chunks/vm.b4MbCAJQ.js +1329 -0
  57. package/dist/chunks/{worker.d.ZpHpO4yb.d.ts → worker.d.CyJRpyfZ.d.ts} +34 -19
  58. package/dist/cli.js +5 -6
  59. package/dist/config.cjs +9 -6
  60. package/dist/config.d.ts +27 -25
  61. package/dist/config.js +3 -3
  62. package/dist/index.d.ts +471 -38
  63. package/dist/index.js +18 -19
  64. package/dist/module-evaluator.d.ts +64 -5
  65. package/dist/module-evaluator.js +122 -62
  66. package/dist/node.d.ts +355 -87
  67. package/dist/node.js +49 -73
  68. package/dist/runtime.d.ts +43 -6
  69. package/dist/runtime.js +7 -9
  70. package/dist/spy.js +1 -1
  71. package/dist/task-utils.js +290 -0
  72. package/dist/{chunks/traces.DT5aQ62U.js → traces.js} +3 -2
  73. package/dist/worker.d.ts +8 -10
  74. package/dist/worker.js +33 -43
  75. package/dist/workers/forks.js +30 -40
  76. package/dist/workers/runVmTests.js +66 -43
  77. package/dist/workers/threads.js +30 -40
  78. package/dist/workers/vmForks.js +19 -20
  79. package/dist/workers/vmThreads.js +19 -20
  80. package/globals.d.ts +19 -19
  81. package/index.cjs +3 -3
  82. package/optional-runtime-types.d.ts +1 -1
  83. package/optional-types.d.ts +1 -1
  84. package/package.json +59 -74
  85. package/suppress-warnings.cjs +1 -1
  86. package/dist/chunks/_commonjsHelpers.D26ty3Ew.js +0 -6
  87. package/dist/chunks/benchmark.CX_oY03V.js +0 -40
  88. package/dist/chunks/benchmark.d.DAaHLpsq.d.ts +0 -24
  89. package/dist/chunks/config.d.A1h_Y6Jt.d.ts +0 -232
  90. package/dist/chunks/coverage.DM_a_rWm.js +0 -1087
  91. package/dist/chunks/coverage.d.BZtK59WP.d.ts +0 -37
  92. package/dist/chunks/evaluatedModules.Dg1zASAC.js +0 -17
  93. package/dist/chunks/global.d.DVsSRdQ5.d.ts +0 -100
  94. package/dist/chunks/globals.Dj1TGiMC.js +0 -31
  95. package/dist/chunks/index.DC7d2Pf8.js +0 -729
  96. package/dist/chunks/index.DdgEv5B1.js +0 -42
  97. package/dist/chunks/index.UpGiHP7g.js +0 -4255
  98. package/dist/chunks/index.og1WyBLx.js +0 -6358
  99. package/dist/chunks/nativeModuleRunner.BIakptoF.js +0 -36
  100. package/dist/chunks/node.COQbm6gK.js +0 -14
  101. package/dist/chunks/plugin.d.DwFIiJ7i.d.ts +0 -38
  102. package/dist/chunks/rpc.MzXet3jl.js +0 -144
  103. package/dist/chunks/rpc.d.B_8sPU0w.d.ts +0 -30
  104. package/dist/chunks/setup-common.DYx3LtFI.js +0 -60
  105. package/dist/chunks/startVitestModuleRunner.DB-7oCpn.js +0 -740
  106. package/dist/chunks/suite.d.udJtyAgw.d.ts +0 -10
  107. package/dist/chunks/test.DNmyFkvJ.js +0 -4430
  108. package/dist/chunks/traces.d.D2T_R8rx.d.ts +0 -60
  109. package/dist/chunks/vm.CXMd5FHa.js +0 -785
  110. package/dist/coverage.d.ts +0 -123
  111. package/dist/coverage.js +0 -27
  112. package/dist/environments.d.ts +0 -22
  113. package/dist/environments.js +0 -5
  114. package/dist/reporters.d.ts +0 -27
  115. package/dist/reporters.js +0 -26
  116. package/dist/runners.d.ts +0 -70
  117. package/dist/runners.js +0 -19
  118. package/dist/snapshot.d.ts +0 -9
  119. package/dist/snapshot.js +0 -6
  120. package/dist/suite.d.ts +0 -5
  121. package/dist/suite.js +0 -8
@@ -1,37 +0,0 @@
1
- interface RuntimeCoverageModuleLoader {
2
- import: (id: string) => Promise<{
3
- default: RuntimeCoverageProviderModule;
4
- }>;
5
- isBrowser?: boolean;
6
- moduleExecutionInfo?: Map<string, {
7
- startOffset: number;
8
- }>;
9
- }
10
- interface RuntimeCoverageProviderModule {
11
- /**
12
- * Factory for creating a new coverage provider
13
- */
14
- getProvider: () => any;
15
- /**
16
- * Executed before tests are run in the worker thread.
17
- */
18
- startCoverage?: (runtimeOptions: {
19
- isolate: boolean;
20
- }) => unknown | Promise<unknown>;
21
- /**
22
- * Executed on after each run in the worker thread. Possible to return a payload passed to the provider
23
- */
24
- takeCoverage?: (runtimeOptions?: {
25
- moduleExecutionInfo?: Map<string, {
26
- startOffset: number;
27
- }>;
28
- }) => unknown | Promise<unknown>;
29
- /**
30
- * Executed after all tests have been run in the worker thread.
31
- */
32
- stopCoverage?: (runtimeOptions: {
33
- isolate: boolean;
34
- }) => unknown | Promise<unknown>;
35
- }
36
-
37
- export type { RuntimeCoverageModuleLoader as R, RuntimeCoverageProviderModule as a };
@@ -1,17 +0,0 @@
1
- import { dirname, resolve } from 'pathe';
2
- import { EvaluatedModules } from 'vite/module-runner';
3
-
4
- // TODO: this is not needed in Vite 7.2+
5
- class VitestEvaluatedModules extends EvaluatedModules {
6
- getModuleSourceMapById(id) {
7
- const map = super.getModuleSourceMapById(id);
8
- if (map != null && !("_patched" in map)) {
9
- map._patched = true;
10
- const dir = dirname(map.url);
11
- map.resolvedSources = (map.map.sources || []).map((s) => resolve(dir, s || ""));
12
- }
13
- return map;
14
- }
15
- }
16
-
17
- export { VitestEvaluatedModules as V };
@@ -1,100 +0,0 @@
1
- import { PromisifyAssertion, Tester, ExpectStatic } from '@vitest/expect';
2
- import { Plugin } from '@vitest/pretty-format';
3
- import { Test } from '@vitest/runner';
4
- import { SnapshotState } from '@vitest/snapshot';
5
- import { B as BenchmarkResult } from './benchmark.d.DAaHLpsq.js';
6
- import { U as UserConsoleLog } from './traces.d.D2T_R8rx.js';
7
-
8
- interface SnapshotMatcher<T> {
9
- <U extends { [P in keyof T] : any }>(snapshot: Partial<U>, hint?: string): void;
10
- (hint?: string): void;
11
- }
12
- interface InlineSnapshotMatcher<T> {
13
- <U extends { [P in keyof T] : any }>(properties: Partial<U>, snapshot?: string, hint?: string): void;
14
- (hint?: string): void;
15
- }
16
- declare module "@vitest/expect" {
17
- interface MatcherState {
18
- environment: string;
19
- snapshotState: SnapshotState;
20
- task?: Readonly<Test>;
21
- }
22
- interface ExpectPollOptions {
23
- interval?: number;
24
- timeout?: number;
25
- message?: string;
26
- }
27
- interface ExpectStatic {
28
- assert: Chai.AssertStatic;
29
- unreachable: (message?: string) => never;
30
- soft: <T>(actual: T, message?: string) => Assertion<T>;
31
- poll: <T>(actual: () => T, options?: ExpectPollOptions) => PromisifyAssertion<Awaited<T>>;
32
- addEqualityTesters: (testers: Array<Tester>) => void;
33
- assertions: (expected: number) => void;
34
- hasAssertions: () => void;
35
- addSnapshotSerializer: (plugin: Plugin) => void;
36
- }
37
- interface Assertion<T> {
38
- matchSnapshot: SnapshotMatcher<T>;
39
- toMatchSnapshot: SnapshotMatcher<T>;
40
- toMatchInlineSnapshot: InlineSnapshotMatcher<T>;
41
- /**
42
- * Checks that an error thrown by a function matches a previously recorded snapshot.
43
- *
44
- * @param hint - Optional custom error message.
45
- *
46
- * @example
47
- * expect(functionWithError).toThrowErrorMatchingSnapshot();
48
- */
49
- toThrowErrorMatchingSnapshot: (hint?: string) => void;
50
- /**
51
- * Checks that an error thrown by a function matches an inline snapshot within the test file.
52
- * Useful for keeping snapshots close to the test code.
53
- *
54
- * @param snapshot - Optional inline snapshot string to match.
55
- * @param hint - Optional custom error message.
56
- *
57
- * @example
58
- * const throwError = () => { throw new Error('Error occurred') };
59
- * expect(throwError).toThrowErrorMatchingInlineSnapshot(`"Error occurred"`);
60
- */
61
- toThrowErrorMatchingInlineSnapshot: (snapshot?: string, hint?: string) => void;
62
- /**
63
- * Compares the received value to a snapshot saved in a specified file.
64
- * Useful for cases where snapshot content is large or needs to be shared across tests.
65
- *
66
- * @param filepath - Path to the snapshot file.
67
- * @param hint - Optional custom error message.
68
- *
69
- * @example
70
- * await expect(largeData).toMatchFileSnapshot('path/to/snapshot.json');
71
- */
72
- toMatchFileSnapshot: (filepath: string, hint?: string) => Promise<void>;
73
- }
74
- }
75
- declare module "@vitest/runner" {
76
- interface TestContext {
77
- /**
78
- * `expect` instance bound to the current test.
79
- *
80
- * This API is useful for running snapshot tests concurrently because global expect cannot track them.
81
- */
82
- readonly expect: ExpectStatic;
83
- /** @internal */
84
- _local: boolean;
85
- }
86
- interface TaskMeta {
87
- typecheck?: boolean;
88
- benchmark?: boolean;
89
- }
90
- interface File {
91
- prepareDuration?: number;
92
- environmentLoad?: number;
93
- }
94
- interface TaskBase {
95
- logs?: UserConsoleLog[];
96
- }
97
- interface TaskResult {
98
- benchmark?: BenchmarkResult;
99
- }
100
- }
@@ -1,31 +0,0 @@
1
- import { g as globalApis } from './constants.CPYnjOGj.js';
2
- import { i as index } from './index.DdgEv5B1.js';
3
- import './test.DNmyFkvJ.js';
4
- import '@vitest/runner';
5
- import '@vitest/utils/helpers';
6
- import '@vitest/utils/timers';
7
- import './benchmark.CX_oY03V.js';
8
- import '@vitest/runner/utils';
9
- import './utils.BX5Fg8C4.js';
10
- import '@vitest/expect';
11
- import '@vitest/utils/error';
12
- import 'pathe';
13
- import '@vitest/spy';
14
- import '@vitest/utils/offset';
15
- import '@vitest/utils/source-map';
16
- import './_commonjsHelpers.D26ty3Ew.js';
17
- import './rpc.MzXet3jl.js';
18
- import './index.Chj8NDwU.js';
19
- import '@vitest/snapshot';
20
- import './evaluatedModules.Dg1zASAC.js';
21
- import 'vite/module-runner';
22
- import 'expect-type';
23
-
24
- function registerApiGlobally() {
25
- globalApis.forEach((api) => {
26
- // @ts-expect-error I know what I am doing :P
27
- globalThis[api] = index[api];
28
- });
29
- }
30
-
31
- export { registerApiGlobally };