vitest 0.22.0 → 0.23.1

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 (49) hide show
  1. package/LICENSE.md +29 -29
  2. package/dist/browser.d.ts +5 -4
  3. package/dist/browser.mjs +12 -9
  4. package/dist/{chunk-api-setup.ecd02c18.mjs → chunk-api-setup.9e83ca0a.mjs} +92 -90
  5. package/dist/chunk-constants.6196597b.mjs +284 -0
  6. package/dist/{chunk-integrations-coverage.d205bd87.mjs → chunk-env-node.ceb43f1c.mjs} +31 -179
  7. package/dist/{chunk-install-pkg.3aa3eae6.mjs → chunk-install-pkg.e081fc1b.mjs} +3 -3
  8. package/dist/chunk-integrations-coverage.99c020eb.mjs +166 -0
  9. package/dist/chunk-integrations-globals.b1aa52c3.mjs +25 -0
  10. package/dist/{chunk-magic-string.efe26975.mjs → chunk-magic-string.56b2b543.mjs} +30 -10
  11. package/dist/{chunk-mock-date.debe9954.mjs → chunk-mock-date.f63a5ff2.mjs} +31 -193
  12. package/dist/{chunk-node-git.71b74da4.mjs → chunk-node-git.6f289b0a.mjs} +20 -16
  13. package/dist/{chunk-runtime-chain.6e363ba2.mjs → chunk-runtime-chain.8bfc559b.mjs} +507 -173
  14. package/dist/{chunk-runtime-error.975bd80a.mjs → chunk-runtime-error.252dd130.mjs} +206 -75
  15. package/dist/{chunk-runtime-hooks.4789e99d.mjs → chunk-runtime-hooks.c6b06bd8.mjs} +18 -12
  16. package/dist/{chunk-runtime-mocker.c91d29ce.mjs → chunk-runtime-mocker.d9690273.mjs} +19 -12
  17. package/dist/{chunk-runtime-rpc.29488183.mjs → chunk-runtime-rpc.48bd94e3.mjs} +1 -2
  18. package/dist/{chunk-utils-source-map.2a082ffd.mjs → chunk-utils-source-map.a1647f5f.mjs} +11 -5
  19. package/dist/{chunk-vite-node-client.d1ead698.mjs → chunk-vite-node-client.998e04d0.mjs} +92 -31
  20. package/dist/{chunk-vite-node-debug.ff1d2a9f.mjs → chunk-vite-node-debug.2d8a1dc3.mjs} +3 -4
  21. package/dist/{chunk-vite-node-externalize.3a38c8af.mjs → chunk-vite-node-externalize.3035bd5b.mjs} +515 -211
  22. package/dist/{chunk-vite-node-utils.d8e5ff7b.mjs → chunk-vite-node-utils.8a9b3014.mjs} +39 -41
  23. package/dist/cli-wrapper.mjs +54 -33
  24. package/dist/cli.mjs +31 -20
  25. package/dist/config.cjs +2 -2
  26. package/dist/config.d.ts +4 -3
  27. package/dist/config.mjs +2 -2
  28. package/dist/entry.mjs +20 -14
  29. package/dist/environments.d.ts +23 -0
  30. package/dist/environments.mjs +3 -0
  31. package/dist/{global-74489cc9.d.ts → global-ea084c9f.d.ts} +154 -24
  32. package/dist/{index-9eded9ec.d.ts → index-5f09f4d0.d.ts} +3 -2
  33. package/dist/index.d.ts +6 -5
  34. package/dist/index.mjs +7 -7
  35. package/dist/loader.mjs +5 -6
  36. package/dist/node.d.ts +5 -4
  37. package/dist/node.mjs +17 -16
  38. package/dist/suite.mjs +6 -6
  39. package/dist/vendor-index.0557b03a.mjs +147 -0
  40. package/dist/{vendor-index.9d9196cc.mjs → vendor-index.13e3bda3.mjs} +0 -0
  41. package/dist/{vendor-index.fbec8a81.mjs → vendor-index.4aeeb598.mjs} +2 -2
  42. package/dist/{vendor-index.2ae8040a.mjs → vendor-index.62ce5c33.mjs} +0 -0
  43. package/dist/{vendor-index.29636037.mjs → vendor-index.731a22f2.mjs} +0 -0
  44. package/dist/worker.mjs +20 -19
  45. package/package.json +18 -11
  46. package/dist/chunk-constants.d3f8437b.mjs +0 -38
  47. package/dist/chunk-integrations-globals.e81d2091.mjs +0 -27
  48. package/dist/chunk-utils-global.fa20c2f6.mjs +0 -5
  49. package/dist/vendor-picocolors.807856aa.mjs +0 -64
@@ -1,6 +1,7 @@
1
1
  import { ViteDevServer, TransformResult as TransformResult$1, UserConfig as UserConfig$1, CommonServerOptions, AliasOptions } from 'vite';
2
- import { MessagePort } from 'worker_threads';
2
+ import { Options, TaskResult as TaskResult$1, Bench } from 'tinybench';
3
3
  import { Stats } from 'fs';
4
+ import { MessagePort } from 'worker_threads';
4
5
 
5
6
  /**
6
7
  * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
@@ -238,9 +239,21 @@ interface ViteHotContext {
238
239
  }
239
240
  declare class ModuleCacheMap extends Map<string, ModuleCache$1> {
240
241
  normalizePath(fsPath: string): string;
241
- set(fsPath: string, mod: Partial<ModuleCache$1>): this;
242
- get(fsPath: string): ModuleCache$1 | undefined;
242
+ /**
243
+ * Assign partial data to the map
244
+ */
245
+ update(fsPath: string, mod: Partial<ModuleCache$1>): this;
246
+ set(fsPath: string, mod: ModuleCache$1): this;
247
+ get(fsPath: string): ModuleCache$1;
243
248
  delete(fsPath: string): boolean;
249
+ /**
250
+ * Invalidate modules that dependent on the given modules, up to the main entry
251
+ */
252
+ invalidateDepTree(ids: string[] | Set<string>, invalidated?: Set<string>): Set<string>;
253
+ /**
254
+ * Invalidate dependency modules of the given modules, down to the bottom-level dependencies
255
+ */
256
+ invalidateSubDepTree(ids: string[] | Set<string>, invalidated?: Set<string>): Set<string>;
244
257
  }
245
258
  declare class ViteNodeRunner {
246
259
  options: ViteNodeRunnerOptions;
@@ -304,6 +317,10 @@ interface ModuleCache$1 {
304
317
  promise?: Promise<any>;
305
318
  exports?: any;
306
319
  code?: string;
320
+ /**
321
+ * Module ids that imports this module
322
+ */
323
+ importers?: Set<string>;
307
324
  }
308
325
  interface ViteNodeRunnerOptions {
309
326
  root: string;
@@ -375,6 +392,7 @@ declare class ViteNodeServer {
375
392
  private fetchPromiseMap;
376
393
  private transformPromiseMap;
377
394
  fetchCache: Map<string, {
395
+ duration?: number | undefined;
378
396
  timestamp: number;
379
397
  result: FetchResult;
380
398
  }>;
@@ -484,7 +502,7 @@ interface CliOptions extends UserConfig {
484
502
  */
485
503
  run?: boolean;
486
504
  }
487
- declare function startVitest(cliFilters: string[], options: CliOptions, viteOverrides?: UserConfig$1): Promise<boolean>;
505
+ declare function startVitest(mode: VitestRunMode, cliFilters: string[], options: CliOptions, viteOverrides?: UserConfig$1): Promise<boolean>;
488
506
 
489
507
  declare type FileStatsCache = Pick<Stats, 'size'>;
490
508
  declare class FilesStatsCache {
@@ -509,6 +527,7 @@ declare class VitestCache {
509
527
  }
510
528
 
511
529
  declare class Vitest {
530
+ readonly mode: VitestRunMode;
512
531
  config: ResolvedConfig;
513
532
  configOverride: Partial<ResolvedConfig> | undefined;
514
533
  server: ViteDevServer;
@@ -527,7 +546,7 @@ declare class Vitest {
527
546
  isFirstRun: boolean;
528
547
  restartsCount: number;
529
548
  runner: ViteNodeRunner;
530
- constructor();
549
+ constructor(mode: VitestRunMode);
531
550
  private _onRestartListeners;
532
551
  setServer(options: UserConfig, server: ViteDevServer): Promise<void>;
533
552
  initCoverageProvider(): Promise<CoverageProvider | null | undefined>;
@@ -538,6 +557,7 @@ declare class Vitest {
538
557
  runFiles(paths: string[]): Promise<void>;
539
558
  rerunFiles(files?: string[], trigger?: string): Promise<void>;
540
559
  changeNamePattern(pattern: string, files?: string[], trigger?: string): Promise<void>;
560
+ changeFilenamePattern(pattern: string): Promise<void>;
541
561
  rerunFailed(): Promise<void>;
542
562
  updateSnapshot(files?: string[]): Promise<void>;
543
563
  private _rerunTimer;
@@ -554,7 +574,7 @@ declare class Vitest {
554
574
  globTestFiles(filters?: string[]): Promise<string[]>;
555
575
  isTargetFile(id: string, source?: string): Promise<boolean>;
556
576
  isInSourceTestFile(code: string): boolean;
557
- onServerRestarted(fn: () => void): void;
577
+ onServerRestart(fn: OnServerRestartHandler): void;
558
578
  }
559
579
 
560
580
  declare type MockMap = Map<string, Record<string, string | null | (() => unknown)>>;
@@ -592,7 +612,7 @@ declare abstract class BaseReporter implements Reporter {
592
612
  onWatcherRerun(files: string[], trigger?: string): Promise<void>;
593
613
  onUserConsoleLog(log: UserConsoleLog): void;
594
614
  shouldLog(log: UserConsoleLog): boolean;
595
- onServerRestart(): void;
615
+ onServerRestart(reason?: string): void;
596
616
  reportSummary(files: File[]): Promise<void>;
597
617
  private printTaskErrors;
598
618
  registerUnhandledRejection(): void;
@@ -636,7 +656,7 @@ interface Callsite {
636
656
  line: number;
637
657
  column: number;
638
658
  }
639
- declare class JsonReporter implements Reporter {
659
+ declare class JsonReporter$1 implements Reporter {
640
660
  start: number;
641
661
  ctx: Vitest;
642
662
  onInit(ctx: Vitest): void;
@@ -648,7 +668,7 @@ declare class JsonReporter implements Reporter {
648
668
  * @param report
649
669
  */
650
670
  writeReport(report: string): Promise<void>;
651
- protected getFailureLocation(test: Test): Callsite | undefined;
671
+ protected getFailureLocation(test: Task): Promise<Callsite | undefined>;
652
672
  }
653
673
 
654
674
  declare class VerboseReporter extends DefaultReporter {
@@ -684,11 +704,31 @@ declare class TapFlatReporter extends TapReporter {
684
704
  onFinished(files?: File[]): Promise<void>;
685
705
  }
686
706
 
707
+ declare class JsonReporter implements Reporter {
708
+ start: number;
709
+ ctx: Vitest;
710
+ onInit(ctx: Vitest): void;
711
+ protected logTasks(files: File[]): Promise<void>;
712
+ onFinished(files?: File[]): Promise<void>;
713
+ /**
714
+ * Writes the report to an output file if specified in the config,
715
+ * or logs it to the console otherwise.
716
+ * @param report
717
+ */
718
+ writeReport(report: string): Promise<void>;
719
+ }
720
+
721
+ declare const BenchmarkReportsMap: {
722
+ default: typeof VerboseReporter;
723
+ json: typeof JsonReporter;
724
+ };
725
+ declare type BenchmarkBuiltinReporters = keyof typeof BenchmarkReportsMap;
726
+
687
727
  declare const ReportersMap: {
688
728
  default: typeof DefaultReporter;
689
729
  verbose: typeof VerboseReporter;
690
730
  dot: typeof DotReporter;
691
- json: typeof JsonReporter;
731
+ json: typeof JsonReporter$1;
692
732
  tap: typeof TapReporter;
693
733
  'tap-flat': typeof TapFlatReporter;
694
734
  junit: typeof JUnitReporter;
@@ -964,6 +1004,7 @@ interface ModuleGraphData {
964
1004
  externalized: string[];
965
1005
  inlined: string[];
966
1006
  }
1007
+ declare type OnServerRestartHandler = (reason?: string) => Promise<void> | void;
967
1008
 
968
1009
  declare type ArgumentsType<T> = T extends (...args: infer A) => any ? A : never;
969
1010
  declare type ReturnType$1<T> = T extends (...args: any) => infer R ? R : never;
@@ -982,8 +1023,55 @@ declare type ChainableFunction<T extends string, Args extends any[], R = any, E
982
1023
  (...args: Args): R;
983
1024
  } & {
984
1025
  [x in T]: ChainableFunction<T, Args, R, E>;
1026
+ } & {
1027
+ fn: (this: Record<T, boolean | undefined>, ...args: Args) => R;
985
1028
  } & E;
986
1029
 
1030
+ interface BenchmarkUserOptions {
1031
+ /**
1032
+ * Include globs for benchmark test files
1033
+ *
1034
+ * @default ['**\/*.{bench,benchmark}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}']
1035
+ */
1036
+ include?: string[];
1037
+ /**
1038
+ * Exclude globs for benchmark test files
1039
+ * @default ['node_modules', 'dist', '.idea', '.git', '.cache']
1040
+ */
1041
+ exclude?: string[];
1042
+ /**
1043
+ * Include globs for in-source test files
1044
+ *
1045
+ * @default []
1046
+ */
1047
+ includeSource?: string[];
1048
+ /**
1049
+ * Custom reporter for output. Can contain one or more built-in report names, reporter instances,
1050
+ * and/or paths to custom reporters
1051
+ */
1052
+ reporters?: Arrayable<BenchmarkBuiltinReporters | Reporter>;
1053
+ }
1054
+ interface Benchmark extends TaskBase {
1055
+ type: 'benchmark';
1056
+ suite: Suite;
1057
+ result?: TaskResult;
1058
+ fails?: boolean;
1059
+ options: Options;
1060
+ }
1061
+ interface BenchmarkResult extends TaskResult$1 {
1062
+ name: string;
1063
+ rank: number;
1064
+ }
1065
+ declare type BenchFunction = (this: Bench) => Promise<void> | void;
1066
+ declare type BenchmarkAPI = ChainableFunction<'skip', [
1067
+ name: string,
1068
+ fn: BenchFunction,
1069
+ options?: Options
1070
+ ], void> & {
1071
+ skipIf(condition: any): BenchmarkAPI;
1072
+ runIf(condition: any): BenchmarkAPI;
1073
+ };
1074
+
987
1075
  declare type RunMode = 'run' | 'skip' | 'only' | 'todo';
988
1076
  declare type TaskState = RunMode | 'pass' | 'fail';
989
1077
  interface TaskBase {
@@ -995,6 +1083,7 @@ interface TaskBase {
995
1083
  suite?: Suite;
996
1084
  file?: File;
997
1085
  result?: TaskResult;
1086
+ retry?: number;
998
1087
  logs?: UserConsoleLog[];
999
1088
  }
1000
1089
  interface TaskResult {
@@ -1005,12 +1094,15 @@ interface TaskResult {
1005
1094
  error?: ErrorWithDiff;
1006
1095
  htmlError?: string;
1007
1096
  hooks?: Partial<Record<keyof SuiteHooks, TaskState>>;
1097
+ benchmark?: BenchmarkResult;
1098
+ retryCount?: number;
1008
1099
  }
1009
1100
  declare type TaskResultPack = [id: string, result: TaskResult | undefined];
1010
1101
  interface Suite extends TaskBase {
1011
1102
  type: 'suite';
1012
1103
  tasks: Task[];
1013
1104
  filepath?: string;
1105
+ benchmark?: Bench;
1014
1106
  }
1015
1107
  interface File extends Suite {
1016
1108
  filepath: string;
@@ -1024,7 +1116,7 @@ interface Test<ExtraContext = {}> extends TaskBase {
1024
1116
  fails?: boolean;
1025
1117
  context: TestContext & ExtraContext;
1026
1118
  }
1027
- declare type Task = Test | Suite | File;
1119
+ declare type Task = Test | Suite | File | Benchmark;
1028
1120
  declare type DoneCallback = (error?: any) => void;
1029
1121
  declare type TestFunction<ExtraContext = {}> = (context: TestContext & ExtraContext) => Awaitable<any> | void;
1030
1122
  declare type ExtractEachCallbackArgs<T extends ReadonlyArray<any>> = {
@@ -1046,18 +1138,31 @@ interface SuiteEachFunction {
1046
1138
  <T>(cases: ReadonlyArray<T>): (name: string, fn: (...args: T[]) => Awaitable<void>) => void;
1047
1139
  }
1048
1140
  interface TestEachFunction {
1049
- <T extends any[] | [any]>(cases: ReadonlyArray<T>): (name: string, fn: (...args: T) => Awaitable<void>, timeout?: number) => void;
1050
- <T extends ReadonlyArray<any>>(cases: ReadonlyArray<T>): (name: string, fn: (...args: ExtractEachCallbackArgs<T>) => Awaitable<void>, timeout?: number) => void;
1051
- <T>(cases: ReadonlyArray<T>): (name: string, fn: (...args: T[]) => Awaitable<void>, timeout?: number) => void;
1141
+ <T extends any[] | [any]>(cases: ReadonlyArray<T>): (name: string, fn: (...args: T) => Awaitable<void>, options?: number | TestOptions) => void;
1142
+ <T extends ReadonlyArray<any>>(cases: ReadonlyArray<T>): (name: string, fn: (...args: ExtractEachCallbackArgs<T>) => Awaitable<void>, options?: number | TestOptions) => void;
1143
+ <T>(cases: ReadonlyArray<T>): (name: string, fn: (...args: T[]) => Awaitable<void>, options?: number | TestOptions) => void;
1052
1144
  }
1053
1145
  declare type ChainableTestAPI<ExtraContext = {}> = ChainableFunction<'concurrent' | 'only' | 'skip' | 'todo' | 'fails', [
1054
1146
  name: string,
1055
1147
  fn?: TestFunction<ExtraContext>,
1056
- timeout?: number
1148
+ options?: number | TestOptions
1057
1149
  ], void, {
1058
1150
  each: TestEachFunction;
1059
- <T extends ExtraContext>(name: string, fn?: TestFunction<T>, timeout?: number): void;
1151
+ <T extends ExtraContext>(name: string, fn?: TestFunction<T>, options?: number | TestOptions): void;
1060
1152
  }>;
1153
+ interface TestOptions {
1154
+ /**
1155
+ * Test timeout.
1156
+ */
1157
+ timeout?: number;
1158
+ /**
1159
+ * Times to retry the test if fails. Useful for making flaky tests more stable.
1160
+ * When retries is up, the last test error will be thrown.
1161
+ *
1162
+ * @default 1
1163
+ */
1164
+ retry?: number;
1165
+ }
1061
1166
  declare type TestAPI<ExtraContext = {}> = ChainableTestAPI<ExtraContext> & {
1062
1167
  each: TestEachFunction;
1063
1168
  skipIf(condition: any): ChainableTestAPI<ExtraContext>;
@@ -1088,7 +1193,8 @@ interface SuiteCollector<ExtraContext = {}> {
1088
1193
  readonly mode: RunMode;
1089
1194
  type: 'collector';
1090
1195
  test: TestAPI<ExtraContext>;
1091
- tasks: (Suite | Test | SuiteCollector<ExtraContext>)[];
1196
+ benchmark: BenchmarkAPI;
1197
+ tasks: (Suite | Test | Benchmark | SuiteCollector<ExtraContext>)[];
1092
1198
  collect: (file?: File) => Promise<Suite>;
1093
1199
  clear: () => void;
1094
1200
  on: <T extends keyof SuiteHooks<ExtraContext>>(name: T, ...fn: SuiteHooks<ExtraContext>[T]) => void;
@@ -1257,6 +1363,10 @@ interface BaseCoverageOptions {
1257
1363
  * @default 'text'
1258
1364
  */
1259
1365
  reporter?: Arrayable<CoverageReporter>;
1366
+ /**
1367
+ * List of files included in coverage as glob patterns
1368
+ */
1369
+ include?: string[];
1260
1370
  /**
1261
1371
  * List of files excluded from coverage as glob patterns
1262
1372
  */
@@ -1291,6 +1401,10 @@ interface BaseCoverageOptions {
1291
1401
  * Extensions for files to be included in coverage
1292
1402
  */
1293
1403
  extension?: string | string[];
1404
+ /**
1405
+ * Whether to include all files, including the untested ones into report
1406
+ */
1407
+ all?: boolean;
1294
1408
  }
1295
1409
  interface CoverageIstanbulOptions extends BaseCoverageOptions {
1296
1410
  ignoreClassMethods?: string[];
@@ -1314,8 +1428,6 @@ interface CoverageC8Options extends BaseCoverageOptions {
1314
1428
  * @default true
1315
1429
  */
1316
1430
  excludeNodeModules?: boolean;
1317
- include?: string[];
1318
- all?: boolean;
1319
1431
  src?: string[];
1320
1432
  100?: boolean;
1321
1433
  }
@@ -1409,11 +1521,13 @@ interface Reporter {
1409
1521
  onTestRemoved?: (trigger?: string) => Awaitable<void>;
1410
1522
  onWatcherStart?: () => Awaitable<void>;
1411
1523
  onWatcherRerun?: (files: string[], trigger?: string) => Awaitable<void>;
1412
- onServerRestart?: () => Awaitable<void>;
1524
+ onServerRestart?: (reason?: string) => Awaitable<void>;
1413
1525
  onUserConsoleLog?: (log: UserConsoleLog) => Awaitable<void>;
1414
1526
  }
1415
1527
 
1416
1528
  declare type BuiltinEnvironment = 'node' | 'jsdom' | 'happy-dom' | 'edge-runtime';
1529
+ declare type VitestEnvironment = BuiltinEnvironment | (string & Record<never, never>);
1530
+ declare type CSSModuleScopeStrategy = 'stable' | 'scoped' | 'non-scoped';
1417
1531
  declare type ApiConfig = Pick<CommonServerOptions, 'port' | 'strictPort' | 'host'>;
1418
1532
 
1419
1533
  interface EnvironmentOptions {
@@ -1421,8 +1535,16 @@ interface EnvironmentOptions {
1421
1535
  * jsdom options.
1422
1536
  */
1423
1537
  jsdom?: JSDOMOptions;
1538
+ [x: string]: unknown;
1424
1539
  }
1540
+ declare type VitestRunMode = 'test' | 'benchmark';
1425
1541
  interface InlineConfig {
1542
+ /**
1543
+ * Benchmark options.
1544
+ *
1545
+ * @default {}
1546
+ */
1547
+ benchmark?: BenchmarkUserOptions;
1426
1548
  /**
1427
1549
  * Include globs for test files
1428
1550
  *
@@ -1498,9 +1620,11 @@ interface InlineConfig {
1498
1620
  *
1499
1621
  * Supports 'node', 'jsdom', 'happy-dom', 'edge-runtime'
1500
1622
  *
1623
+ * If used unsupported string, will try to load the package `vitest-environment-${env}`
1624
+ *
1501
1625
  * @default 'node'
1502
1626
  */
1503
- environment?: BuiltinEnvironment;
1627
+ environment?: VitestEnvironment;
1504
1628
  /**
1505
1629
  * Environment options.
1506
1630
  */
@@ -1721,11 +1845,14 @@ interface InlineConfig {
1721
1845
  *
1722
1846
  * When excluded, the CSS files will be replaced with empty strings to bypass the subsequent processing.
1723
1847
  *
1724
- * @default { include: [/\.module\./] }
1848
+ * @default { include: [], modules: { classNameStrategy: false } }
1725
1849
  */
1726
1850
  css?: boolean | {
1727
1851
  include?: RegExp | RegExp[];
1728
1852
  exclude?: RegExp | RegExp[];
1853
+ modules?: {
1854
+ classNameStrategy?: CSSModuleScopeStrategy;
1855
+ };
1729
1856
  };
1730
1857
  /**
1731
1858
  * A number of tests that are allowed to run at the same time marked with `test.concurrent`.
@@ -1810,7 +1937,8 @@ interface UserConfig extends InlineConfig {
1810
1937
  */
1811
1938
  shard?: string;
1812
1939
  }
1813
- interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters' | 'coverage' | 'testNamePattern' | 'related' | 'api' | 'reporters' | 'resolveSnapshotPath' | 'shard' | 'cache' | 'sequence'> {
1940
+ interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters' | 'coverage' | 'testNamePattern' | 'related' | 'api' | 'reporters' | 'resolveSnapshotPath' | 'benchmark' | 'shard' | 'cache' | 'sequence'> {
1941
+ mode: VitestRunMode;
1814
1942
  base?: string;
1815
1943
  config?: string;
1816
1944
  filters?: string[];
@@ -1821,6 +1949,7 @@ interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters'
1821
1949
  reporters: (Reporter | BuiltinReporters)[];
1822
1950
  defines: Record<string, any>;
1823
1951
  api?: ApiConfig;
1952
+ benchmark?: Required<BenchmarkUserOptions>;
1824
1953
  shard?: {
1825
1954
  index: number;
1826
1955
  count: number;
@@ -1974,6 +2103,7 @@ interface MatcherState {
1974
2103
  isExpectingAssertions?: boolean;
1975
2104
  isExpectingAssertionsError?: Error | null;
1976
2105
  isNot: boolean;
2106
+ environment: VitestEnvironment;
1977
2107
  promise: string;
1978
2108
  snapshotState: SnapshotState;
1979
2109
  suppressedErrors: Array<Error>;
@@ -2095,4 +2225,4 @@ declare global {
2095
2225
  }
2096
2226
  }
2097
2227
 
2098
- export { Environment as $, ApiConfig as A, BuiltinEnvironment as B, WorkerRPC as C, DoneCallback as D, EnvironmentOptions as E, FakeTimerInstallOpts as F, WorkerGlobalState as G, HookListener as H, InlineConfig as I, JSDOMOptions as J, Awaitable as K, Arrayable as L, ModuleGraphData as M, Nullable as N, ArgumentsType$1 as O, MergeInsertions as P, DeepMerge as Q, ResolvedConfig as R, Suite as S, TaskResultPack as T, UserConfig as U, Vitest as V, WorkerContext as W, MutableArray as X, Constructable as Y, ModuleCache as Z, EnvironmentReturn as _, File as a, UserConsoleLog as a0, Position as a1, ParsedStack as a2, ErrorWithDiff as a3, CoverageProvider as a4, CoverageProviderModule as a5, CoverageReporter as a6, CoverageOptions as a7, ResolvedCoverageOptions as a8, BaseCoverageOptions as a9, CoverageIstanbulOptions as aa, CoverageC8Options as ab, ModuleCacheMap as ac, ViteNodeRunnerOptions as ad, MockMap as ae, ViteNodeRunner as af, TestSequencer as ag, startVitest as ah, TestSequencerConstructor as ai, Reporter as b, RunMode as c, TaskState as d, TaskBase as e, TaskResult as f, Test as g, Task as h, TestFunction as i, TestAPI as j, SuiteAPI as k, HookCleanupCallback as l, SuiteHooks as m, SuiteCollector as n, SuiteFactory as o, RuntimeContext as p, TestContext as q, SnapshotData as r, SnapshotUpdateState as s, SnapshotStateOptions as t, SnapshotMatchOptions as u, SnapshotResult as v, UncheckedSnapshot as w, SnapshotSummary as x, ResolveIdFunction as y, AfterSuiteRunMeta as z };
2228
+ export { MutableArray as $, ApiConfig as A, BuiltinEnvironment as B, CSSModuleScopeStrategy as C, DoneCallback as D, EnvironmentOptions as E, FakeTimerInstallOpts as F, SnapshotSummary as G, HookListener as H, InlineConfig as I, JSDOMOptions as J, ResolveIdFunction as K, AfterSuiteRunMeta as L, ModuleGraphData as M, WorkerRPC as N, WorkerGlobalState as O, Awaitable as P, Nullable as Q, ResolvedConfig as R, Suite as S, TaskResultPack as T, UserConfig as U, VitestEnvironment as V, WorkerContext as W, Arrayable as X, ArgumentsType$1 as Y, MergeInsertions as Z, DeepMerge as _, File as a, Constructable as a0, ModuleCache as a1, EnvironmentReturn as a2, Environment as a3, UserConsoleLog as a4, Position as a5, ParsedStack as a6, ErrorWithDiff as a7, OnServerRestartHandler as a8, CoverageProvider as a9, CoverageProviderModule as aa, CoverageReporter as ab, CoverageOptions as ac, ResolvedCoverageOptions as ad, BaseCoverageOptions as ae, CoverageIstanbulOptions as af, CoverageC8Options as ag, BenchmarkUserOptions as ah, Benchmark as ai, BenchmarkResult as aj, BenchFunction as ak, BenchmarkAPI as al, ModuleCacheMap as am, ViteNodeRunnerOptions as an, MockMap as ao, ViteNodeRunner as ap, TestSequencer as aq, startVitest as ar, TestSequencerConstructor as as, Reporter as b, VitestRunMode as c, RunMode as d, TaskState as e, TaskBase as f, TaskResult as g, Test as h, Task as i, TestFunction as j, TestOptions as k, TestAPI as l, SuiteAPI as m, HookCleanupCallback as n, SuiteHooks as o, SuiteCollector as p, SuiteFactory as q, RuntimeContext as r, TestContext as s, Vitest as t, SnapshotData as u, SnapshotUpdateState as v, SnapshotStateOptions as w, SnapshotMatchOptions as x, SnapshotResult as y, UncheckedSnapshot as z };
@@ -1,5 +1,5 @@
1
1
  import { SpyImpl } from 'tinyspy';
2
- import { k as SuiteAPI, j as TestAPI, m as SuiteHooks, H as HookListener, q as TestContext, S as Suite, l as HookCleanupCallback, g as Test } from './global-74489cc9.js';
2
+ import { m as SuiteAPI, l as TestAPI, al as BenchmarkAPI, o as SuiteHooks, H as HookListener, s as TestContext, S as Suite, n as HookCleanupCallback, h as Test } from './global-ea084c9f.js';
3
3
 
4
4
  interface MockResultReturn<T> {
5
5
  type: 'return';
@@ -102,6 +102,7 @@ declare function fn<TArgs extends any[] = any[], R = any>(implementation: (...ar
102
102
 
103
103
  declare const suite: SuiteAPI<{}>;
104
104
  declare const test: TestAPI<{}>;
105
+ declare const bench: BenchmarkAPI;
105
106
  declare const describe: SuiteAPI<{}>;
106
107
  declare const it: TestAPI<{}>;
107
108
 
@@ -113,4 +114,4 @@ declare const afterEach: <ExtraContext = {}>(fn: HookListener<[TestContext & Ext
113
114
  declare function createExpect(test?: Test): Vi.ExpectStatic;
114
115
  declare const globalExpect: Vi.ExpectStatic;
115
116
 
116
- export { EnhancedSpy as E, MaybeMockedDeep as M, SpyInstance as S, MaybeMocked as a, MaybePartiallyMocked as b, MaybePartiallyMockedDeep as c, suite as d, describe as e, fn as f, beforeAll as g, afterAll as h, it as i, beforeEach as j, afterEach as k, globalExpect as l, createExpect as m, MockedFunction as n, MockedObject as o, MockInstance as p, Mock as q, MockContext as r, spyOn as s, test as t, Mocked as u, MockedClass as v };
117
+ export { EnhancedSpy as E, MaybeMockedDeep as M, SpyInstance as S, MaybeMocked as a, MaybePartiallyMocked as b, MaybePartiallyMockedDeep as c, suite as d, describe as e, fn as f, bench as g, beforeAll as h, it as i, afterAll as j, beforeEach as k, afterEach as l, globalExpect as m, createExpect as n, MockedFunction as o, MockedObject as p, MockInstance as q, Mock as r, spyOn as s, test as t, MockContext as u, Mocked as v, MockedClass as w };
package/dist/index.d.ts CHANGED
@@ -1,14 +1,15 @@
1
- import { s as spyOn, f as fn, M as MaybeMockedDeep, a as MaybeMocked, b as MaybePartiallyMocked, c as MaybePartiallyMockedDeep, E as EnhancedSpy } from './index-9eded9ec.js';
2
- export { E as EnhancedSpy, q as Mock, r as MockContext, p as MockInstance, u as Mocked, v as MockedClass, n as MockedFunction, o as MockedObject, S as SpyInstance, h as afterAll, k as afterEach, g as beforeAll, j as beforeEach, m as createExpect, e as describe, l as expect, i as it, d as suite, t as test } from './index-9eded9ec.js';
3
- import { D as DoneCallback, F as FakeTimerInstallOpts, a as File, T as TaskResultPack, R as ResolvedConfig, M as ModuleGraphData, b as Reporter } from './global-74489cc9.js';
4
- export { z as AfterSuiteRunMeta, A as ApiConfig, O as ArgumentsType, L as Arrayable, K as Awaitable, a9 as BaseCoverageOptions, B as BuiltinEnvironment, Y as Constructable, ab as CoverageC8Options, aa as CoverageIstanbulOptions, a7 as CoverageOptions, a4 as CoverageProvider, a5 as CoverageProviderModule, a6 as CoverageReporter, Q as DeepMerge, D as DoneCallback, $ as Environment, E as EnvironmentOptions, _ as EnvironmentReturn, a3 as ErrorWithDiff, a as File, l as HookCleanupCallback, H as HookListener, I as InlineConfig, J as JSDOMOptions, P as MergeInsertions, Z as ModuleCache, M as ModuleGraphData, X as MutableArray, N as Nullable, a2 as ParsedStack, a1 as Position, b as Reporter, y as ResolveIdFunction, R as ResolvedConfig, a8 as ResolvedCoverageOptions, c as RunMode, p as RuntimeContext, r as SnapshotData, u as SnapshotMatchOptions, v as SnapshotResult, t as SnapshotStateOptions, x as SnapshotSummary, s as SnapshotUpdateState, S as Suite, k as SuiteAPI, n as SuiteCollector, o as SuiteFactory, m as SuiteHooks, h as Task, e as TaskBase, f as TaskResult, T as TaskResultPack, d as TaskState, g as Test, j as TestAPI, q as TestContext, i as TestFunction, w as UncheckedSnapshot, U as UserConfig, a0 as UserConsoleLog, V as Vitest, W as WorkerContext, G as WorkerGlobalState, C as WorkerRPC } from './global-74489cc9.js';
1
+ import { s as spyOn, f as fn, M as MaybeMockedDeep, a as MaybeMocked, b as MaybePartiallyMocked, c as MaybePartiallyMockedDeep, E as EnhancedSpy } from './index-5f09f4d0.js';
2
+ export { E as EnhancedSpy, r as Mock, u as MockContext, q as MockInstance, v as Mocked, w as MockedClass, o as MockedFunction, p as MockedObject, S as SpyInstance, j as afterAll, l as afterEach, h as beforeAll, k as beforeEach, g as bench, n as createExpect, e as describe, m as expect, i as it, d as suite, t as test } from './index-5f09f4d0.js';
3
+ import { D as DoneCallback, F as FakeTimerInstallOpts, a as File, T as TaskResultPack, R as ResolvedConfig, M as ModuleGraphData, b as Reporter } from './global-ea084c9f.js';
4
+ export { L as AfterSuiteRunMeta, A as ApiConfig, Y as ArgumentsType, X as Arrayable, P as Awaitable, ae as BaseCoverageOptions, ak as BenchFunction, ai as Benchmark, al as BenchmarkAPI, aj as BenchmarkResult, ah as BenchmarkUserOptions, B as BuiltinEnvironment, C as CSSModuleScopeStrategy, a0 as Constructable, ag as CoverageC8Options, af as CoverageIstanbulOptions, ac as CoverageOptions, a9 as CoverageProvider, aa as CoverageProviderModule, ab as CoverageReporter, _ as DeepMerge, D as DoneCallback, a3 as Environment, E as EnvironmentOptions, a2 as EnvironmentReturn, a7 as ErrorWithDiff, a as File, n as HookCleanupCallback, H as HookListener, I as InlineConfig, J as JSDOMOptions, Z as MergeInsertions, a1 as ModuleCache, M as ModuleGraphData, $ as MutableArray, Q as Nullable, a8 as OnServerRestartHandler, a6 as ParsedStack, a5 as Position, b as Reporter, K as ResolveIdFunction, R as ResolvedConfig, ad as ResolvedCoverageOptions, d as RunMode, r as RuntimeContext, u as SnapshotData, x as SnapshotMatchOptions, y as SnapshotResult, w as SnapshotStateOptions, G as SnapshotSummary, v as SnapshotUpdateState, S as Suite, m as SuiteAPI, p as SuiteCollector, q as SuiteFactory, o as SuiteHooks, i as Task, f as TaskBase, g as TaskResult, T as TaskResultPack, e as TaskState, h as Test, l as TestAPI, s as TestContext, j as TestFunction, k as TestOptions, z as UncheckedSnapshot, U as UserConfig, a4 as UserConsoleLog, t as Vitest, V as VitestEnvironment, c as VitestRunMode, W as WorkerContext, O as WorkerGlobalState, N as WorkerRPC } from './global-ea084c9f.js';
5
5
  import { TransformResult } from 'vite';
6
6
  import * as chai from 'chai';
7
7
  export { chai };
8
8
  export { assert, should } from 'chai';
9
+ export { Bench as BenchFactory, Options as BenchOptions, Task as BenchTask, TaskResult as BenchTaskResult } from 'tinybench';
9
10
  import 'tinyspy';
10
- import 'worker_threads';
11
11
  import 'fs';
12
+ import 'worker_threads';
12
13
 
13
14
  /**
14
15
  * A simple wrapper for converting callback style to promise
package/dist/index.mjs CHANGED
@@ -1,19 +1,19 @@
1
- export { c as createExpect, d as describe, b as expect, i as it, s as suite, t as test } from './chunk-runtime-chain.6e363ba2.mjs';
2
- export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach, h as getRunningMode, f as isFirstRun, j as isWatchMode, e as runOnce, v as vi, g as vitest, w as withCallback } from './chunk-runtime-hooks.4789e99d.mjs';
1
+ export { b as bench, c as createExpect, d as describe, e as expect, i as it, s as suite, t as test } from './chunk-runtime-chain.8bfc559b.mjs';
2
+ export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach, h as getRunningMode, f as isFirstRun, j as isWatchMode, e as runOnce, v as vi, g as vitest, w as withCallback } from './chunk-runtime-hooks.c6b06bd8.mjs';
3
3
  import * as chai from 'chai';
4
4
  export { chai };
5
5
  export { assert, should } from 'chai';
6
6
  import 'util';
7
- import './chunk-mock-date.debe9954.mjs';
7
+ import './chunk-mock-date.f63a5ff2.mjs';
8
8
  import 'path';
9
- import './vendor-picocolors.807856aa.mjs';
9
+ import './chunk-constants.6196597b.mjs';
10
10
  import 'tty';
11
+ import 'url';
11
12
  import 'local-pkg';
12
13
  import './vendor-_commonjsHelpers.4da45ef5.mjs';
13
- import './chunk-runtime-rpc.29488183.mjs';
14
- import './chunk-utils-global.fa20c2f6.mjs';
14
+ import './chunk-runtime-rpc.48bd94e3.mjs';
15
15
  import './chunk-utils-timers.b48455ed.mjs';
16
16
  import 'fs';
17
- import './chunk-utils-source-map.2a082ffd.mjs';
17
+ import './chunk-utils-source-map.a1647f5f.mjs';
18
18
  import './spy.mjs';
19
19
  import 'tinyspy';
package/dist/loader.mjs CHANGED
@@ -1,15 +1,14 @@
1
1
  import { pathToFileURL } from 'url';
2
2
  import { readFile } from 'fs/promises';
3
- import { i as isNodeBuiltin, d as normalizeModuleId, h as hasCJSSyntax } from './chunk-vite-node-utils.d8e5ff7b.mjs';
4
- import './chunk-mock-date.debe9954.mjs';
5
- import { g as getWorkerState } from './chunk-utils-global.fa20c2f6.mjs';
3
+ import { i as isNodeBuiltin, d as normalizeModuleId, h as hasCJSSyntax } from './chunk-vite-node-utils.8a9b3014.mjs';
4
+ import { g as getWorkerState } from './chunk-mock-date.f63a5ff2.mjs';
5
+ import './chunk-constants.6196597b.mjs';
6
+ import 'tty';
7
+ import 'path';
6
8
  import 'module';
7
9
  import 'fs';
8
- import 'path';
9
10
  import 'assert';
10
11
  import 'util';
11
- import './vendor-picocolors.807856aa.mjs';
12
- import 'tty';
13
12
  import 'local-pkg';
14
13
 
15
14
  var ModuleFormat = /* @__PURE__ */ ((ModuleFormat2) => {
package/dist/node.d.ts CHANGED
@@ -1,10 +1,11 @@
1
- import { U as UserConfig, V as Vitest, ac as ModuleCacheMap, ad as ViteNodeRunnerOptions, ae as MockMap, af as ViteNodeRunner, ag as TestSequencer } from './global-74489cc9.js';
2
- export { ag as TestSequencer, ai as TestSequencerConstructor, V as Vitest, ah as startVitest } from './global-74489cc9.js';
1
+ import { c as VitestRunMode, U as UserConfig, t as Vitest, am as ModuleCacheMap, an as ViteNodeRunnerOptions, ao as MockMap, ap as ViteNodeRunner, aq as TestSequencer } from './global-ea084c9f.js';
2
+ export { aq as TestSequencer, as as TestSequencerConstructor, t as Vitest, ar as startVitest } from './global-ea084c9f.js';
3
3
  import { UserConfig as UserConfig$1, Plugin } from 'vite';
4
- import 'worker_threads';
4
+ import 'tinybench';
5
5
  import 'fs';
6
+ import 'worker_threads';
6
7
 
7
- declare function createVitest(options: UserConfig, viteOverrides?: UserConfig$1): Promise<Vitest>;
8
+ declare function createVitest(mode: VitestRunMode, options: UserConfig, viteOverrides?: UserConfig$1): Promise<Vitest>;
8
9
 
9
10
  declare function VitestPlugin(options?: UserConfig, ctx?: Vitest): Promise<Plugin[]>;
10
11
 
package/dist/node.mjs CHANGED
@@ -1,36 +1,37 @@
1
- export { B as BaseSequencer, V as VitestPlugin, c as createVitest, s as startVitest } from './chunk-vite-node-externalize.3a38c8af.mjs';
2
- export { V as VitestRunner } from './chunk-runtime-mocker.c91d29ce.mjs';
3
- import './chunk-mock-date.debe9954.mjs';
4
- import 'path';
5
- import './vendor-picocolors.807856aa.mjs';
1
+ export { B as BaseSequencer, V as VitestPlugin, c as createVitest, s as startVitest } from './chunk-vite-node-externalize.3035bd5b.mjs';
2
+ export { V as VitestRunner } from './chunk-runtime-mocker.d9690273.mjs';
3
+ import './chunk-constants.6196597b.mjs';
6
4
  import 'tty';
5
+ import 'url';
6
+ import 'path';
7
+ import './chunk-integrations-coverage.99c020eb.mjs';
7
8
  import 'local-pkg';
8
- import './chunk-integrations-coverage.d205bd87.mjs';
9
+ import './chunk-env-node.ceb43f1c.mjs';
10
+ import 'console';
11
+ import './chunk-mock-date.f63a5ff2.mjs';
9
12
  import 'vite';
10
- import 'url';
11
13
  import 'process';
12
14
  import 'fs';
13
- import './chunk-constants.d3f8437b.mjs';
14
15
  import 'os';
15
16
  import 'util';
16
17
  import 'stream';
17
18
  import 'events';
18
19
  import './vendor-_commonjsHelpers.4da45ef5.mjs';
19
- import './chunk-vite-node-client.d1ead698.mjs';
20
+ import './chunk-vite-node-client.998e04d0.mjs';
20
21
  import 'module';
21
22
  import 'vm';
22
- import './chunk-vite-node-utils.d8e5ff7b.mjs';
23
+ import './chunk-vite-node-utils.8a9b3014.mjs';
23
24
  import 'assert';
24
25
  import 'debug';
26
+ import 'perf_hooks';
25
27
  import 'worker_threads';
26
28
  import 'tinypool';
27
- import 'perf_hooks';
28
- import './chunk-utils-source-map.2a082ffd.mjs';
29
+ import './chunk-utils-source-map.a1647f5f.mjs';
29
30
  import './chunk-utils-timers.b48455ed.mjs';
30
31
  import 'crypto';
31
- import './vendor-index.9d9196cc.mjs';
32
- import './vendor-index.29636037.mjs';
33
- import './chunk-magic-string.efe26975.mjs';
32
+ import './vendor-index.13e3bda3.mjs';
33
+ import './vendor-index.731a22f2.mjs';
34
+ import './chunk-magic-string.56b2b543.mjs';
35
+ import 'strip-literal';
34
36
  import 'readline';
35
37
  import './vendor-index.ae96af6e.mjs';
36
- import './chunk-utils-global.fa20c2f6.mjs';
package/dist/suite.mjs CHANGED
@@ -1,16 +1,16 @@
1
1
  import 'util';
2
- import './chunk-mock-date.debe9954.mjs';
3
- export { e as clearCollectorContext, o as createSuiteHooks, f as defaultSuite, d as describe, g as getCurrentSuite, i as it, s as suite, t as test } from './chunk-runtime-chain.6e363ba2.mjs';
4
- import './chunk-utils-global.fa20c2f6.mjs';
2
+ import './chunk-mock-date.f63a5ff2.mjs';
3
+ export { b as bench, f as clearCollectorContext, q as createSuiteHooks, h as defaultSuite, d as describe, g as getCurrentSuite, i as it, s as suite, t as test } from './chunk-runtime-chain.8bfc559b.mjs';
5
4
  import 'path';
6
- import './vendor-picocolors.807856aa.mjs';
5
+ import './chunk-constants.6196597b.mjs';
7
6
  import 'tty';
7
+ import 'url';
8
8
  import 'local-pkg';
9
9
  import 'chai';
10
10
  import './vendor-_commonjsHelpers.4da45ef5.mjs';
11
- import './chunk-runtime-rpc.29488183.mjs';
11
+ import './chunk-runtime-rpc.48bd94e3.mjs';
12
12
  import './chunk-utils-timers.b48455ed.mjs';
13
13
  import 'fs';
14
- import './chunk-utils-source-map.2a082ffd.mjs';
14
+ import './chunk-utils-source-map.a1647f5f.mjs';
15
15
  import './spy.mjs';
16
16
  import 'tinyspy';