vitest 4.0.0-beta.1 → 4.0.0-beta.10

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 (85) hide show
  1. package/LICENSE.md +2 -2
  2. package/dist/browser.d.ts +13 -14
  3. package/dist/browser.js +6 -5
  4. package/dist/chunks/base.Cjha6usc.js +129 -0
  5. package/dist/chunks/{benchmark.CYdenmiT.js → benchmark.CJUa-Hsa.js} +6 -8
  6. package/dist/chunks/{benchmark.d.BwvBVTda.d.ts → benchmark.d.DAaHLpsq.d.ts} +4 -4
  7. package/dist/chunks/{browser.d.q8Z0P0q1.d.ts → browser.d.yFAklsD1.d.ts} +5 -5
  8. package/dist/chunks/{cac.D3EzDDZd.js → cac.DCxo_nSu.js} +70 -152
  9. package/dist/chunks/{cli-api.Dn5gKePv.js → cli-api.BJJXh9BV.js} +1330 -1677
  10. package/dist/chunks/{config.d.HJdfX-8k.d.ts → config.d.B_LthbQq.d.ts} +58 -63
  11. package/dist/chunks/{console.CtFJOzRO.js → console.7h5kHUIf.js} +34 -70
  12. package/dist/chunks/{constants.DnKduX2e.js → constants.D_Q9UYh-.js} +1 -9
  13. package/dist/chunks/{coverage.Cwa-XhJt.js → coverage.BCU-r2QL.js} +515 -781
  14. package/dist/chunks/{coverage.DVF1vEu8.js → coverage.D_JHT54q.js} +2 -2
  15. package/dist/chunks/{coverage.d.S9RMNXIe.d.ts → coverage.d.BZtK59WP.d.ts} +10 -8
  16. package/dist/chunks/{creator.GK6I-cL4.js → creator.08Gi-vCA.js} +93 -77
  17. package/dist/chunks/{date.Bq6ZW5rf.js → date.-jtEtIeV.js} +6 -17
  18. package/dist/chunks/{environment.d.CUq4cUgQ.d.ts → environment.d.BsToaxti.d.ts} +27 -6
  19. package/dist/chunks/{git.BVQ8w_Sw.js → git.BFNcloKD.js} +1 -2
  20. package/dist/chunks/{global.d.CVbXEflG.d.ts → global.d.BK3X7FW1.d.ts} +2 -5
  21. package/dist/chunks/{globals.Cxal6MLI.js → globals.DG-S3xFe.js} +8 -8
  22. package/dist/chunks/{index.CZI_8rVt.js → index.BIP7prJq.js} +289 -608
  23. package/dist/chunks/{index.B521nVV-.js → index.Bgo3tNWt.js} +23 -4
  24. package/dist/chunks/{index.TfbsX-3I.js → index.BjKEiSn0.js} +14 -24
  25. package/dist/chunks/{index.BWf_gE5n.js → index.CMfqw92x.js} +7 -6
  26. package/dist/chunks/{index.CmSc2RE5.js → index.DIWhzsUh.js} +72 -118
  27. package/dist/chunks/{inspector.C914Efll.js → inspector.CvQD-Nie.js} +10 -25
  28. package/dist/chunks/moduleRunner.d.D9nBoC4p.d.ts +201 -0
  29. package/dist/chunks/moduleTransport.I-bgQy0S.js +19 -0
  30. package/dist/chunks/{node.fjCdwEIl.js → node.CyipiPvJ.js} +1 -1
  31. package/dist/chunks/{plugin.d.C2EcJUjo.d.ts → plugin.d.BMVSnsGV.d.ts} +1 -1
  32. package/dist/chunks/{reporters.d.DxZg19fy.d.ts → reporters.d.BUWjmRYq.d.ts} +1226 -1291
  33. package/dist/chunks/resolveSnapshotEnvironment.Bkht6Yor.js +81 -0
  34. package/dist/chunks/resolver.Bx6lE0iq.js +119 -0
  35. package/dist/chunks/rpc.BKr6mtxz.js +65 -0
  36. package/dist/chunks/{setup-common.D7ZqXFx-.js → setup-common.uiMcU3cv.js} +17 -29
  37. package/dist/chunks/startModuleRunner.p67gbNo9.js +665 -0
  38. package/dist/chunks/{suite.d.FvehnV49.d.ts → suite.d.BJWk38HB.d.ts} +1 -1
  39. package/dist/chunks/test.BiqSKISg.js +214 -0
  40. package/dist/chunks/{typechecker.CVytUJuF.js → typechecker.DB-fIMaH.js} +144 -213
  41. package/dist/chunks/{utils.CAioKnHs.js → utils.C2YI6McM.js} +5 -14
  42. package/dist/chunks/{utils.XdZDrNZV.js → utils.D2R2NiOH.js} +8 -27
  43. package/dist/chunks/{vi.bdSIJ99Y.js → vi.ZPgvtBao.js} +156 -305
  44. package/dist/chunks/{vm.BThCzidc.js → vm.Ca0Y0W5f.js} +116 -226
  45. package/dist/chunks/{worker.d.DoNjFAiv.d.ts → worker.d.BDsXGkwh.d.ts} +28 -22
  46. package/dist/chunks/{worker.d.CmvJfRGs.d.ts → worker.d.BNcX_2mH.d.ts} +1 -1
  47. package/dist/cli.js +4 -4
  48. package/dist/config.cjs +3 -9
  49. package/dist/config.d.ts +49 -54
  50. package/dist/config.js +1 -1
  51. package/dist/coverage.d.ts +27 -26
  52. package/dist/coverage.js +6 -7
  53. package/dist/environments.d.ts +9 -13
  54. package/dist/environments.js +1 -1
  55. package/dist/index.d.ts +38 -45
  56. package/dist/index.js +7 -9
  57. package/dist/module-evaluator.d.ts +13 -0
  58. package/dist/module-evaluator.js +276 -0
  59. package/dist/module-runner.js +15 -0
  60. package/dist/node.d.ts +40 -41
  61. package/dist/node.js +23 -33
  62. package/dist/reporters.d.ts +12 -13
  63. package/dist/reporters.js +3 -3
  64. package/dist/runners.d.ts +3 -3
  65. package/dist/runners.js +13 -232
  66. package/dist/snapshot.js +2 -2
  67. package/dist/suite.d.ts +2 -2
  68. package/dist/suite.js +2 -2
  69. package/dist/worker.js +90 -47
  70. package/dist/workers/forks.js +34 -10
  71. package/dist/workers/runVmTests.js +36 -56
  72. package/dist/workers/threads.js +34 -10
  73. package/dist/workers/vmForks.js +11 -10
  74. package/dist/workers/vmThreads.js +11 -10
  75. package/dist/workers.d.ts +5 -4
  76. package/dist/workers.js +35 -17
  77. package/globals.d.ts +17 -17
  78. package/package.json +32 -31
  79. package/dist/chunks/base.Bj3pWTr1.js +0 -38
  80. package/dist/chunks/execute.B7h3T_Hc.js +0 -708
  81. package/dist/chunks/index.D-VkfKhf.js +0 -105
  82. package/dist/chunks/rpc.CsFtxqeq.js +0 -83
  83. package/dist/chunks/runBaseTests.BC7ZIH5L.js +0 -129
  84. package/dist/execute.d.ts +0 -148
  85. package/dist/execute.js +0 -13
package/dist/node.d.ts CHANGED
@@ -3,38 +3,37 @@ import { InlineConfig, UserConfig as UserConfig$1, Plugin, ResolvedConfig as Res
3
3
  export { vite as Vite };
4
4
  export { esbuildVersion, isCSSRequest, isFileServingAllowed, parseAst, parseAstAsync, rollupVersion, version as viteVersion } from 'vite';
5
5
  import { IncomingMessage } from 'node:http';
6
- import { h as ResolvedConfig, f as UserConfig, i as VitestRunMode, j as VitestOptions, V as Vitest, A as ApiConfig, T as TestProject, k as TestSequencer, l as TestSpecification, L as Logger } from './chunks/reporters.d.DxZg19fy.js';
7
- export { ao as BaseCoverageOptions, K as BenchmarkUserOptions, N as BrowserBuiltinProvider, Q as BrowserCommand, X as BrowserCommandContext, Y as BrowserConfigOptions, Z as BrowserInstanceOption, _ as BrowserModuleMocker, $ as BrowserOrchestrator, a0 as BrowserProvider, a1 as BrowserProviderInitializationOptions, a2 as BrowserProviderModule, a3 as BrowserProviderOptions, a4 as BrowserScript, a5 as BrowserServerState, a6 as BrowserServerStateSession, ab as BuiltinEnvironment, a7 as CDPSession, ac as CSSModuleScopeStrategy, ap as CoverageIstanbulOptions, aq as CoverageOptions, ar as CoverageProvider, as as CoverageProviderModule, at as CoverageReporter, c as CoverageV8Options, au as CustomProviderOptions, ad as DepsOptimizationOptions, ae as EnvironmentOptions, H as HTMLOptions, I as InlineConfig, q as JUnitOptions, J as JsonOptions, M as ModuleDiagnostic, O as OnServerRestartHandler, m as OnTestsRerunHandler, a8 as ParentProjectBrowser, af as Pool, ag as PoolOptions, P as ProcessPool, a9 as ProjectBrowser, ah as ProjectConfig, b as ReportContext, aw as ReportedHookContext, ax as Reporter, aj as ResolveSnapshotPathHandler, ak as ResolveSnapshotPathHandlerContext, aa as ResolvedBrowserOptions, R as ResolvedCoverageOptions, ai as ResolvedProjectConfig, S as SerializedTestProject, r as TaskOptions, s as TestCase, t as TestCollection, u as TestDiagnostic, v as TestModule, w as TestModuleState, x as TestResult, y as TestResultFailed, z as TestResultPassed, B as TestResultSkipped, ay as TestRunEndReason, av as TestRunResult, G as TestSequencerConstructor, D as TestState, E as TestSuite, F as TestSuiteState, al as TransformModePatterns, am as TypecheckConfig, U as UserWorkspaceConfig, an as VitestEnvironment, n as VitestPackageInstaller, W as WatcherTriggerPattern, o as WorkspaceSpec, p as getFilePoolName } from './chunks/reporters.d.DxZg19fy.js';
8
- import { R as RuntimeRPC } from './chunks/worker.d.DoNjFAiv.js';
9
- export { T as TestExecutionType } from './chunks/worker.d.DoNjFAiv.js';
6
+ import { h as ResolvedConfig, f as UserConfig, i as VitestRunMode, j as VitestOptions, V as Vitest, A as ApiConfig, k as TestSpecification, T as TestProject, P as Pool, l as TestSequencer, L as Logger } from './chunks/reporters.d.BUWjmRYq.js';
7
+ export { al as BaseCoverageOptions, G as BenchmarkUserOptions, K as BrowserBuiltinProvider, N as BrowserCommand, Q as BrowserCommandContext, X as BrowserConfigOptions, Y as BrowserInstanceOption, Z as BrowserModuleMocker, _ as BrowserOrchestrator, $ as BrowserProvider, a0 as BrowserProviderOption, a1 as BrowserScript, a2 as BrowserServerState, a3 as BrowserServerStateSession, aa as BuiltinEnvironment, a4 as CDPSession, ab as CSSModuleScopeStrategy, am as CoverageIstanbulOptions, an as CoverageOptions, ao as CoverageProvider, ap as CoverageProviderModule, aq as CoverageReporter, c as CoverageV8Options, ar as CustomProviderOptions, ac as DepsOptimizationOptions, ad as EnvironmentOptions, H as HTMLOptions, I as InlineConfig, o as JUnitOptions, J as JsonOptions, M as ModuleDiagnostic, O as OnServerRestartHandler, m as OnTestsRerunHandler, a5 as ParentProjectBrowser, ae as PoolOptions, a6 as ProjectBrowser, af as ProjectConfig, b as ReportContext, at as ReportedHookContext, au as Reporter, ah as ResolveSnapshotPathHandler, ai as ResolveSnapshotPathHandlerContext, a7 as ResolvedBrowserOptions, R as ResolvedCoverageOptions, ag as ResolvedProjectConfig, S as SerializedTestProject, p as TaskOptions, q as TestCase, r as TestCollection, s as TestDiagnostic, t as TestModule, u as TestModuleState, v as TestResult, w as TestResultFailed, x as TestResultPassed, y as TestResultSkipped, av as TestRunEndReason, as as TestRunResult, F as TestSequencerConstructor, z as TestState, B as TestSuite, D as TestSuiteState, a8 as ToMatchScreenshotComparators, a9 as ToMatchScreenshotOptions, aj as TypecheckConfig, U as UserWorkspaceConfig, ak as VitestEnvironment, n as VitestPackageInstaller, W as WatcherTriggerPattern, E as experimental_getRunnerTask } from './chunks/reporters.d.BUWjmRYq.js';
8
+ import { Awaitable } from '@vitest/utils';
9
+ export { SerializedError } from '@vitest/utils';
10
+ import { R as RuntimeRPC } from './chunks/worker.d.BDsXGkwh.js';
11
+ export { T as TestExecutionType } from './chunks/worker.d.BDsXGkwh.js';
10
12
  import { Writable } from 'node:stream';
11
- export { V as VitestPluginContext } from './chunks/plugin.d.C2EcJUjo.js';
12
- export { W as WorkerContext } from './chunks/worker.d.CmvJfRGs.js';
13
+ export { V as VitestPluginContext } from './chunks/plugin.d.BMVSnsGV.js';
14
+ export { W as WorkerContext } from './chunks/worker.d.BNcX_2mH.js';
13
15
  import { Debugger } from 'debug';
14
- import './chunks/global.d.CVbXEflG.js';
16
+ import './chunks/global.d.BK3X7FW1.js';
15
17
  export { Task as RunnerTask, TaskResult as RunnerTaskResult, TaskResultPack as RunnerTaskResultPack, Test as RunnerTestCase, File as RunnerTestFile, Suite as RunnerTestSuite, SequenceHooks, SequenceSetupFiles } from '@vitest/runner';
16
- export { b as RuntimeConfig } from './chunks/config.d.HJdfX-8k.js';
17
- export { SerializedError } from '@vitest/utils';
18
+ export { b as RuntimeConfig } from './chunks/config.d.B_LthbQq.js';
18
19
  export { generateFileHash } from '@vitest/runner/utils';
19
- import './chunks/environment.d.CUq4cUgQ.js';
20
- import 'node:console';
21
- import './chunks/browser.d.q8Z0P0q1.js';
20
+ import './chunks/environment.d.BsToaxti.js';
22
21
  import '@vitest/mocker';
23
22
  import '@vitest/utils/source-map';
23
+ import './chunks/browser.d.yFAklsD1.js';
24
24
  import '@vitest/pretty-format';
25
25
  import '@vitest/snapshot';
26
26
  import '@vitest/utils/diff';
27
- import 'vite-node';
28
- import 'chai';
27
+ import '@vitest/expect';
29
28
  import 'vitest/optional-types.js';
30
- import './chunks/benchmark.d.BwvBVTda.js';
29
+ import './chunks/benchmark.d.DAaHLpsq.js';
31
30
  import 'tinybench';
32
- import './chunks/coverage.d.S9RMNXIe.js';
33
- import 'vite-node/client';
31
+ import './chunks/coverage.d.BZtK59WP.js';
34
32
  import '@vitest/snapshot/manager';
35
33
  import 'node:fs';
34
+ import 'node:console';
35
+ import 'vite/module-runner';
36
36
  import 'node:worker_threads';
37
- import '@vitest/expect';
38
37
 
39
38
  type RawErrsMap = Map<string, TscErrorInfo[]>;
40
39
  interface TscErrorInfo {
@@ -55,13 +54,15 @@ interface RootAndTarget {
55
54
  targetAbsPath: string;
56
55
  }
57
56
  type Context = RootAndTarget & {
58
- rawErrsMap: RawErrsMap
59
- openedDirs: Set<string>
60
- lastActivePath?: string
57
+ rawErrsMap: RawErrsMap;
58
+ openedDirs: Set<string>;
59
+ lastActivePath?: string;
61
60
  };
62
61
 
63
62
  declare function isValidApiRequest(config: ResolvedConfig, req: IncomingMessage): boolean;
64
63
 
64
+ declare function escapeTestName(label: string, dynamic: boolean): string;
65
+
65
66
  interface CliOptions extends UserConfig {
66
67
  /**
67
68
  * Override the watch mode
@@ -86,7 +87,7 @@ interface CliOptions extends UserConfig {
86
87
  * @experimental
87
88
  */
88
89
  configLoader?: InlineConfig extends {
89
- configLoader?: infer T
90
+ configLoader?: infer T;
90
91
  } ? T : never;
91
92
  }
92
93
  /**
@@ -100,11 +101,11 @@ interface CliParseOptions {
100
101
  allowUnknownOptions?: boolean;
101
102
  }
102
103
  declare function parseCLI(argv: string | string[], config?: CliParseOptions): {
103
- filter: string[]
104
- options: CliOptions
104
+ filter: string[];
105
+ options: CliOptions;
105
106
  };
106
107
 
107
- declare function resolveApiServerConfig<Options extends ApiConfig & UserConfig>(options: Options, defaultPort: number): ApiConfig | undefined;
108
+ declare function resolveApiServerConfig<Options extends ApiConfig & Omit<UserConfig, "expect">>(options: Options, defaultPort: number): ApiConfig | undefined;
108
109
 
109
110
  declare function createVitest(mode: VitestRunMode, options: CliOptions, viteOverrides?: UserConfig$1, vitestOptions?: VitestOptions): Promise<Vitest>;
110
111
 
@@ -117,22 +118,26 @@ declare class GitNotFoundError extends Error {
117
118
  constructor();
118
119
  }
119
120
 
120
- /** @deprecated use `TestProject` instead */
121
- type GlobalSetupContext = TestProject;
122
-
123
121
  declare function VitestPlugin(options?: UserConfig, vitest?: Vitest): Promise<Plugin[]>;
124
122
 
125
- // this is only exported as a public function and not used inside vitest
126
123
  declare function resolveConfig(options?: UserConfig, viteOverrides?: UserConfig$1): Promise<{
127
- vitestConfig: ResolvedConfig
128
- viteConfig: ResolvedConfig$1
124
+ vitestConfig: ResolvedConfig;
125
+ viteConfig: ResolvedConfig$1;
129
126
  }>;
130
127
 
131
128
  declare function resolveFsAllow(projectRoot: string, rootConfigFile: string | false | undefined): string[];
132
129
 
130
+ type RunWithFiles = (files: TestSpecification[], invalidates?: string[]) => Awaitable<void>;
131
+ interface ProcessPool {
132
+ name: string;
133
+ runTests: RunWithFiles;
134
+ collectTests: RunWithFiles;
135
+ close?: () => Awaitable<void>;
136
+ }
137
+ declare function getFilePoolName(project: TestProject): Pool;
138
+
133
139
  interface MethodsOptions {
134
140
  cacheFs?: boolean;
135
- // do not report files
136
141
  collect?: boolean;
137
142
  }
138
143
  declare function createMethodsRPC(project: TestProject, options?: MethodsOptions): RuntimeRPC;
@@ -140,18 +145,13 @@ declare function createMethodsRPC(project: TestProject, options?: MethodsOptions
140
145
  declare class BaseSequencer implements TestSequencer {
141
146
  protected ctx: Vitest;
142
147
  constructor(ctx: Vitest);
143
- // async so it can be extended by other sequelizers
144
148
  shard(files: TestSpecification[]): Promise<TestSpecification[]>;
145
- // async so it can be extended by other sequelizers
146
149
  sort(files: TestSpecification[]): Promise<TestSpecification[]>;
150
+ private calculateShardRange;
147
151
  }
148
152
 
149
153
  declare function registerConsoleShortcuts(ctx: Vitest, stdin: NodeJS.ReadStream | undefined, stdout: NodeJS.WriteStream | Writable): () => void;
150
154
 
151
- // This is copy-pasted and needs to be synced from time to time. Ideally, Vite's `createLogger` should accept a custom `console`
152
- // https://github.com/vitejs/vite/blob/main/packages/vite/src/node/logger.ts?rgh-link-date=2024-10-16T23%3A29%3A19Z
153
- // When Vitest supports only Vite 6 and above, we can use Vite's `createLogger({ console })`
154
- // https://github.com/vitejs/vite/pull/18379
155
155
  declare function createViteLogger(console: Logger, level?: LogLevel, options?: LoggerOptions): Logger$1;
156
156
 
157
157
  declare const rootDir: string;
@@ -163,8 +163,7 @@ declare const version: string;
163
163
 
164
164
  declare const createViteServer: typeof vite.createServer;
165
165
 
166
- // rolldownVersion is exported only by rolldown-vite
167
166
  declare const rolldownVersion: string | undefined;
168
167
 
169
- export { ApiConfig, BaseSequencer, GitNotFoundError, ResolvedConfig, TestProject, TestSequencer, TestSpecification, UserConfig as TestUserConfig, FilesNotFoundError as TestsNotFoundError, Vitest, VitestOptions, VitestPlugin, VitestRunMode, TestProject as WorkspaceProject, createDebugger, createMethodsRPC, createViteLogger, createViteServer, createVitest, distDir, isValidApiRequest, parseCLI, registerConsoleShortcuts, resolveApiServerConfig, resolveConfig, resolveFsAllow, rolldownVersion, rootDir, startVitest, version };
170
- export type { CliParseOptions, GlobalSetupContext, CollectLineNumbers as TypeCheckCollectLineNumbers, CollectLines as TypeCheckCollectLines, Context as TypeCheckContext, TscErrorInfo as TypeCheckErrorInfo, RawErrsMap as TypeCheckRawErrorsMap, RootAndTarget as TypeCheckRootAndTarget };
168
+ export { ApiConfig, BaseSequencer, GitNotFoundError, Pool, ResolvedConfig, TestProject, TestSequencer, TestSpecification, UserConfig as TestUserConfig, FilesNotFoundError as TestsNotFoundError, Vitest, VitestOptions, VitestPlugin, VitestRunMode, createDebugger, createMethodsRPC, createViteLogger, createViteServer, createVitest, distDir, escapeTestName, getFilePoolName, isValidApiRequest, parseCLI, registerConsoleShortcuts, resolveApiServerConfig, resolveConfig, resolveFsAllow, rolldownVersion, rootDir, startVitest, version };
169
+ export type { CliParseOptions, ProcessPool, CollectLineNumbers as TypeCheckCollectLineNumbers, CollectLines as TypeCheckCollectLines, Context as TypeCheckContext, TscErrorInfo as TypeCheckErrorInfo, RawErrsMap as TypeCheckRawErrorsMap, RootAndTarget as TypeCheckRootAndTarget };
package/dist/node.js CHANGED
@@ -1,29 +1,26 @@
1
1
  import * as vite from 'vite';
2
2
  import { resolveConfig as resolveConfig$1, mergeConfig } from 'vite';
3
3
  export { esbuildVersion, isCSSRequest, isFileServingAllowed, parseAst, parseAstAsync, rollupVersion, version as viteVersion } from 'vite';
4
- import { V as Vitest, a as VitestPlugin } from './chunks/cli-api.Dn5gKePv.js';
5
- export { G as GitNotFoundError, F as TestsNotFoundError, b as VitestPackageInstaller, e as createViteLogger, c as createVitest, i as isValidApiRequest, d as registerConsoleShortcuts, r as resolveFsAllow, s as startVitest } from './chunks/cli-api.Dn5gKePv.js';
6
- export { p as parseCLI } from './chunks/cac.D3EzDDZd.js';
7
- import { r as resolveConfig$2 } from './chunks/coverage.Cwa-XhJt.js';
8
- export { b as BaseSequencer, c as createMethodsRPC, g as getFilePoolName, a as resolveApiServerConfig } from './chunks/coverage.Cwa-XhJt.js';
4
+ import { V as Vitest, a as VitestPlugin } from './chunks/cli-api.BJJXh9BV.js';
5
+ export { G as GitNotFoundError, F as TestsNotFoundError, b as VitestPackageInstaller, h as createDebugger, g as createViteLogger, c as createVitest, e as escapeTestName, d as experimental_getRunnerTask, i as isValidApiRequest, f as registerConsoleShortcuts, r as resolveFsAllow, s as startVitest } from './chunks/cli-api.BJJXh9BV.js';
6
+ export { p as parseCLI } from './chunks/cac.DCxo_nSu.js';
7
+ import { r as resolveConfig$2 } from './chunks/coverage.BCU-r2QL.js';
8
+ export { b as BaseSequencer, c as createMethodsRPC, g as getFilePoolName, a as resolveApiServerConfig } from './chunks/coverage.BCU-r2QL.js';
9
9
  import { slash, deepClone } from '@vitest/utils';
10
10
  import { f as findUp } from './chunks/index.X0nbfr6-.js';
11
11
  import { resolve } from 'pathe';
12
- import { c as configFiles } from './chunks/constants.DnKduX2e.js';
12
+ import { c as configFiles } from './chunks/constants.D_Q9UYh-.js';
13
13
  export { distDir, rootDir } from './path.js';
14
- import createDebug from 'debug';
15
14
  export { generateFileHash } from '@vitest/runner/utils';
16
15
  import 'node:fs';
17
- import './chunks/coverage.DVF1vEu8.js';
16
+ import './chunks/coverage.D_JHT54q.js';
18
17
  import 'node:path';
18
+ import 'node:os';
19
19
  import '@vitest/snapshot/manager';
20
- import 'vite-node/client';
21
- import 'vite-node/server';
22
- import './chunks/index.B521nVV-.js';
23
- import './chunks/index.CZI_8rVt.js';
20
+ import './chunks/index.Bgo3tNWt.js';
21
+ import './chunks/index.BIP7prJq.js';
24
22
  import 'node:fs/promises';
25
- import './chunks/typechecker.CVytUJuF.js';
26
- import 'node:os';
23
+ import './chunks/typechecker.DB-fIMaH.js';
27
24
  import 'node:perf_hooks';
28
25
  import '@vitest/utils/source-map';
29
26
  import 'tinyexec';
@@ -46,14 +43,18 @@ import 'zlib';
46
43
  import 'buffer';
47
44
  import './chunks/_commonjsHelpers.BFTU3MAI.js';
48
45
  import 'node:crypto';
46
+ import 'debug';
47
+ import '#module-evaluator';
48
+ import 'vite/module-runner';
49
49
  import 'node:url';
50
50
  import 'picomatch';
51
51
  import 'tinyglobby';
52
- import 'vite-node/utils';
52
+ import 'magic-string';
53
53
  import '@vitest/mocker/node';
54
54
  import './chunks/defaults.CXFFjsi8.js';
55
- import 'magic-string';
56
- import './chunks/index.TfbsX-3I.js';
55
+ import './chunks/resolver.Bx6lE0iq.js';
56
+ import 'es-module-lexer';
57
+ import './chunks/index.BjKEiSn0.js';
57
58
  import 'node:assert';
58
59
  import '@vitest/utils/error';
59
60
  import 'node:readline';
@@ -67,33 +68,22 @@ import 'readline';
67
68
 
68
69
  // this is only exported as a public function and not used inside vitest
69
70
  async function resolveConfig(options = {}, viteOverrides = {}) {
70
- const root = slash(resolve(options.root || process.cwd()));
71
- const configPath = options.config === false ? false : options.config ? resolve(root, options.config) : await findUp(configFiles, { cwd: root });
71
+ const root = slash(resolve(options.root || process.cwd())), configPath = options.config === false ? false : options.config ? resolve(root, options.config) : await findUp(configFiles, { cwd: root });
72
72
  options.config = configPath;
73
- const vitest = new Vitest("test", deepClone(options));
74
- const config = await resolveConfig$1(mergeConfig({
73
+ const vitest = new Vitest("test", deepClone(options)), config = await resolveConfig$1(mergeConfig({
75
74
  configFile: configPath,
76
75
  mode: options.mode || "test",
77
76
  plugins: [await VitestPlugin(options, vitest)]
78
- }, mergeConfig(viteOverrides, { root: options.root })), "serve");
79
- // Reflect just to avoid type error
80
- const updatedOptions = Reflect.get(config, "_vitest");
81
- const vitestConfig = resolveConfig$2(vitest, updatedOptions, config);
82
- await vitest.close();
83
- return {
77
+ }, mergeConfig(viteOverrides, { root: options.root })), "serve"), updatedOptions = Reflect.get(config, "_vitest"), vitestConfig = resolveConfig$2(vitest, updatedOptions, config);
78
+ return await vitest.close(), {
84
79
  viteConfig: config,
85
80
  vitestConfig
86
81
  };
87
82
  }
88
83
 
89
- function createDebugger(namespace) {
90
- const debug = createDebug(namespace);
91
- if (debug.enabled) return debug;
92
- }
93
-
94
84
  const version = Vitest.version;
95
85
  const createViteServer = vite.createServer;
96
86
  // rolldownVersion is exported only by rolldown-vite
97
87
  const rolldownVersion = vite.rolldownVersion;
98
88
 
99
- export { VitestPlugin, createDebugger, createViteServer, resolveConfig, rolldownVersion, version };
89
+ export { VitestPlugin, createViteServer, resolveConfig, rolldownVersion, version };
@@ -1,25 +1,24 @@
1
- export { aM as BaseReporter, aN as BenchmarkBuiltinReporters, az as BenchmarkReporter, aA as BenchmarkReportsMap, aO as BuiltinReporterOptions, aP as BuiltinReporters, aB as DefaultReporter, aC as DotReporter, aD as GithubActionsReporter, aE as HangingProcessReporter, aG as JUnitReporter, aQ as JsonAssertionResult, aF as JsonReporter, aR as JsonTestResult, aS as JsonTestResults, aw as ReportedHookContext, ax as Reporter, aH as ReportersMap, aI as TapFlatReporter, aJ as TapReporter, ay as TestRunEndReason, aK as VerboseBenchmarkReporter, aL as VerboseReporter } from './chunks/reporters.d.DxZg19fy.js';
1
+ export { aJ as BaseReporter, aK as BenchmarkBuiltinReporters, aw as BenchmarkReporter, ax as BenchmarkReportsMap, aL as BuiltinReporterOptions, aM as BuiltinReporters, ay as DefaultReporter, az as DotReporter, aA as GithubActionsReporter, aB as HangingProcessReporter, aD as JUnitReporter, aN as JsonAssertionResult, aC as JsonReporter, aO as JsonTestResult, aP as JsonTestResults, at as ReportedHookContext, au as Reporter, aE as ReportersMap, aF as TapFlatReporter, aG as TapReporter, av as TestRunEndReason, aH as VerboseBenchmarkReporter, aI as VerboseReporter } from './chunks/reporters.d.BUWjmRYq.js';
2
2
  import '@vitest/runner';
3
- import './chunks/environment.d.CUq4cUgQ.js';
4
3
  import '@vitest/utils';
4
+ import './chunks/environment.d.BsToaxti.js';
5
5
  import 'node:stream';
6
6
  import 'vite';
7
- import 'node:console';
8
- import './chunks/browser.d.q8Z0P0q1.js';
9
- import './chunks/worker.d.DoNjFAiv.js';
10
- import './chunks/config.d.HJdfX-8k.js';
7
+ import '@vitest/mocker';
8
+ import '@vitest/utils/source-map';
9
+ import './chunks/browser.d.yFAklsD1.js';
10
+ import './chunks/worker.d.BDsXGkwh.js';
11
+ import 'vite/module-runner';
12
+ import './chunks/config.d.B_LthbQq.js';
11
13
  import '@vitest/pretty-format';
12
14
  import '@vitest/snapshot';
13
15
  import '@vitest/utils/diff';
14
- import '@vitest/mocker';
15
- import '@vitest/utils/source-map';
16
- import 'vite-node';
17
- import 'chai';
16
+ import '@vitest/expect';
18
17
  import 'vitest/optional-types.js';
19
- import './chunks/benchmark.d.BwvBVTda.js';
18
+ import './chunks/benchmark.d.DAaHLpsq.js';
20
19
  import '@vitest/runner/utils';
21
20
  import 'tinybench';
22
- import './chunks/coverage.d.S9RMNXIe.js';
23
- import 'vite-node/client';
21
+ import './chunks/coverage.d.BZtK59WP.js';
24
22
  import '@vitest/snapshot/manager';
25
23
  import 'node:fs';
24
+ import 'node:console';
package/dist/reporters.js CHANGED
@@ -1,9 +1,9 @@
1
- export { D as DefaultReporter, a as DotReporter, G as GithubActionsReporter, H as HangingProcessReporter, b as JUnitReporter, J as JsonReporter, R as ReportersMap, T as TapFlatReporter, c as TapReporter, V as VerboseReporter } from './chunks/index.CZI_8rVt.js';
2
- export { B as BenchmarkReporter, a as BenchmarkReportsMap, V as VerboseBenchmarkReporter } from './chunks/index.TfbsX-3I.js';
1
+ export { D as DefaultReporter, a as DotReporter, G as GithubActionsReporter, H as HangingProcessReporter, b as JUnitReporter, J as JsonReporter, R as ReportersMap, T as TapFlatReporter, c as TapReporter, V as VerboseReporter } from './chunks/index.BIP7prJq.js';
2
+ export { B as BenchmarkReporter, a as BenchmarkReportsMap, V as VerboseBenchmarkReporter } from './chunks/index.BjKEiSn0.js';
3
3
  import 'node:fs';
4
4
  import 'node:fs/promises';
5
5
  import 'pathe';
6
- import './chunks/typechecker.CVytUJuF.js';
6
+ import './chunks/typechecker.DB-fIMaH.js';
7
7
  import 'node:os';
8
8
  import 'node:perf_hooks';
9
9
  import '@vitest/utils/source-map';
package/dist/runners.d.ts CHANGED
@@ -1,14 +1,14 @@
1
1
  import * as tinybench from 'tinybench';
2
2
  import { VitestRunner, VitestRunnerImportSource, Suite, File, Task, CancelReason, Test, TestContext, ImportDuration } from '@vitest/runner';
3
3
  export { VitestRunner } from '@vitest/runner';
4
- import { a as SerializedConfig } from './chunks/config.d.HJdfX-8k.js';
4
+ import { a as SerializedConfig } from './chunks/config.d.B_LthbQq.js';
5
5
  import '@vitest/pretty-format';
6
6
  import '@vitest/snapshot';
7
7
  import '@vitest/utils/diff';
8
8
 
9
9
  declare class NodeBenchmarkRunner implements VitestRunner {
10
10
  config: SerializedConfig;
11
- private __vitest_executor;
11
+ private moduleRunner;
12
12
  constructor(config: SerializedConfig);
13
13
  importTinybench(): Promise<typeof tinybench>;
14
14
  importFile(filepath: string, source: VitestRunnerImportSource): unknown;
@@ -20,7 +20,7 @@ declare class VitestTestRunner implements VitestRunner {
20
20
  config: SerializedConfig;
21
21
  private snapshotClient;
22
22
  private workerState;
23
- private __vitest_executor;
23
+ private moduleRunner;
24
24
  private cancelRun;
25
25
  private assertionsErrors;
26
26
  pool: string;
package/dist/runners.js CHANGED
@@ -1,236 +1,17 @@
1
- import { updateTask } from '@vitest/runner';
2
- import { createDefer, getSafeTimers } from '@vitest/utils';
3
- import { a as getBenchOptions, g as getBenchFn } from './chunks/benchmark.CYdenmiT.js';
4
- import { g as getWorkerState } from './chunks/utils.XdZDrNZV.js';
5
- import { setState, GLOBAL_EXPECT, getState } from '@vitest/expect';
6
- import { getTests, getNames, getTestName } from '@vitest/runner/utils';
7
- import { normalize } from 'pathe';
8
- import { g as getSnapshotClient, i as inject, c as createExpect, v as vi } from './chunks/vi.bdSIJ99Y.js';
9
- import { r as rpc } from './chunks/rpc.CsFtxqeq.js';
10
- import 'chai';
1
+ export { N as NodeBenchmarkRunner, V as VitestTestRunner } from './chunks/test.BiqSKISg.js';
2
+ import '@vitest/runner';
3
+ import '@vitest/utils';
4
+ import './chunks/benchmark.CJUa-Hsa.js';
5
+ import '@vitest/runner/utils';
6
+ import './chunks/utils.D2R2NiOH.js';
7
+ import '@vitest/expect';
8
+ import '@vitest/utils/error';
9
+ import 'pathe';
10
+ import './chunks/vi.ZPgvtBao.js';
11
11
  import './chunks/_commonjsHelpers.BFTU3MAI.js';
12
12
  import '@vitest/snapshot';
13
- import '@vitest/utils/error';
14
13
  import '@vitest/spy';
15
14
  import '@vitest/utils/source-map';
16
- import './chunks/date.Bq6ZW5rf.js';
17
- import './chunks/index.B521nVV-.js';
18
-
19
- function createBenchmarkResult(name) {
20
- return {
21
- name,
22
- rank: 0,
23
- rme: 0,
24
- samples: []
25
- };
26
- }
27
- const benchmarkTasks = /* @__PURE__ */ new WeakMap();
28
- async function runBenchmarkSuite(suite, runner) {
29
- const { Task, Bench } = await runner.importTinybench();
30
- const start = performance.now();
31
- const benchmarkGroup = [];
32
- const benchmarkSuiteGroup = [];
33
- for (const task of suite.tasks) {
34
- if (task.mode !== "run" && task.mode !== "queued") continue;
35
- if (task.meta?.benchmark) benchmarkGroup.push(task);
36
- else if (task.type === "suite") benchmarkSuiteGroup.push(task);
37
- }
38
- // run sub suites sequentially
39
- for (const subSuite of benchmarkSuiteGroup) await runBenchmarkSuite(subSuite, runner);
40
- if (benchmarkGroup.length) {
41
- const defer = createDefer();
42
- suite.result = {
43
- state: "run",
44
- startTime: start,
45
- benchmark: createBenchmarkResult(suite.name)
46
- };
47
- updateTask$1("suite-prepare", suite);
48
- const addBenchTaskListener = (task, benchmark) => {
49
- task.addEventListener("complete", (e) => {
50
- const task = e.task;
51
- const taskRes = task.result;
52
- const result = benchmark.result.benchmark;
53
- benchmark.result.state = "pass";
54
- Object.assign(result, taskRes);
55
- // compute extra stats and free raw samples as early as possible
56
- const samples = result.samples;
57
- result.sampleCount = samples.length;
58
- result.median = samples.length % 2 ? samples[Math.floor(samples.length / 2)] : (samples[samples.length / 2] + samples[samples.length / 2 - 1]) / 2;
59
- if (!runner.config.benchmark?.includeSamples) result.samples.length = 0;
60
- updateTask$1("test-finished", benchmark);
61
- }, { once: true });
62
- task.addEventListener("error", (e) => {
63
- const task = e.task;
64
- defer.reject(benchmark ? task.result.error : e);
65
- }, { once: true });
66
- };
67
- benchmarkGroup.forEach((benchmark) => {
68
- const options = getBenchOptions(benchmark);
69
- const benchmarkInstance = new Bench(options);
70
- const benchmarkFn = getBenchFn(benchmark);
71
- benchmark.result = {
72
- state: "run",
73
- startTime: start,
74
- benchmark: createBenchmarkResult(benchmark.name)
75
- };
76
- const task = new Task(benchmarkInstance, benchmark.name, benchmarkFn);
77
- benchmarkTasks.set(benchmark, task);
78
- addBenchTaskListener(task, benchmark);
79
- });
80
- const { setTimeout } = getSafeTimers();
81
- const tasks = [];
82
- for (const benchmark of benchmarkGroup) {
83
- const task = benchmarkTasks.get(benchmark);
84
- updateTask$1("test-prepare", benchmark);
85
- await task.warmup();
86
- tasks.push([await new Promise((resolve) => setTimeout(async () => {
87
- resolve(await task.run());
88
- })), benchmark]);
89
- }
90
- suite.result.duration = performance.now() - start;
91
- suite.result.state = "pass";
92
- updateTask$1("suite-finished", suite);
93
- defer.resolve(null);
94
- await defer;
95
- }
96
- function updateTask$1(event, task) {
97
- updateTask(event, task, runner);
98
- }
99
- }
100
- class NodeBenchmarkRunner {
101
- __vitest_executor;
102
- constructor(config) {
103
- this.config = config;
104
- }
105
- async importTinybench() {
106
- return await import('tinybench');
107
- }
108
- importFile(filepath, source) {
109
- if (source === "setup") getWorkerState().moduleCache.delete(filepath);
110
- return this.__vitest_executor.executeId(filepath);
111
- }
112
- async runSuite(suite) {
113
- await runBenchmarkSuite(suite, this);
114
- }
115
- async runTask() {
116
- throw new Error("`test()` and `it()` is only available in test mode.");
117
- }
118
- }
119
-
120
- // import type { VitestExecutor } from '../execute'
121
- // worker context is shared between all tests
122
- const workerContext = Object.create(null);
123
- class VitestTestRunner {
124
- snapshotClient = getSnapshotClient();
125
- workerState = getWorkerState();
126
- __vitest_executor;
127
- cancelRun = false;
128
- assertionsErrors = /* @__PURE__ */ new WeakMap();
129
- pool = this.workerState.ctx.pool;
130
- constructor(config) {
131
- this.config = config;
132
- }
133
- importFile(filepath, source) {
134
- if (source === "setup") this.workerState.moduleCache.delete(filepath);
135
- return this.__vitest_executor.executeId(filepath);
136
- }
137
- onCollectStart(file) {
138
- this.workerState.current = file;
139
- }
140
- onCleanupWorkerContext(listener) {
141
- this.workerState.onCleanup(listener);
142
- }
143
- onAfterRunFiles() {
144
- this.snapshotClient.clear();
145
- this.workerState.current = void 0;
146
- }
147
- getWorkerContext() {
148
- return workerContext;
149
- }
150
- async onAfterRunSuite(suite) {
151
- if (this.config.logHeapUsage && typeof process !== "undefined") suite.result.heap = process.memoryUsage().heapUsed;
152
- if (suite.mode !== "skip" && "filepath" in suite) {
153
- // mark snapshots in skipped tests as not obsolete
154
- for (const test of getTests(suite)) if (test.mode === "skip") {
155
- const name = getNames(test).slice(1).join(" > ");
156
- this.snapshotClient.skipTest(suite.file.filepath, name);
157
- }
158
- const result = await this.snapshotClient.finish(suite.file.filepath);
159
- await rpc().snapshotSaved(result);
160
- }
161
- this.workerState.current = suite.suite || suite.file;
162
- }
163
- onAfterRunTask(test) {
164
- if (this.config.logHeapUsage && typeof process !== "undefined") test.result.heap = process.memoryUsage().heapUsed;
165
- this.workerState.current = test.suite || test.file;
166
- }
167
- cancel(_reason) {
168
- this.cancelRun = true;
169
- }
170
- injectValue(key) {
171
- // inject has a very limiting type controlled by ProvidedContext
172
- // some tests override it which causes the build to fail
173
- return inject(key);
174
- }
175
- async onBeforeRunTask(test) {
176
- if (this.cancelRun) test.mode = "skip";
177
- if (test.mode !== "run" && test.mode !== "queued") return;
178
- this.workerState.current = test;
179
- }
180
- async onBeforeRunSuite(suite) {
181
- if (this.cancelRun) suite.mode = "skip";
182
- // initialize snapshot state before running file suite
183
- if (suite.mode !== "skip" && "filepath" in suite) await this.snapshotClient.setup(suite.file.filepath, this.workerState.config.snapshotOptions);
184
- this.workerState.current = suite;
185
- }
186
- onBeforeTryTask(test) {
187
- clearModuleMocks(this.config);
188
- this.snapshotClient.clearTest(test.file.filepath, test.id);
189
- setState({
190
- assertionCalls: 0,
191
- isExpectingAssertions: false,
192
- isExpectingAssertionsError: null,
193
- expectedAssertionsNumber: null,
194
- expectedAssertionsNumberErrorGen: null,
195
- currentTestName: getTestName(test),
196
- snapshotState: this.snapshotClient.getSnapshotState(test.file.filepath)
197
- }, globalThis[GLOBAL_EXPECT]);
198
- }
199
- onAfterTryTask(test) {
200
- const { assertionCalls, expectedAssertionsNumber, expectedAssertionsNumberErrorGen, isExpectingAssertions, isExpectingAssertionsError } = test.context._local ? test.context.expect.getState() : getState(globalThis[GLOBAL_EXPECT]);
201
- if (expectedAssertionsNumber !== null && assertionCalls !== expectedAssertionsNumber) throw expectedAssertionsNumberErrorGen();
202
- if (isExpectingAssertions === true && assertionCalls === 0) throw isExpectingAssertionsError;
203
- if (this.config.expect.requireAssertions && assertionCalls === 0) throw this.assertionsErrors.get(test);
204
- }
205
- extendTaskContext(context) {
206
- // create error during the test initialization so we have a nice stack trace
207
- if (this.config.expect.requireAssertions) this.assertionsErrors.set(context.task, new Error("expected any number of assertion, but got none"));
208
- let _expect;
209
- Object.defineProperty(context, "expect", { get() {
210
- if (!_expect) _expect = createExpect(context.task);
211
- return _expect;
212
- } });
213
- Object.defineProperty(context, "_local", { get() {
214
- return _expect != null;
215
- } });
216
- return context;
217
- }
218
- getImportDurations() {
219
- const entries = [...this.workerState.moduleExecutionInfo?.entries() ?? []];
220
- return Object.fromEntries(entries.map(([filepath, { duration, selfTime }]) => [normalize(filepath), {
221
- selfTime,
222
- totalTime: duration
223
- }]));
224
- }
225
- }
226
- function clearModuleMocks(config) {
227
- const { clearMocks, mockReset, restoreMocks, unstubEnvs, unstubGlobals } = config;
228
- // since each function calls another, we can just call one
229
- if (restoreMocks) vi.restoreAllMocks();
230
- else if (mockReset) vi.resetAllMocks();
231
- else if (clearMocks) vi.clearAllMocks();
232
- if (unstubEnvs) vi.unstubAllEnvs();
233
- if (unstubGlobals) vi.unstubAllGlobals();
234
- }
235
-
236
- export { NodeBenchmarkRunner, VitestTestRunner };
15
+ import './chunks/date.-jtEtIeV.js';
16
+ import './chunks/rpc.BKr6mtxz.js';
17
+ import './chunks/index.Bgo3tNWt.js';
package/dist/snapshot.js CHANGED
@@ -1,4 +1,4 @@
1
- export { VitestNodeSnapshotEnvironment as VitestSnapshotEnvironment } from './chunks/node.fjCdwEIl.js';
1
+ export { VitestNodeSnapshotEnvironment as VitestSnapshotEnvironment } from './chunks/node.CyipiPvJ.js';
2
2
  import '@vitest/snapshot/environment';
3
- import './chunks/utils.XdZDrNZV.js';
3
+ import './chunks/utils.D2R2NiOH.js';
4
4
  import '@vitest/utils';
package/dist/suite.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export { g as getBenchFn, a as getBenchOptions } from './chunks/suite.d.FvehnV49.js';
1
+ export { g as getBenchFn, a as getBenchOptions } from './chunks/suite.d.BJWk38HB.js';
2
2
  export { VitestRunner, VitestRunnerConfig, createTaskCollector, getCurrentSuite, getCurrentTest, getFn, getHooks, setFn, setHooks } from '@vitest/runner';
3
3
  export { createChainable } from '@vitest/runner/utils';
4
- import './chunks/benchmark.d.BwvBVTda.js';
4
+ import './chunks/benchmark.d.DAaHLpsq.js';
5
5
  import 'tinybench';
package/dist/suite.js CHANGED
@@ -1,5 +1,5 @@
1
- export { g as getBenchFn, a as getBenchOptions } from './chunks/benchmark.CYdenmiT.js';
1
+ export { g as getBenchFn, a as getBenchOptions } from './chunks/benchmark.CJUa-Hsa.js';
2
2
  export { createTaskCollector, getCurrentSuite, getCurrentTest, getFn, getHooks, setFn, setHooks } from '@vitest/runner';
3
3
  export { createChainable } from '@vitest/runner/utils';
4
4
  import '@vitest/utils';
5
- import './chunks/utils.XdZDrNZV.js';
5
+ import './chunks/utils.D2R2NiOH.js';