vitest 4.0.17 → 4.1.0-beta.2

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 (74) hide show
  1. package/LICENSE.md +36 -0
  2. package/dist/browser.d.ts +1 -1
  3. package/dist/browser.js +2 -2
  4. package/dist/chunks/acorn.B2iPLyUM.js +5958 -0
  5. package/dist/chunks/{base.XJJQZiKB.js → base.DiopZV8F.js} +49 -14
  6. package/dist/chunks/{benchmark.B3N2zMcH.js → benchmark.BoqSLF53.js} +1 -1
  7. package/dist/chunks/{browser.d.ChKACdzH.d.ts → browser.d.BE4kbYok.d.ts} +4 -1
  8. package/dist/chunks/{cac.jRCLJDDc.js → cac.C4jjt2RX.js} +816 -14
  9. package/dist/chunks/{cli-api.Cx2DW4Bc.js → cli-api.ChbI1JU9.js} +412 -166
  10. package/dist/chunks/{config.d.Cy95HiCx.d.ts → config.d.Cr1Ep39N.d.ts} +13 -11
  11. package/dist/chunks/{console.Cf-YriPC.js → console.CNlG1KsP.js} +3 -2
  12. package/dist/chunks/{constants.D_Q9UYh-.js → constants.B63TT-Bl.js} +1 -1
  13. package/dist/chunks/coverage.tyqbzn4W.js +1001 -0
  14. package/dist/chunks/{creator.DAmOKTvJ.js → creator.yyCHuw5R.js} +33 -2
  15. package/dist/chunks/{global.d.B15mdLcR.d.ts → global.d.JeWMqlOm.d.ts} +1 -1
  16. package/dist/chunks/{globals.DOayXfHP.js → globals.C6Ecf1TO.js} +11 -10
  17. package/dist/chunks/{index.M8mOzt4Y.js → index.B-iBE_Gx.js} +21 -5
  18. package/dist/chunks/{coverage.AVPTjMgw.js → index.BCY_7LL2.js} +5 -959
  19. package/dist/chunks/{index.6Qv1eEA6.js → index.CAN630q3.js} +20 -8
  20. package/dist/chunks/{index.C5r1PdPD.js → index.CFulQRmC.js} +1 -1
  21. package/dist/chunks/{index.Z5E_ObnR.js → index.CouFDptX.js} +4 -2
  22. package/dist/chunks/{init-forks.BC6ZwHQN.js → init-forks.BnCXPazU.js} +1 -1
  23. package/dist/chunks/{init-threads.CxSxLC0N.js → init-threads.Cyh2PqXi.js} +1 -1
  24. package/dist/chunks/{init.C9kljSTm.js → init.B95Mm0Iz.js} +65 -12
  25. package/dist/chunks/native.mV0-490A.js +148 -0
  26. package/dist/chunks/nativeModuleMocker.D_q5sFv6.js +206 -0
  27. package/dist/chunks/nativeModuleRunner.BIakptoF.js +36 -0
  28. package/dist/chunks/{node.Ce0vMQM7.js → node.CrSEwhm4.js} +1 -1
  29. package/dist/chunks/{plugin.d.CtqpEehP.d.ts → plugin.d.C9o5bttz.d.ts} +1 -1
  30. package/dist/chunks/{reporters.d.CWXNI2jG.d.ts → reporters.d.7faYdkxy.d.ts} +146 -49
  31. package/dist/chunks/rpc.DcRWTy5G.js +148 -0
  32. package/dist/chunks/{rpc.d.RH3apGEf.d.ts → rpc.d.CM7x9-sm.d.ts} +1 -0
  33. package/dist/chunks/{setup-common.Cm-kSBVi.js → setup-common.cvFp-ao9.js} +2 -2
  34. package/dist/chunks/{startModuleRunner.DEj0jb3e.js → startVitestModuleRunner.BK-u7y4N.js} +182 -391
  35. package/dist/chunks/{vi.2VT5v0um.js → test.G82XYNFk.js} +505 -119
  36. package/dist/chunks/{utils.DvEY5TfP.js → utils.DT4VyRyl.js} +5 -1
  37. package/dist/chunks/{vm.CMjifoPa.js → vm.BdLtzhnj.js} +15 -11
  38. package/dist/chunks/{worker.d.Dyxm8DEL.d.ts → worker.d.CPzI2ZzJ.d.ts} +2 -2
  39. package/dist/cli.js +4 -3
  40. package/dist/config.d.ts +11 -11
  41. package/dist/config.js +1 -1
  42. package/dist/coverage.d.ts +10 -8
  43. package/dist/coverage.js +7 -4
  44. package/dist/environments.js +2 -0
  45. package/dist/index.d.ts +30 -23
  46. package/dist/index.js +9 -8
  47. package/dist/module-evaluator.d.ts +10 -1
  48. package/dist/module-evaluator.js +1 -5
  49. package/dist/node.d.ts +13 -12
  50. package/dist/node.js +27 -25
  51. package/dist/nodejs-worker-loader.js +41 -0
  52. package/dist/reporters.d.ts +8 -8
  53. package/dist/reporters.js +4 -2
  54. package/dist/runners.d.ts +24 -4
  55. package/dist/runners.js +6 -6
  56. package/dist/runtime.d.ts +6 -0
  57. package/dist/runtime.js +35 -0
  58. package/dist/snapshot.js +4 -2
  59. package/dist/suite.js +4 -2
  60. package/dist/worker.d.ts +8 -7
  61. package/dist/worker.js +25 -20
  62. package/dist/workers/forks.js +21 -16
  63. package/dist/workers/runVmTests.js +11 -13
  64. package/dist/workers/threads.js +21 -16
  65. package/dist/workers/vmForks.js +14 -11
  66. package/dist/workers/vmThreads.js +14 -11
  67. package/package.json +28 -29
  68. package/suppress-warnings.cjs +1 -0
  69. package/dist/chunks/date.Bq6ZW5rf.js +0 -73
  70. package/dist/chunks/rpc.BoxB0q7B.js +0 -76
  71. package/dist/chunks/test.B8ej_ZHS.js +0 -254
  72. package/dist/mocker.d.ts +0 -1
  73. package/dist/mocker.js +0 -1
  74. package/dist/module-runner.js +0 -17
@@ -1,21 +1,21 @@
1
- import { TaskMeta, Suite, File, TestAnnotation, TestArtifact, ImportDuration, Test, Task, TaskResultPack, FileSpecification, CancelReason, SequenceSetupFiles, SequenceHooks } from '@vitest/runner';
1
+ import { TaskMeta, Suite, File, SerializableRetry, TestAnnotation, TestArtifact, ImportDuration, Test, Task, TaskResultPack, FileSpecification, CancelReason, SequenceSetupFiles, SequenceHooks, TestTagDefinition } from '@vitest/runner';
2
2
  import { TestError, SerializedError, Arrayable, ParsedStack, Awaitable } from '@vitest/utils';
3
- import { A as AfterSuiteRunMeta, U as UserConsoleLog, P as ProvidedContext, L as LabelColor } from './rpc.d.RH3apGEf.js';
3
+ import { A as AfterSuiteRunMeta, U as UserConsoleLog, P as ProvidedContext, L as LabelColor } from './rpc.d.CM7x9-sm.js';
4
4
  import { Writable } from 'node:stream';
5
5
  import { DevEnvironment, TransformResult as TransformResult$1, ViteDevServer, Plugin, UserConfig as UserConfig$1, DepOptimizationConfig, ServerOptions, ConfigEnv, AliasOptions } from 'vite';
6
- import { S as SerializedTestSpecification, c as SourceModuleDiagnostic, B as BrowserTesterOptions } from './browser.d.ChKACdzH.js';
7
- import { MockedModule } from '@vitest/mocker';
8
- import { StackTraceParserOptions } from '@vitest/utils/source-map';
9
- import { BrowserCommands } from 'vitest/browser';
10
- import { B as BrowserTraceViewMode, S as SerializedConfig, F as FakeTimerInstallOpts } from './config.d.Cy95HiCx.js';
6
+ import { S as SerializedTestSpecification, c as SourceModuleDiagnostic, B as BrowserTesterOptions } from './browser.d.BE4kbYok.js';
7
+ import { B as BrowserTraceViewMode, S as SerializedConfig, F as FakeTimerInstallOpts } from './config.d.Cr1Ep39N.js';
11
8
  import { PrettyFormatOptions } from '@vitest/pretty-format';
12
9
  import { SnapshotSummary, SnapshotStateOptions } from '@vitest/snapshot';
13
10
  import { SerializedDiffOptions } from '@vitest/utils/diff';
14
11
  import { chai } from '@vitest/expect';
15
12
  import { happyDomTypes, jsdomTypes } from 'vitest/optional-types.js';
16
- import { c as ContextTestEnvironment, d as WorkerExecuteContext, e as WorkerTestEnvironment } from './worker.d.Dyxm8DEL.js';
13
+ import { c as ContextTestEnvironment, d as WorkerExecuteContext, e as WorkerTestEnvironment } from './worker.d.CPzI2ZzJ.js';
17
14
  import { O as OTELCarrier } from './traces.d.402V_yFI.js';
18
15
  import { B as BenchmarkResult } from './benchmark.d.DAaHLpsq.js';
16
+ import { MockedModule } from '@vitest/mocker';
17
+ import { StackTraceParserOptions } from '@vitest/utils/source-map';
18
+ import { BrowserCommands } from 'vitest/browser';
19
19
  import { a as RuntimeCoverageProviderModule } from './coverage.d.BZtK59WP.js';
20
20
  import { SnapshotManager } from '@vitest/snapshot/manager';
21
21
  import { Console } from 'node:console';
@@ -72,6 +72,53 @@ interface ConstructorOptionsOverride {
72
72
  resources?: "usable";
73
73
  }
74
74
 
75
+ interface TestSpecificationOptions {
76
+ testNamePattern?: RegExp;
77
+ testIds?: string[];
78
+ testLines?: number[];
79
+ testTagsFilter?: string[];
80
+ }
81
+ declare class TestSpecification {
82
+ /**
83
+ * The task id associated with the test module.
84
+ */
85
+ readonly taskId: string;
86
+ /**
87
+ * The test project that the module belongs to.
88
+ */
89
+ readonly project: TestProject;
90
+ /**
91
+ * The id of the module in the Vite module graph. It is usually an absolute file path.
92
+ */
93
+ readonly moduleId: string;
94
+ /**
95
+ * The current test pool. It's possible to have multiple pools in a single test project with `typecheck.enabled`.
96
+ * @experimental In later versions, the project will only support a single pool.
97
+ */
98
+ readonly pool: Pool;
99
+ /**
100
+ * Line numbers of the test locations to run.
101
+ */
102
+ readonly testLines: number[] | undefined;
103
+ /**
104
+ * Regular expression pattern to filter test names.
105
+ */
106
+ readonly testNamePattern: RegExp | undefined;
107
+ /**
108
+ * The ids of tasks inside of this specification to run.
109
+ */
110
+ readonly testIds: string[] | undefined;
111
+ /**
112
+ * The tags of tests to run.
113
+ */
114
+ readonly testTagsFilter: string[] | undefined;
115
+ /**
116
+ * Test module associated with the specification. This will be `undefined` if tests have not been run yet.
117
+ */
118
+ get testModule(): TestModule | undefined;
119
+ toJSON(): SerializedTestSpecification;
120
+ }
121
+
75
122
  declare class ReportedTaskImplementation {
76
123
  /**
77
124
  * The project associated with the test or suite.
@@ -120,6 +167,10 @@ declare class TestCase extends ReportedTaskImplementation {
120
167
  */
121
168
  readonly parent: TestSuite | TestModule;
122
169
  /**
170
+ * Tags associated with the test.
171
+ */
172
+ readonly tags: string[];
173
+ /**
123
174
  * Full name of the test including all parent suites separated with `>`.
124
175
  */
125
176
  get fullName(): string;
@@ -146,6 +197,10 @@ declare class TestCase extends ReportedTaskImplementation {
146
197
  * Diagnostic is only available after the test has finished.
147
198
  */
148
199
  diagnostic(): TestDiagnostic | undefined;
200
+ /**
201
+ * Returns a new test specification that can be used to filter or run this specific test case.
202
+ */
203
+ toTestSpecification(): TestSpecification;
149
204
  }
150
205
  declare class TestCollection {
151
206
  #private;
@@ -231,6 +286,10 @@ declare class TestSuite extends SuiteImplementation {
231
286
  */
232
287
  state(): TestSuiteState;
233
288
  /**
289
+ * Returns a new test specification that can be used to filter or run this specific test suite.
290
+ */
291
+ toTestSpecification(): TestSpecification;
292
+ /**
234
293
  * Full name of the suite including all parent suites separated with `>`.
235
294
  */
236
295
  get fullName(): string;
@@ -255,6 +314,10 @@ declare class TestModule extends SuiteImplementation {
255
314
  */
256
315
  readonly relativeModuleId: string;
257
316
  /**
317
+ * Returns a new test specification that can be used to filter or run this specific test module.
318
+ */
319
+ toTestSpecification(): TestSpecification;
320
+ /**
258
321
  * Checks the running state of the test file.
259
322
  */
260
323
  state(): TestModuleState;
@@ -278,8 +341,13 @@ interface TaskOptions {
278
341
  readonly fails: boolean | undefined;
279
342
  readonly concurrent: boolean | undefined;
280
343
  readonly shuffle: boolean | undefined;
281
- readonly retry: number | undefined;
344
+ readonly retry: SerializableRetry | undefined;
282
345
  readonly repeats: number | undefined;
346
+ readonly tags: string[] | undefined;
347
+ /**
348
+ * Only tests have a `timeout` option.
349
+ */
350
+ readonly timeout: number | undefined;
283
351
  readonly mode: "run" | "only" | "skip" | "todo";
284
352
  }
285
353
  type TestSuiteState = "skipped" | "pending" | "failed" | "passed";
@@ -402,36 +470,6 @@ declare function experimental_getRunnerTask(entity: TestSuite): Suite;
402
470
  declare function experimental_getRunnerTask(entity: TestModule): File;
403
471
  declare function experimental_getRunnerTask(entity: TestCase | TestSuite | TestModule): Suite | File | Test;
404
472
 
405
- declare class TestSpecification {
406
- /**
407
- * The task ID associated with the test module.
408
- */
409
- readonly taskId: string;
410
- /**
411
- * The test project that the module belongs to.
412
- */
413
- readonly project: TestProject;
414
- /**
415
- * The ID of the module in the Vite module graph. It is usually an absolute file path.
416
- */
417
- readonly moduleId: string;
418
- /**
419
- * The current test pool. It's possible to have multiple pools in a single test project with `poolMatchGlob` and `typecheck.enabled`.
420
- * @experimental In Vitest 4, the project will only support a single pool and this property will be removed.
421
- */
422
- readonly pool: Pool;
423
- /**
424
- * Line numbers of the test locations to run.
425
- */
426
- readonly testLines: number[] | undefined;
427
- constructor(project: TestProject, moduleId: string, pool: Pool, testLines?: number[] | undefined);
428
- /**
429
- * Test module associated with the specification.
430
- */
431
- get testModule(): TestModule | undefined;
432
- toJSON(): SerializedTestSpecification;
433
- }
434
-
435
473
  interface CoverageSummaryData {
436
474
  lines: Totals;
437
475
  statements: Totals;
@@ -865,6 +903,8 @@ declare class Logger {
865
903
  deprecate(message: string): void;
866
904
  clearHighlightCache(filename?: string): void;
867
905
  highlight(filename: string, source: string): string;
906
+ printNoTestTagsFound(): void;
907
+ printTags(): void;
868
908
  printNoTestFound(filters?: string[]): void;
869
909
  printBanner(): void;
870
910
  printBrowserBanner(project: TestProject): void;
@@ -1081,6 +1121,7 @@ declare class VitestWatcher {
1081
1121
  readonly changedTests: Set<string>;
1082
1122
  private readonly _onRerun;
1083
1123
  constructor(vitest: Vitest);
1124
+ close(): void;
1084
1125
  unregisterWatcher: () => void;
1085
1126
  registerWatcher(): this;
1086
1127
  private scheduleRerun;
@@ -1149,7 +1190,6 @@ declare class Vitest {
1149
1190
  private restartsCount;
1150
1191
  private readonly specifications;
1151
1192
  private pool;
1152
- private _config?;
1153
1193
  private _vite?;
1154
1194
  private _state?;
1155
1195
  private _cache?;
@@ -1183,6 +1223,7 @@ declare class Vitest {
1183
1223
  * Test results and test file stats cache. Primarily used by the sequencer to sort tests.
1184
1224
  */
1185
1225
  get cache(): VitestCache;
1226
+ listTags(): Promise<void>;
1186
1227
  enableCoverage(): Promise<void>;
1187
1228
  disableCoverage(): void;
1188
1229
  private clearAllCachePaths;
@@ -1278,6 +1319,12 @@ declare class Vitest {
1278
1319
  */
1279
1320
  runTestSpecifications(specifications: TestSpecification[], allTestsRun?: boolean): Promise<TestRunResult>;
1280
1321
  /**
1322
+ * Runs tests for the given file paths. This does not trigger `onWatcher*` events.
1323
+ * @param filepaths A list of file paths to run tests for.
1324
+ * @param allTestsRun Indicates whether all tests were run. This only matters for coverage.
1325
+ */
1326
+ runTestFiles(filepaths: string[], allTestsRun?: boolean): Promise<TestRunResult>;
1327
+ /**
1281
1328
  * Rerun files and trigger `onWatcherRerun`, `onWatcherStart` and `onTestsRerun` events.
1282
1329
  * @param specifications A list of specifications to run.
1283
1330
  * @param allTestsRun Indicates whether all tests were run. This only matters for coverage.
@@ -1428,7 +1475,9 @@ interface BrowserProvider {
1428
1475
  */
1429
1476
  supportsParallelism: boolean;
1430
1477
  getCommandsContext: (sessionId: string) => Record<string, unknown>;
1431
- openPage: (sessionId: string, url: string) => Promise<void>;
1478
+ openPage: (sessionId: string, url: string, options: {
1479
+ parallel: boolean;
1480
+ }) => Promise<void>;
1432
1481
  getCDPSession?: (sessionId: string) => Promise<CDPSession>;
1433
1482
  close: () => Awaitable<void>;
1434
1483
  }
@@ -1825,7 +1874,7 @@ declare class TestProject {
1825
1874
  * Creates a new test specification. Specifications describe how to run tests.
1826
1875
  * @param moduleId The file path
1827
1876
  */
1828
- createSpecification(moduleId: string, locations?: number[] | undefined, pool?: string): TestSpecification;
1877
+ createSpecification(moduleId: string, locationsOrOptions?: number[] | TestSpecificationOptions | undefined, pool?: string): TestSpecification;
1829
1878
  toJSON(): SerializedTestProject;
1830
1879
  /**
1831
1880
  * Vite's dev server instance. Every workspace project has its own server.
@@ -2100,6 +2149,7 @@ interface JsonAssertionResult {
2100
2149
  duration?: Milliseconds | null;
2101
2150
  failureMessages: Array<string> | null;
2102
2151
  location?: Callsite | null;
2152
+ tags: string[];
2103
2153
  }
2104
2154
  interface JsonTestResult {
2105
2155
  message: string;
@@ -2166,6 +2216,10 @@ interface JUnitOptions {
2166
2216
  * @default false
2167
2217
  */
2168
2218
  addFileAttribute?: boolean;
2219
+ /**
2220
+ * Hostname to use in the report. By default, it uses os.hostname()
2221
+ */
2222
+ hostname?: string;
2169
2223
  }
2170
2224
  declare class JUnitReporter implements Reporter {
2171
2225
  private ctx;
@@ -2976,11 +3030,17 @@ interface InlineConfig {
2976
3030
  */
2977
3031
  bail?: number;
2978
3032
  /**
2979
- * Retry the test specific number of times if it fails.
3033
+ * Retry configuration for tests.
3034
+ * - If a number, specifies how many times to retry failed tests
3035
+ * - If an object, allows fine-grained retry control
2980
3036
  *
2981
- * @default 0
3037
+ * ⚠️ WARNING: Function form is NOT supported in a config file
3038
+ * because configurations are serialized when passed to worker threads.
3039
+ * Use the function form only in test files directly.
3040
+ *
3041
+ * @default 0 // Don't retry
2982
3042
  */
2983
- retry?: number;
3043
+ retry?: SerializableRetry;
2984
3044
  /**
2985
3045
  * Show full diff when snapshot fails instead of a patch.
2986
3046
  */
@@ -3042,7 +3102,34 @@ interface InlineConfig {
3042
3102
  * Enabling this will also show a breakdown by default in UI, but you can always press a button to toggle it.
3043
3103
  */
3044
3104
  printImportBreakdown?: boolean;
3105
+ /**
3106
+ * Controls whether Vitest uses Vite's module runner to run the code or fallback to the native `import`.
3107
+ *
3108
+ * If Node.js cannot process the code, consider registering [module loader](https://nodejs.org/api/module.html#customization-hooks) via `execArgv`.
3109
+ * @default true
3110
+ */
3111
+ viteModuleRunner?: boolean;
3112
+ /**
3113
+ * If module runner is disabled, Vitest uses a module loader to transform files to support
3114
+ * `import.meta.vitest` and `vi.mock`.
3115
+ *
3116
+ * If you don't use these features, you can disable this.
3117
+ *
3118
+ * This option only affects `loader.load` method, Vitest always defines a `loader.resolve` to populate the module graph.
3119
+ */
3120
+ nodeLoader?: boolean;
3045
3121
  };
3122
+ /**
3123
+ * Define tags available in your test files.
3124
+ *
3125
+ * If test defines a tag that is not listed here, an error will be thrown.
3126
+ */
3127
+ tags?: TestTagDefinition[];
3128
+ /**
3129
+ * Should Vitest throw an error if test has a tag that is not defined in the config.
3130
+ * @default true
3131
+ */
3132
+ strictTags?: boolean;
3046
3133
  }
3047
3134
  interface TypecheckConfig {
3048
3135
  /**
@@ -3163,11 +3250,20 @@ interface UserConfig extends InlineConfig {
3163
3250
  * @experimental
3164
3251
  */
3165
3252
  clearCache?: boolean;
3253
+ /**
3254
+ * Tags expression to filter tests to run. Multiple filters will be applied using AND logic.
3255
+ * @see {@link https://vitest.dev/guide/test-tags#syntax}
3256
+ */
3257
+ tagsFilter?: string[];
3258
+ /**
3259
+ * Log all available tags instead of running tests.
3260
+ */
3261
+ listTags?: boolean | "json";
3166
3262
  }
3167
3263
  type OnUnhandledErrorCallback = (error: (TestError | Error) & {
3168
3264
  type: string;
3169
3265
  }) => boolean | void;
3170
- interface ResolvedConfig extends Omit<Required<UserConfig>, "project" | "config" | "filters" | "browser" | "coverage" | "testNamePattern" | "related" | "api" | "reporters" | "resolveSnapshotPath" | "benchmark" | "shard" | "cache" | "sequence" | "typecheck" | "runner" | "pool" | "cliExclude" | "diff" | "setupFiles" | "snapshotEnvironment" | "bail" | "name" | "vmMemoryLimit" | "fileParallelism"> {
3266
+ interface ResolvedConfig extends Omit<Required<UserConfig>, "project" | "config" | "filters" | "browser" | "coverage" | "testNamePattern" | "related" | "api" | "reporters" | "resolveSnapshotPath" | "benchmark" | "shard" | "cache" | "sequence" | "typecheck" | "runner" | "pool" | "cliExclude" | "diff" | "setupFiles" | "snapshotEnvironment" | "bail" | "name" | "vmMemoryLimit" | "fileParallelism" | "tagsFilter"> {
3171
3267
  mode: VitestRunMode;
3172
3268
  name: ProjectName["label"];
3173
3269
  color?: ProjectName["color"];
@@ -3220,8 +3316,9 @@ interface ResolvedConfig extends Omit<Required<UserConfig>, "project" | "config"
3220
3316
  maxWorkers: number;
3221
3317
  vmMemoryLimit?: UserConfig["vmMemoryLimit"];
3222
3318
  dumpDir?: string;
3319
+ tagsFilter?: string[];
3223
3320
  }
3224
- type NonProjectOptions = "shard" | "watch" | "run" | "cache" | "update" | "reporters" | "outputFile" | "teardownTimeout" | "silent" | "forceRerunTriggers" | "testNamePattern" | "ui" | "open" | "uiBase" | "snapshotFormat" | "resolveSnapshotPath" | "passWithNoTests" | "onConsoleLog" | "onStackTrace" | "dangerouslyIgnoreUnhandledErrors" | "slowTestThreshold" | "inspect" | "inspectBrk" | "coverage" | "watchTriggerPatterns";
3321
+ type NonProjectOptions = "shard" | "watch" | "run" | "cache" | "update" | "reporters" | "outputFile" | "teardownTimeout" | "silent" | "forceRerunTriggers" | "testNamePattern" | "ui" | "open" | "uiBase" | "snapshotFormat" | "resolveSnapshotPath" | "passWithNoTests" | "onConsoleLog" | "onStackTrace" | "dangerouslyIgnoreUnhandledErrors" | "slowTestThreshold" | "inspect" | "inspectBrk" | "coverage" | "watchTriggerPatterns" | "tagsFilter";
3225
3322
  interface ServerDepsOptions {
3226
3323
  /**
3227
3324
  * Externalize means that Vite will bpass the package to native Node.
@@ -3267,5 +3364,5 @@ type TestProjectInlineConfiguration = (UserWorkspaceConfig & {
3267
3364
  });
3268
3365
  type TestProjectConfiguration = string | TestProjectInlineConfiguration | Promise<UserWorkspaceConfig> | UserProjectConfigFn;
3269
3366
 
3270
- export { CoverageMap as C, TestSuite as K, Logger as L, experimental_getRunnerTask as Q, TestProject as T, Vitest as V, BenchmarkReporter as aE, BenchmarkReportsMap as aF, DefaultReporter as aG, DotReporter as aH, GithubActionsReporter as aI, HangingProcessReporter as aJ, JsonReporter as aK, JUnitReporter as aL, ReportersMap as aM, TapFlatReporter as aN, TapReporter as aO, VerboseBenchmarkReporter as aP, VerboseReporter as aQ, BaseReporter as aR, TestSpecification as k, VitestPackageInstaller as p, TestCase as v, TestCollection as w, TestModule as y };
3271
- export type { BrowserCommand as $, ApiConfig as A, TestResult as B, TestResultFailed as D, TestResultPassed as E, TestResultSkipped as F, TestState as G, HTMLOptions as H, InlineConfig as I, JsonOptions as J, ModuleDiagnostic as M, TestSuiteState as N, OnServerRestartHandler as O, PoolWorker as P, ResolvedCoverageOptions as R, SerializedTestProject as S, UserWorkspaceConfig as U, WatcherTriggerPattern as W, TestSequencerConstructor as X, BenchmarkUserOptions as Y, BrowserBuiltinProvider as Z, _BrowserNames as _, ReportContext as a, BrowserCommandContext as a0, BrowserConfigOptions as a1, BrowserInstanceOption as a2, BrowserModuleMocker as a3, BrowserOrchestrator as a4, BrowserProvider as a5, BrowserProviderOption as a6, BrowserScript as a7, BrowserServerFactory as a8, BrowserServerOptions as a9, TestRunResult as aA, ReportedHookContext as aB, Reporter as aC, TestRunEndReason as aD, BenchmarkBuiltinReporters as aS, BuiltinReporterOptions as aT, BuiltinReporters as aU, JsonAssertionResult as aV, JsonTestResult as aW, JsonTestResults as aX, BrowserServerState as aa, BrowserServerStateSession as ab, CDPSession as ac, ParentProjectBrowser as ad, ProjectBrowser as ae, ResolvedBrowserOptions as af, ToMatchScreenshotComparators as ag, ToMatchScreenshotOptions as ah, BuiltinEnvironment as ai, CSSModuleScopeStrategy as aj, DepsOptimizationOptions as ak, EnvironmentOptions as al, Pool as am, ProjectConfig as an, ResolvedProjectConfig as ao, ResolveSnapshotPathHandler as ap, ResolveSnapshotPathHandlerContext as aq, TypecheckConfig as ar, VitestEnvironment as as, BaseCoverageOptions as at, CoverageIstanbulOptions as au, CoverageOptions as av, CoverageProvider as aw, CoverageProviderModule as ax, CoverageReporter as ay, CustomProviderOptions as az, TestProjectConfiguration as b, CoverageV8Options as c, UserProjectConfigFn as d, UserProjectConfigExport as e, UserConfig as f, TestProjectInlineConfiguration as g, ResolvedConfig as h, VitestRunMode as i, VitestOptions as j, PoolOptions as l, WorkerRequest as m, TestSequencer as n, OnTestsRerunHandler as o, PoolRunnerInitializer as q, PoolTask as r, WorkerResponse as s, JUnitOptions as t, TaskOptions as u, TestDiagnostic as x, TestModuleState as z };
3367
+ export { BenchmarkReporter as B, DefaultReporter as D, GithubActionsReporter as G, HangingProcessReporter as H, JsonReporter as J, Logger as L, TestProject as T, Vitest as V, TestCase as a3, TestCollection as a4, TestModule as a6, CoverageMap as aY, TestSuite as ad, experimental_getRunnerTask as af, TestSpecification as i, VitestPackageInstaller as n, BenchmarkReportsMap as r, DotReporter as s, JUnitReporter as t, ReportersMap as u, TapFlatReporter as v, TapReporter as w, VerboseBenchmarkReporter as x, VerboseReporter as y, BaseReporter as z };
3368
+ export type { JsonOptions as $, ApiConfig as A, CoverageV8Options as C, BenchmarkBuiltinReporters as E, BuiltinReporterOptions as F, InlineConfig as I, BuiltinReporters as K, JsonAssertionResult as M, JsonTestResult as N, OnServerRestartHandler as O, PoolWorker as P, JsonTestResults as Q, ResolvedCoverageOptions as R, SerializedTestProject as S, UserWorkspaceConfig as U, WatcherTriggerPattern as W, ReportedHookContext as X, Reporter as Y, TestRunEndReason as Z, HTMLOptions as _, TestProjectConfiguration as a, JUnitOptions as a0, ModuleDiagnostic as a1, TaskOptions as a2, TestDiagnostic as a5, TestModuleState as a7, TestResult as a8, TestResultFailed as a9, ProjectBrowser as aA, ResolvedBrowserOptions as aB, ToMatchScreenshotComparators as aC, ToMatchScreenshotOptions as aD, BuiltinEnvironment as aE, CSSModuleScopeStrategy as aF, DepsOptimizationOptions as aG, EnvironmentOptions as aH, Pool as aI, ProjectConfig as aJ, ResolvedProjectConfig as aK, ResolveSnapshotPathHandler as aL, ResolveSnapshotPathHandlerContext as aM, TypecheckConfig as aN, VitestEnvironment as aO, BaseCoverageOptions as aP, CoverageIstanbulOptions as aQ, CoverageOptions as aR, CoverageProvider as aS, CoverageProviderModule as aT, CoverageReporter as aU, CustomProviderOptions as aV, ReportContext as aW, TestRunResult as aX, TestResultPassed as aa, TestResultSkipped as ab, TestState as ac, TestSuiteState as ae, TestSequencerConstructor as ag, TestSpecificationOptions as ah, BenchmarkUserOptions as ai, _BrowserNames as aj, BrowserBuiltinProvider as ak, BrowserCommand as al, BrowserCommandContext as am, BrowserConfigOptions as an, BrowserInstanceOption as ao, BrowserModuleMocker as ap, BrowserOrchestrator as aq, BrowserProvider as ar, BrowserProviderOption as as, BrowserScript as at, BrowserServerFactory as au, BrowserServerOptions as av, BrowserServerState as aw, BrowserServerStateSession as ax, CDPSession as ay, ParentProjectBrowser as az, UserProjectConfigFn as b, UserProjectConfigExport as c, UserConfig as d, TestProjectInlineConfiguration as e, ResolvedConfig as f, VitestRunMode as g, VitestOptions as h, PoolOptions as j, WorkerRequest as k, TestSequencer as l, OnTestsRerunHandler as m, PoolRunnerInitializer as o, PoolTask as p, WorkerResponse as q };
@@ -0,0 +1,148 @@
1
+ import { getSafeTimers } from '@vitest/utils/timers';
2
+ import { c as createBirpc } from './index.Chj8NDwU.js';
3
+ import { g as getWorkerState } from './utils.DT4VyRyl.js';
4
+
5
+ /* Ported from https://github.com/boblauer/MockDate/blob/master/src/mockdate.ts */
6
+ /*
7
+ The MIT License (MIT)
8
+
9
+ Copyright (c) 2014 Bob Lauer
10
+
11
+ Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ of this software and associated documentation files (the "Software"), to deal
13
+ in the Software without restriction, including without limitation the rights
14
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ copies of the Software, and to permit persons to whom the Software is
16
+ furnished to do so, subject to the following conditions:
17
+
18
+ The above copyright notice and this permission notice shall be included in all
19
+ copies or substantial portions of the Software.
20
+
21
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27
+ SOFTWARE.
28
+ */
29
+ const RealDate = Date;
30
+ let now = null;
31
+ class MockDate extends RealDate {
32
+ constructor(y, m, d, h, M, s, ms) {
33
+ super();
34
+ let date;
35
+ switch (arguments.length) {
36
+ case 0:
37
+ if (now !== null) date = new RealDate(now.valueOf());
38
+ else date = new RealDate();
39
+ break;
40
+ case 1:
41
+ date = new RealDate(y);
42
+ break;
43
+ default:
44
+ d = typeof d === "undefined" ? 1 : d;
45
+ h = h || 0;
46
+ M = M || 0;
47
+ s = s || 0;
48
+ ms = ms || 0;
49
+ date = new RealDate(y, m, d, h, M, s, ms);
50
+ break;
51
+ }
52
+ Object.setPrototypeOf(date, MockDate.prototype);
53
+ return date;
54
+ }
55
+ }
56
+ MockDate.UTC = RealDate.UTC;
57
+ MockDate.now = function() {
58
+ return new MockDate().valueOf();
59
+ };
60
+ MockDate.parse = function(dateString) {
61
+ return RealDate.parse(dateString);
62
+ };
63
+ MockDate.toString = function() {
64
+ return RealDate.toString();
65
+ };
66
+ function mockDate(date) {
67
+ const dateObj = new RealDate(date.valueOf());
68
+ if (Number.isNaN(dateObj.getTime())) throw new TypeError(`mockdate: The time set is an invalid date: ${date}`);
69
+ // @ts-expect-error global
70
+ globalThis.Date = MockDate;
71
+ now = dateObj.valueOf();
72
+ }
73
+ function resetDate() {
74
+ globalThis.Date = RealDate;
75
+ }
76
+
77
+ const { get } = Reflect;
78
+ function withSafeTimers(fn) {
79
+ const { setTimeout, clearTimeout, nextTick, setImmediate, clearImmediate } = getSafeTimers();
80
+ const currentSetTimeout = globalThis.setTimeout;
81
+ const currentClearTimeout = globalThis.clearTimeout;
82
+ const currentSetImmediate = globalThis.setImmediate;
83
+ const currentClearImmediate = globalThis.clearImmediate;
84
+ const currentNextTick = globalThis.process?.nextTick;
85
+ try {
86
+ globalThis.setTimeout = setTimeout;
87
+ globalThis.clearTimeout = clearTimeout;
88
+ if (setImmediate) globalThis.setImmediate = setImmediate;
89
+ if (clearImmediate) globalThis.clearImmediate = clearImmediate;
90
+ if (globalThis.process && nextTick) globalThis.process.nextTick = nextTick;
91
+ return fn();
92
+ } finally {
93
+ globalThis.setTimeout = currentSetTimeout;
94
+ globalThis.clearTimeout = currentClearTimeout;
95
+ globalThis.setImmediate = currentSetImmediate;
96
+ globalThis.clearImmediate = currentClearImmediate;
97
+ if (globalThis.process && nextTick) nextTick(() => {
98
+ globalThis.process.nextTick = currentNextTick;
99
+ });
100
+ }
101
+ }
102
+ const promises = /* @__PURE__ */ new Set();
103
+ async function rpcDone() {
104
+ if (!promises.size) return;
105
+ const awaitable = Array.from(promises);
106
+ return Promise.all(awaitable);
107
+ }
108
+ const onCancelCallbacks = [];
109
+ function onCancel(callback) {
110
+ onCancelCallbacks.push(callback);
111
+ }
112
+ function createRuntimeRpc(options) {
113
+ return createSafeRpc(createBirpc({ async onCancel(reason) {
114
+ await Promise.all(onCancelCallbacks.map((fn) => fn(reason)));
115
+ } }, {
116
+ eventNames: [
117
+ "onUserConsoleLog",
118
+ "onCollected",
119
+ "onCancel"
120
+ ],
121
+ timeout: -1,
122
+ ...options
123
+ }));
124
+ }
125
+ function createSafeRpc(rpc) {
126
+ return new Proxy(rpc, { get(target, p, handler) {
127
+ // keep $rejectPendingCalls as sync function
128
+ if (p === "$rejectPendingCalls") return rpc.$rejectPendingCalls;
129
+ const sendCall = get(target, p, handler);
130
+ const safeSendCall = (...args) => withSafeTimers(async () => {
131
+ const result = sendCall(...args);
132
+ promises.add(result);
133
+ try {
134
+ return await result;
135
+ } finally {
136
+ promises.delete(result);
137
+ }
138
+ });
139
+ safeSendCall.asEvent = sendCall.asEvent;
140
+ return safeSendCall;
141
+ } });
142
+ }
143
+ function rpc() {
144
+ const { rpc } = getWorkerState();
145
+ return rpc;
146
+ }
147
+
148
+ export { RealDate as R, rpcDone as a, resetDate as b, createRuntimeRpc as c, mockDate as m, onCancel as o, rpc as r };
@@ -56,6 +56,7 @@ interface RuntimeRPC {
56
56
  getCountOfFailedTests: () => number;
57
57
  snapshotSaved: (snapshot: SnapshotResult) => void;
58
58
  resolveSnapshotPath: (testPath: string) => string;
59
+ ensureModuleGraphEntry: (id: string, importer: string) => void;
59
60
  }
60
61
  interface RunnerRPC {
61
62
  onCancel: (reason: CancelReason) => void;
@@ -1,7 +1,7 @@
1
1
  import { r as resolveCoverageProviderModule } from './coverage.D_JHT54q.js';
2
2
  import { addSerializer } from '@vitest/snapshot';
3
3
  import { setSafeTimers } from '@vitest/utils/timers';
4
- import { g as getWorkerState } from './utils.DvEY5TfP.js';
4
+ import { g as getWorkerState } from './utils.DT4VyRyl.js';
5
5
 
6
6
  async function startCoverageInsideWorker(options, loader, runtimeOptions) {
7
7
  const coverageModule = await resolveCoverageProviderModule(options, loader);
@@ -26,7 +26,7 @@ async function setupCommonEnv(config) {
26
26
  if (globalSetup) return;
27
27
  globalSetup = true;
28
28
  setSafeTimers();
29
- if (config.globals) (await import('./globals.DOayXfHP.js')).registerApiGlobally();
29
+ if (config.globals) (await import('./globals.C6Ecf1TO.js')).registerApiGlobally();
30
30
  }
31
31
  function setupDefines(config) {
32
32
  for (const key in config.defines) globalThis[key] = config.defines[key];