vitest 0.34.6 → 1.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/browser.d.ts +1 -1
  2. package/dist/browser.js +1 -1
  3. package/dist/child.js +21 -19
  4. package/dist/{chunk-api-setup.d65b007d.js → chunk-api-setup.0aeabd21.js} +1 -1
  5. package/dist/{chunk-install-pkg.6c4f388a.js → chunk-install-pkg.991b9ea3.js} +5 -4
  6. package/dist/{chunk-integrations-globals.5afac659.js → chunk-integrations-globals.c3c5e678.js} +4 -3
  7. package/dist/cli.js +11 -6
  8. package/dist/config.cjs +1 -2
  9. package/dist/config.d.ts +2 -3
  10. package/dist/config.js +1 -2
  11. package/dist/coverage.d.ts +1 -1
  12. package/dist/entry-vm.js +5 -4
  13. package/dist/entry.js +8 -4
  14. package/dist/environments.d.ts +1 -1
  15. package/dist/environments.js +1 -1
  16. package/dist/execute.d.ts +1 -1
  17. package/dist/index.d.ts +9 -10
  18. package/dist/index.js +4 -3
  19. package/dist/node.d.ts +2 -2
  20. package/dist/node.js +7 -6
  21. package/dist/{reporters-5f784f42.d.ts → reporters-7bd09217.d.ts} +165 -103
  22. package/dist/reporters.d.ts +1 -1
  23. package/dist/runners.d.ts +10 -10
  24. package/dist/runners.js +13 -12
  25. package/dist/suite-543d56bd.d.ts +10 -0
  26. package/dist/suite.d.ts +15 -1
  27. package/dist/suite.js +7 -1
  28. package/dist/vendor-benchmark.44931cfa.js +41 -0
  29. package/dist/{vendor-environments.7aba93d9.js → vendor-environments.e73c5410.js} +14 -2
  30. package/dist/{vendor-index.b271ebe4.js → vendor-index.1ca68bd5.js} +7 -5
  31. package/dist/{vendor-index.3e351f42.js → vendor-index.d36f5516.js} +5 -5
  32. package/dist/{vendor-index.7646b3af.js → vendor-index.f7fcd5e8.js} +2 -1
  33. package/dist/vendor-inspector.209edf5a.js +26 -0
  34. package/dist/{vendor-node.a7c48fe1.js → vendor-node.6fe91553.js} +413 -298
  35. package/dist/{vendor-vi.6873a1c1.js → vendor-vi.7f2b988f.js} +28 -53
  36. package/dist/vm.js +2 -2
  37. package/dist/worker.js +7 -4
  38. package/package.json +13 -12
  39. package/dist/vendor-inspector.47fc8cbb.js +0 -23
@@ -1,7 +1,7 @@
1
1
  import * as vite from 'vite';
2
2
  import { ViteDevServer, UserConfig as UserConfig$1, TransformResult as TransformResult$1, ServerOptions, DepOptimizationConfig, AliasOptions } from 'vite';
3
3
  import * as _vitest_runner from '@vitest/runner';
4
- import { File, Test as Test$1, Suite, TaskResultPack, Task, CancelReason, TaskCustom, SequenceHooks, SequenceSetupFiles } from '@vitest/runner';
4
+ import { File, Test as Test$1, Suite, TaskResultPack, Task, CancelReason, Custom, SequenceHooks, SequenceSetupFiles } from '@vitest/runner';
5
5
  import { RawSourceMap, FetchResult, ViteNodeResolveId, ModuleCacheMap, ViteNodeServerOptions } from 'vite-node';
6
6
  import { SnapshotResult, SnapshotStateOptions, SnapshotState } from '@vitest/snapshot';
7
7
  import { ExpectStatic } from '@vitest/expect';
@@ -447,6 +447,39 @@ declare class Typechecker {
447
447
  getTestPacks(): TaskResultPack[];
448
448
  }
449
449
 
450
+ interface ErrorOptions {
451
+ type?: string;
452
+ fullStack?: boolean;
453
+ project?: WorkspaceProject;
454
+ }
455
+ declare class Logger {
456
+ ctx: Vitest;
457
+ console: Console;
458
+ outputStream: NodeJS.WriteStream & {
459
+ fd: 1;
460
+ };
461
+ errorStream: NodeJS.WriteStream & {
462
+ fd: 2;
463
+ };
464
+ logUpdate: ((...text: string[]) => void) & {
465
+ clear(): void;
466
+ done(): void;
467
+ };
468
+ private _clearScreenPending;
469
+ constructor(ctx: Vitest, console?: Console);
470
+ log(...args: any[]): void;
471
+ error(...args: any[]): void;
472
+ warn(...args: any[]): void;
473
+ clearFullScreen(message: string): void;
474
+ clearScreen(message: string, force?: boolean): void;
475
+ private _clearScreen;
476
+ printError(err: unknown, options?: ErrorOptions): Promise<void>;
477
+ printNoTestFound(filters?: string[]): void;
478
+ printBanner(): void;
479
+ printUnhandledErrors(errors: unknown[]): Promise<void>;
480
+ printSourceTypeErrors(errors: TypeCheckError[]): Promise<void>;
481
+ }
482
+
450
483
  declare class WorkspaceProject {
451
484
  path: string | number;
452
485
  ctx: Vitest;
@@ -460,9 +493,14 @@ declare class WorkspaceProject {
460
493
  closingPromise: Promise<unknown> | undefined;
461
494
  browserProvider: BrowserProvider | undefined;
462
495
  testFilesList: string[];
496
+ private _globalSetupInit;
497
+ private _globalSetups;
463
498
  constructor(path: string | number, ctx: Vitest);
464
499
  getName(): string;
465
500
  isCore(): boolean;
501
+ initializeGlobalSetup(): Promise<void>;
502
+ teardownGlobalSetup(): Promise<void>;
503
+ get logger(): Logger;
466
504
  getModulesByFilepath(file: string): Set<vite.ModuleNode>;
467
505
  getModuleById(id: string): vite.ModuleNode | undefined;
468
506
  getSourceMapModuleById(id: string): rollup.SourceMap | null | undefined;
@@ -534,10 +572,17 @@ interface BrowserConfigOptions {
534
572
  * @experimental
535
573
  */
536
574
  slowHijackESM?: boolean;
575
+ /**
576
+ * Isolate test environment after each test
577
+ *
578
+ * @default true
579
+ */
580
+ isolate?: boolean;
537
581
  }
538
582
  interface ResolvedBrowserOptions extends BrowserConfigOptions {
539
583
  enabled: boolean;
540
584
  headless: boolean;
585
+ isolate: boolean;
541
586
  api: ApiConfig;
542
587
  }
543
588
 
@@ -626,39 +671,6 @@ declare class StateManager {
626
671
  cancelFiles(files: string[], root: string): void;
627
672
  }
628
673
 
629
- interface ErrorOptions {
630
- type?: string;
631
- fullStack?: boolean;
632
- project?: WorkspaceProject;
633
- }
634
- declare class Logger {
635
- ctx: Vitest;
636
- console: Console;
637
- outputStream: NodeJS.WriteStream & {
638
- fd: 1;
639
- };
640
- errorStream: NodeJS.WriteStream & {
641
- fd: 2;
642
- };
643
- logUpdate: ((...text: string[]) => void) & {
644
- clear(): void;
645
- done(): void;
646
- };
647
- private _clearScreenPending;
648
- constructor(ctx: Vitest, console?: Console);
649
- log(...args: any[]): void;
650
- error(...args: any[]): void;
651
- warn(...args: any[]): void;
652
- clearFullScreen(message: string): void;
653
- clearScreen(message: string, force?: boolean): void;
654
- private _clearScreen;
655
- printError(err: unknown, options?: ErrorOptions): Promise<void>;
656
- printNoTestFound(filters?: string[]): void;
657
- printBanner(): void;
658
- printUnhandledErrors(errors: unknown[]): Promise<void>;
659
- printSourceTypeErrors(errors: TypeCheckError[]): Promise<void>;
660
- }
661
-
662
674
  interface SuiteResultCache {
663
675
  failed: boolean;
664
676
  duration: number;
@@ -756,6 +768,7 @@ declare class Vitest {
756
768
  private getTestDependencies;
757
769
  filterTestsBySource(specs: WorkspaceSpec[]): Promise<WorkspaceSpec[]>;
758
770
  getProjectsByTestFile(file: string): WorkspaceSpec[];
771
+ initializeGlobalSetup(paths: WorkspaceSpec[]): Promise<void>;
759
772
  runFiles(paths: WorkspaceSpec[]): Promise<void>;
760
773
  cancelCurrentRun(reason: CancelReason): Promise<void>;
761
774
  rerunFiles(files?: string[], trigger?: string): Promise<void>;
@@ -1107,7 +1120,7 @@ type BirpcFn<T> = PromisifyFn<T> & {
1107
1120
  */
1108
1121
  asEvent(...args: ArgumentsType<T>): void;
1109
1122
  };
1110
- type BirpcReturn<RemoteFunctions, LocalFunctions = {}> = {
1123
+ type BirpcReturn<RemoteFunctions, LocalFunctions = Record<string, never>> = {
1111
1124
  [K in keyof RemoteFunctions]: BirpcFn<RemoteFunctions[K]>;
1112
1125
  } & {
1113
1126
  $functions: LocalFunctions;
@@ -1170,7 +1183,7 @@ type ResolveIdFunction = (id: string, importer?: string) => Promise<ViteNodeReso
1170
1183
  interface AfterSuiteRunMeta {
1171
1184
  coverage?: unknown;
1172
1185
  }
1173
- type WorkerRPC = BirpcReturn<RuntimeRPC>;
1186
+ type WorkerRPC = BirpcReturn<RuntimeRPC, RunnerRPC>;
1174
1187
  interface WorkerGlobalState {
1175
1188
  ctx: ContextRPC;
1176
1189
  config: ResolvedConfig;
@@ -1186,6 +1199,7 @@ interface WorkerGlobalState {
1186
1199
  environment: number;
1187
1200
  prepare: number;
1188
1201
  };
1202
+ isChildProcess?: boolean;
1189
1203
  }
1190
1204
 
1191
1205
  type TransformResult = string | Partial<TransformResult$1> | undefined | null | void;
@@ -1510,7 +1524,7 @@ interface BenchmarkUserOptions {
1510
1524
  */
1511
1525
  outputFile?: string | (Partial<Record<BenchmarkBuiltinReporters, string>> & Record<string, string>);
1512
1526
  }
1513
- interface Benchmark extends TaskCustom {
1527
+ interface Benchmark extends Custom {
1514
1528
  meta: {
1515
1529
  benchmark: true;
1516
1530
  result?: TaskResult;
@@ -1530,9 +1544,83 @@ type BenchmarkAPI = ChainableFunction<'skip' | 'only' | 'todo', [
1530
1544
  runIf(condition: any): BenchmarkAPI;
1531
1545
  };
1532
1546
 
1547
+ type Pool = 'browser' | 'threads' | 'forks' | 'vmThreads';
1548
+ interface PoolOptions {
1549
+ /**
1550
+ * Run tests in `node:worker_threads`.
1551
+ *
1552
+ * Test isolation (when enabled) is done by spawning a new thread for each test file.
1553
+ *
1554
+ * This pool is used by default.
1555
+ */
1556
+ threads?: ThreadsOptions & WorkerContextOptions;
1557
+ /**
1558
+ * Run tests in `node:child_process` using [`fork()`](https://nodejs.org/api/child_process.html#child_processforkmodulepath-args-options)
1559
+ *
1560
+ * Test isolation (when enabled) is done by spawning a new child process for each test file.
1561
+ */
1562
+ forks?: ForksOptions & WorkerContextOptions;
1563
+ /**
1564
+ * Run tests in isolated `node:vm`.
1565
+ * Test files are run parallel using `node:worker_threads`.
1566
+ *
1567
+ * This makes tests run faster, but VM module is unstable. Your tests might leak memory.
1568
+ */
1569
+ vmThreads?: ThreadsOptions & VmOptions;
1570
+ }
1571
+ interface ThreadsOptions {
1572
+ /** Minimum amount of threads to use */
1573
+ minThreads?: number;
1574
+ /** Maximum amount of threads to use */
1575
+ maxThreads?: number;
1576
+ /**
1577
+ * Run tests inside a single thread.
1578
+ *
1579
+ * @default false
1580
+ */
1581
+ singleThread?: boolean;
1582
+ /**
1583
+ * Use Atomics to synchronize threads
1584
+ *
1585
+ * This can improve performance in some cases, but might cause segfault in older Node versions.
1586
+ *
1587
+ * @default false
1588
+ */
1589
+ useAtomics?: boolean;
1590
+ }
1591
+ interface ForksOptions {
1592
+ /** Minimum amount of child processes to use */
1593
+ minForks?: number;
1594
+ /** Maximum amount of child processes to use */
1595
+ maxForks?: number;
1596
+ /**
1597
+ * Run tests inside a single fork.
1598
+ *
1599
+ * @default false
1600
+ */
1601
+ singleFork?: boolean;
1602
+ }
1603
+ interface WorkerContextOptions {
1604
+ /**
1605
+ * Isolate test environment by recycling `worker_threads` or `child_process` after each test
1606
+ *
1607
+ * @default true
1608
+ */
1609
+ isolate?: boolean;
1610
+ }
1611
+ interface VmOptions {
1612
+ /**
1613
+ * Specifies the memory limit for `worker_thread` or `child_processe` before they are recycled.
1614
+ * If you see memory leaks, try to tinker this value.
1615
+ */
1616
+ memoryLimit?: string | number;
1617
+ /** Isolation is always enabled */
1618
+ isolate?: true;
1619
+ }
1620
+
1533
1621
  type BuiltinEnvironment = 'node' | 'jsdom' | 'happy-dom' | 'edge-runtime';
1534
1622
  type VitestEnvironment = BuiltinEnvironment | (string & Record<never, never>);
1535
- type VitestPool = 'browser' | 'threads' | 'child_process' | 'experimentalVmThreads';
1623
+
1536
1624
  type CSSModuleScopeStrategy = 'stable' | 'scoped' | 'non-scoped';
1537
1625
  type ApiConfig = Pick<ServerOptions, 'port' | 'strictPort' | 'host' | 'middlewareMode'>;
1538
1626
 
@@ -1618,7 +1706,7 @@ interface DepsOptions {
1618
1706
  *
1619
1707
  * These module will have a default export equal to the path to the asset, if no query is specified.
1620
1708
  *
1621
- * **At the moment, this option only works with `experimentalVmThreads` pool.**
1709
+ * **At the moment, this option only works with `{ pool: 'vmThreads' }`.**
1622
1710
  *
1623
1711
  * @default true
1624
1712
  */
@@ -1628,7 +1716,7 @@ interface DepsOptions {
1628
1716
  *
1629
1717
  * If CSS files are disabled with `css` options, this option will just silence UNKNOWN_EXTENSION errors.
1630
1718
  *
1631
- * **At the moment, this option only works with `experimentalVmThreads` pool.**
1719
+ * **At the moment, this option only works with `{ pool: 'vmThreads' }`.**
1632
1720
  *
1633
1721
  * @default true
1634
1722
  */
@@ -1638,7 +1726,7 @@ interface DepsOptions {
1638
1726
  *
1639
1727
  * By default, files inside `node_modules` are externalized and not transformed.
1640
1728
  *
1641
- * **At the moment, this option only works with `experimentalVmThreads` pool.**
1729
+ * **At the moment, this option only works with `{ pool: 'vmThreads' }`.**
1642
1730
  *
1643
1731
  * @default []
1644
1732
  */
@@ -1773,6 +1861,18 @@ interface InlineConfig {
1773
1861
  * ]
1774
1862
  */
1775
1863
  environmentMatchGlobs?: [string, VitestEnvironment][];
1864
+ /**
1865
+ * Pool used to run tests in.
1866
+ *
1867
+ * Supports 'threads', 'forks', 'vmThreads'
1868
+ *
1869
+ * @default 'threads'
1870
+ */
1871
+ pool?: Omit<Pool, 'browser'>;
1872
+ /**
1873
+ * Pool options
1874
+ */
1875
+ poolOptions?: PoolOptions;
1776
1876
  /**
1777
1877
  * Automatically assign pool based on globs. The first match will be used.
1778
1878
  *
@@ -1780,13 +1880,13 @@ interface InlineConfig {
1780
1880
  *
1781
1881
  * @default []
1782
1882
  * @example [
1783
- * // all tests in "child_process" directory will run using "child_process" API
1784
- * ['tests/child_process/**', 'child_process'],
1785
- * // all other tests will run based on "threads" option, if you didn't specify other globs
1883
+ * // all tests in "forks" directory will run using "poolOptions.forks" API
1884
+ * ['tests/forks/**', 'forks'],
1885
+ * // all other tests will run based on "poolOptions.threads" option, if you didn't specify other globs
1786
1886
  * // ...
1787
1887
  * ]
1788
1888
  */
1789
- poolMatchGlobs?: [string, Omit<VitestPool, 'browser'>][];
1889
+ poolMatchGlobs?: [string, Omit<Pool, 'browser'>][];
1790
1890
  /**
1791
1891
  * Update snapshot
1792
1892
  *
@@ -1815,45 +1915,6 @@ interface InlineConfig {
1815
1915
  * Also definable individually per reporter by using an object instead.
1816
1916
  */
1817
1917
  outputFile?: string | (Partial<Record<BuiltinReporters, string>> & Record<string, string>);
1818
- /**
1819
- * Run tests using VM context in a worker pool.
1820
- *
1821
- * This makes tests run faster, but VM module is unstable. Your tests might leak memory.
1822
- */
1823
- experimentalVmThreads?: boolean;
1824
- /**
1825
- * Specifies the memory limit for workers before they are recycled.
1826
- * If you see your worker leaking memory, try to tinker this value.
1827
- *
1828
- * This only has effect on workers that run tests in VM context.
1829
- */
1830
- experimentalVmWorkerMemoryLimit?: string | number;
1831
- /**
1832
- * Enable multi-threading
1833
- *
1834
- * @default true
1835
- */
1836
- threads?: boolean;
1837
- /**
1838
- * Maximum number of threads
1839
- *
1840
- * @default available CPUs
1841
- */
1842
- maxThreads?: number;
1843
- /**
1844
- * Minimum number of threads
1845
- *
1846
- * @default available CPUs
1847
- */
1848
- minThreads?: number;
1849
- /**
1850
- * Use Atomics to synchronize threads
1851
- *
1852
- * This can improve performance in some cases, but might cause segfault in older Node versions.
1853
- *
1854
- * @default false
1855
- */
1856
- useAtomics?: boolean;
1857
1918
  /**
1858
1919
  * Default timeout of a test in milliseconds
1859
1920
  *
@@ -1904,18 +1965,6 @@ interface InlineConfig {
1904
1965
  * @default []
1905
1966
  */
1906
1967
  forceRerunTriggers?: string[];
1907
- /**
1908
- * Isolate environment for each test file
1909
- *
1910
- * @default true
1911
- */
1912
- isolate?: boolean;
1913
- /**
1914
- * Run tests inside a single thread.
1915
- *
1916
- * @default false
1917
- */
1918
- singleThread?: boolean;
1919
1968
  /**
1920
1969
  * Coverage options
1921
1970
  */
@@ -1988,7 +2037,7 @@ interface InlineConfig {
1988
2037
  /**
1989
2038
  * Format options for snapshot testing.
1990
2039
  */
1991
- snapshotFormat?: PrettyFormatOptions;
2040
+ snapshotFormat?: Omit<PrettyFormatOptions, 'plugins'>;
1992
2041
  /**
1993
2042
  * Path to a module which has a default export of diff config.
1994
2043
  */
@@ -2080,13 +2129,15 @@ interface InlineConfig {
2080
2129
  /**
2081
2130
  * Debug tests by opening `node:inspector` in worker / child process.
2082
2131
  * Provides similar experience as `--inspect` Node CLI argument.
2083
- * Requires `singleThread: true` OR `threads: false`.
2132
+ *
2133
+ * Requires `poolOptions.threads.singleThread: true` OR `poolOptions.forks.singleFork: true`.
2084
2134
  */
2085
2135
  inspect?: boolean;
2086
2136
  /**
2087
2137
  * Debug tests by opening `node:inspector` in worker / child process and wait for debugger to connect.
2088
2138
  * Provides similar experience as `--inspect-brk` Node CLI argument.
2089
- * Requires `singleThread: true` OR `threads: false`.
2139
+ *
2140
+ * Requires `poolOptions.threads.singleThread: true` OR `poolOptions.forks.singleFork: true`.
2090
2141
  */
2091
2142
  inspectBrk?: boolean;
2092
2143
  /**
@@ -2168,7 +2219,7 @@ interface UserConfig extends InlineConfig {
2168
2219
  */
2169
2220
  shard?: string;
2170
2221
  }
2171
- interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters' | 'browser' | 'coverage' | 'testNamePattern' | 'related' | 'api' | 'reporters' | 'resolveSnapshotPath' | 'benchmark' | 'shard' | 'cache' | 'sequence' | 'typecheck' | 'runner' | 'experimentalVmWorkerMemoryLimit'> {
2222
+ interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters' | 'browser' | 'coverage' | 'testNamePattern' | 'related' | 'api' | 'reporters' | 'resolveSnapshotPath' | 'benchmark' | 'shard' | 'cache' | 'sequence' | 'typecheck' | 'runner' | 'poolOptions'> {
2172
2223
  mode: VitestRunMode;
2173
2224
  base?: string;
2174
2225
  config?: string;
@@ -2178,6 +2229,8 @@ interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters'
2178
2229
  coverage: ResolvedCoverageOptions;
2179
2230
  snapshotOptions: SnapshotStateOptions;
2180
2231
  browser: ResolvedBrowserOptions;
2232
+ pool: Pool;
2233
+ poolOptions?: PoolOptions;
2181
2234
  reporters: (Reporter | BuiltinReporters)[];
2182
2235
  defines: Record<string, any>;
2183
2236
  api?: ApiConfig;
@@ -2201,9 +2254,8 @@ interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters'
2201
2254
  };
2202
2255
  typecheck: TypecheckConfig;
2203
2256
  runner?: string;
2204
- experimentalVmWorkerMemoryLimit?: number | null;
2205
2257
  }
2206
- type ProjectConfig = Omit<UserConfig, 'sequencer' | 'shard' | 'watch' | 'run' | 'cache' | 'update' | 'reporters' | 'outputFile' | 'maxThreads' | 'minThreads' | 'useAtomics' | 'teardownTimeout' | 'silent' | 'watchExclude' | 'forceRerunTriggers' | 'testNamePattern' | 'ui' | 'open' | 'uiBase' | 'snapshotFormat' | 'resolveSnapshotPath' | 'passWithNoTests' | 'onConsoleLog' | 'dangerouslyIgnoreUnhandledErrors' | 'slowTestThreshold' | 'inspect' | 'inspectBrk' | 'deps' | 'coverage'> & {
2258
+ type ProjectConfig = Omit<UserConfig, 'sequencer' | 'shard' | 'watch' | 'run' | 'cache' | 'update' | 'reporters' | 'outputFile' | 'pool' | 'poolOptions' | 'teardownTimeout' | 'silent' | 'watchExclude' | 'forceRerunTriggers' | 'testNamePattern' | 'ui' | 'open' | 'uiBase' | 'snapshotFormat' | 'resolveSnapshotPath' | 'passWithNoTests' | 'onConsoleLog' | 'dangerouslyIgnoreUnhandledErrors' | 'slowTestThreshold' | 'inspect' | 'inspectBrk' | 'deps' | 'coverage'> & {
2207
2259
  sequencer?: Omit<SequenceOptions, 'sequencer' | 'seed'>;
2208
2260
  deps?: Omit<DepsOptions, 'registerNodeLoader' | 'moduleDirectories'>;
2209
2261
  };
@@ -2223,6 +2275,16 @@ declare module 'vite' {
2223
2275
  }
2224
2276
  }
2225
2277
 
2278
+ declare global {
2279
+ namespace Chai {
2280
+ interface Assertion {
2281
+ containSubset(expected: any): Assertion;
2282
+ }
2283
+ interface Assert {
2284
+ containSubset(val: any, exp: any, msg?: string): void;
2285
+ }
2286
+ }
2287
+ }
2226
2288
  declare module '@vitest/expect' {
2227
2289
  interface MatcherState {
2228
2290
  environment: VitestEnvironment;
@@ -2295,4 +2357,4 @@ type Context = RootAndTarget & {
2295
2357
  lastActivePath?: string;
2296
2358
  };
2297
2359
 
2298
- export { Nullable as $, AfterSuiteRunMeta as A, BaseCoverageOptions as B, CoverageV8Options as C, DepsOptimizationOptions as D, Environment as E, FakeTimerInstallOpts as F, TypecheckConfig as G, HappyDOMOptions as H, InlineConfig as I, JSDOMOptions as J, RuntimeRPC as K, RunnerRPC as L, MockFactoryWithHelper as M, ContextTestEnvironment as N, ResolvedTestEnvironment as O, ProjectConfig as P, ContextRPC as Q, ResolvedConfig as R, WorkerContext as S, TestSequencer as T, UserConfig as U, VitestRunMode as V, WorkspaceSpec as W, ResolveIdFunction as X, WorkerRPC as Y, WorkerGlobalState as Z, Awaitable as _, ResolvedCoverageOptions as a, Arrayable as a0, ArgumentsType$1 as a1, MutableArray as a2, Constructable as a3, ModuleCache as a4, EnvironmentReturn as a5, VmEnvironmentReturn as a6, OnServerRestartHandler as a7, ReportContext as a8, CoverageReporter as a9, CoverageIstanbulOptions as aa, CustomProviderOptions as ab, BenchmarkUserOptions as ac, Benchmark as ad, BenchmarkResult as ae, BenchFunction as af, PendingSuiteMock as ag, MockFactory as ah, MockMap as ai, DefaultReporter as aj, BasicReporter as ak, DotReporter as al, JsonReporter$1 as am, VerboseReporter as an, TapReporter as ao, JUnitReporter as ap, TapFlatReporter as aq, HangingProcessReporter as ar, BaseReporter as as, ReportersMap as at, BuiltinReporters as au, BenchmarkReportsMap as av, BenchmarkBuiltinReporters as aw, Vitest as b, WorkspaceProject as c, TestSequencerConstructor as d, CoverageOptions as e, CoverageProvider as f, CoverageProviderModule as g, BenchmarkAPI as h, RuntimeConfig as i, UserConsoleLog as j, ModuleGraphData as k, Reporter as l, RawErrsMap as m, TscErrorInfo as n, CollectLineNumbers as o, CollectLines as p, RootAndTarget as q, Context as r, startVitest as s, BuiltinEnvironment as t, VitestEnvironment as u, VitestPool as v, CSSModuleScopeStrategy as w, ApiConfig as x, EnvironmentOptions as y, TransformModePatterns as z };
2360
+ export { Nullable as $, AfterSuiteRunMeta as A, BaseCoverageOptions as B, CoverageV8Options as C, DepsOptimizationOptions as D, Environment as E, FakeTimerInstallOpts as F, TypecheckConfig as G, HappyDOMOptions as H, InlineConfig as I, JSDOMOptions as J, RuntimeRPC as K, RunnerRPC as L, MockFactoryWithHelper as M, ContextTestEnvironment as N, ResolvedTestEnvironment as O, ProjectConfig as P, ContextRPC as Q, ResolvedConfig as R, WorkerContext as S, TestSequencer as T, UserConfig as U, VitestRunMode as V, WorkspaceSpec as W, ResolveIdFunction as X, WorkerRPC as Y, WorkerGlobalState as Z, Awaitable as _, ResolvedCoverageOptions as a, Arrayable as a0, ArgumentsType$1 as a1, MutableArray as a2, Constructable as a3, ModuleCache as a4, EnvironmentReturn as a5, VmEnvironmentReturn as a6, OnServerRestartHandler as a7, ReportContext as a8, CoverageReporter as a9, CoverageIstanbulOptions as aa, CustomProviderOptions as ab, BenchmarkUserOptions as ac, Benchmark as ad, BenchmarkResult as ae, BenchFunction as af, BenchmarkAPI as ag, PendingSuiteMock as ah, MockFactory as ai, MockMap as aj, DefaultReporter as ak, BasicReporter as al, DotReporter as am, JsonReporter$1 as an, VerboseReporter as ao, TapReporter as ap, JUnitReporter as aq, TapFlatReporter as ar, HangingProcessReporter as as, BaseReporter as at, ReportersMap as au, BuiltinReporters as av, BenchmarkReportsMap as aw, BenchmarkBuiltinReporters as ax, Vitest as b, WorkspaceProject as c, TestSequencerConstructor as d, CoverageOptions as e, CoverageProvider as f, CoverageProviderModule as g, RuntimeConfig as h, UserConsoleLog as i, ModuleGraphData as j, Reporter as k, RawErrsMap as l, TscErrorInfo as m, CollectLineNumbers as n, CollectLines as o, RootAndTarget as p, Context as q, Pool as r, startVitest as s, PoolOptions as t, BuiltinEnvironment as u, VitestEnvironment as v, CSSModuleScopeStrategy as w, ApiConfig as x, EnvironmentOptions as y, TransformModePatterns as z };
@@ -1,4 +1,4 @@
1
- export { as as BaseReporter, ak as BasicReporter, aw as BenchmarkBuiltinReporters, av as BenchmarkReportsMap, au as BuiltinReporters, aj as DefaultReporter, al as DotReporter, ar as HangingProcessReporter, ap as JUnitReporter, am as JsonReporter, l as Reporter, at as ReportersMap, aq as TapFlatReporter, ao as TapReporter, an as VerboseReporter } from './reporters-5f784f42.js';
1
+ export { at as BaseReporter, al as BasicReporter, ax as BenchmarkBuiltinReporters, aw as BenchmarkReportsMap, av as BuiltinReporters, ak as DefaultReporter, am as DotReporter, as as HangingProcessReporter, aq as JUnitReporter, an as JsonReporter, k as Reporter, au as ReportersMap, ar as TapFlatReporter, ap as TapReporter, ao as VerboseReporter } from './reporters-7bd09217.js';
2
2
  import 'vite';
3
3
  import '@vitest/runner';
4
4
  import 'vite-node';
package/dist/runners.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { VitestRunner, VitestRunnerImportSource, Suite, Test, CancelReason, TestContext } from '@vitest/runner';
2
- import { R as ResolvedConfig } from './reporters-5f784f42.js';
1
+ import { VitestRunner, VitestRunnerImportSource, Suite, Test, CancelReason, Custom, TaskContext, ExtendedContext } from '@vitest/runner';
2
+ import { R as ResolvedConfig } from './reporters-7bd09217.js';
3
3
  import 'vite';
4
4
  import 'vite-node';
5
5
  import '@vitest/snapshot';
@@ -23,16 +23,16 @@ declare class VitestTestRunner implements VitestRunner {
23
23
  private cancelRun;
24
24
  constructor(config: ResolvedConfig);
25
25
  importFile(filepath: string, source: VitestRunnerImportSource): unknown;
26
- onBeforeRun(): void;
27
- onAfterRun(): Promise<void>;
26
+ onBeforeRunFiles(): void;
27
+ onAfterRunFiles(): Promise<void>;
28
28
  onAfterRunSuite(suite: Suite): void;
29
- onAfterRunTest(test: Test): void;
29
+ onAfterRunTask(test: Test): void;
30
30
  onCancel(_reason: CancelReason): void;
31
- onBeforeRunTest(test: Test): Promise<void>;
31
+ onBeforeRunTask(test: Test): Promise<void>;
32
32
  onBeforeRunSuite(suite: Suite): void;
33
- onBeforeTryTest(test: Test): void;
34
- onAfterTryTest(test: Test): void;
35
- extendTestContext(context: TestContext): TestContext;
33
+ onBeforeTryTask(test: Test): void;
34
+ onAfterTryTask(test: Test): void;
35
+ extendTaskContext<T extends Test | Custom>(context: TaskContext<T>): ExtendedContext<T>;
36
36
  }
37
37
 
38
38
  declare class NodeBenchmarkRunner implements VitestRunner {
@@ -41,7 +41,7 @@ declare class NodeBenchmarkRunner implements VitestRunner {
41
41
  constructor(config: ResolvedConfig);
42
42
  importFile(filepath: string, source: VitestRunnerImportSource): unknown;
43
43
  runSuite(suite: Suite): Promise<void>;
44
- runTest(): Promise<void>;
44
+ runTask(): Promise<void>;
45
45
  }
46
46
 
47
47
  export { NodeBenchmarkRunner, VitestTestRunner };
package/dist/runners.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { setState, GLOBAL_EXPECT, getState } from '@vitest/expect';
2
- import { g as getSnapshotClient, c as createExpect, v as vi, a as getBenchOptions, b as getBenchFn } from './vendor-vi.6873a1c1.js';
2
+ import { g as getSnapshotClient, c as createExpect, v as vi } from './vendor-vi.7f2b988f.js';
3
3
  import './vendor-index.29282562.js';
4
4
  import { a as rpc } from './vendor-rpc.cbd8e972.js';
5
5
  import { g as getFullName } from './vendor-tasks.f9d75aed.js';
@@ -8,6 +8,7 @@ import { getNames } from '@vitest/runner/utils';
8
8
  import { performance } from 'node:perf_hooks';
9
9
  import { updateTask } from '@vitest/runner';
10
10
  import { createDefer, getSafeTimers } from '@vitest/utils';
11
+ import { a as getBenchOptions, g as getBenchFn } from './vendor-benchmark.44931cfa.js';
11
12
  import 'chai';
12
13
  import './vendor-_commonjsHelpers.7d1333e8.js';
13
14
  import '@vitest/snapshot';
@@ -32,11 +33,11 @@ class VitestTestRunner {
32
33
  this.workerState.moduleCache.delete(filepath);
33
34
  return this.__vitest_executor.executeId(filepath);
34
35
  }
35
- onBeforeRun() {
36
+ onBeforeRunFiles() {
36
37
  this.snapshotClient.clear();
37
38
  }
38
- async onAfterRun() {
39
- const result = await this.snapshotClient.resetCurrent();
39
+ async onAfterRunFiles() {
40
+ const result = await this.snapshotClient.finishCurrentRun();
40
41
  if (result)
41
42
  await rpc().snapshotSaved(result);
42
43
  }
@@ -44,7 +45,7 @@ class VitestTestRunner {
44
45
  if (this.config.logHeapUsage && typeof process !== "undefined")
45
46
  suite.result.heap = process.memoryUsage().heapUsed;
46
47
  }
47
- onAfterRunTest(test) {
48
+ onAfterRunTask(test) {
48
49
  this.snapshotClient.clearTest();
49
50
  if (this.config.logHeapUsage && typeof process !== "undefined")
50
51
  test.result.heap = process.memoryUsage().heapUsed;
@@ -53,7 +54,7 @@ class VitestTestRunner {
53
54
  onCancel(_reason) {
54
55
  this.cancelRun = true;
55
56
  }
56
- async onBeforeRunTest(test) {
57
+ async onBeforeRunTask(test) {
57
58
  const name = getNames(test).slice(1).join(" > ");
58
59
  if (this.cancelRun)
59
60
  test.mode = "skip";
@@ -62,14 +63,14 @@ class VitestTestRunner {
62
63
  return;
63
64
  }
64
65
  clearModuleMocks(this.config);
65
- await this.snapshotClient.setTest(test.file.filepath, name, this.workerState.config.snapshotOptions);
66
+ await this.snapshotClient.startCurrentRun(test.file.filepath, name, this.workerState.config.snapshotOptions);
66
67
  this.workerState.current = test;
67
68
  }
68
69
  onBeforeRunSuite(suite) {
69
70
  if (this.cancelRun)
70
71
  suite.mode = "skip";
71
72
  }
72
- onBeforeTryTest(test) {
73
+ onBeforeTryTask(test) {
73
74
  var _a;
74
75
  setState({
75
76
  assertionCalls: 0,
@@ -82,7 +83,7 @@ class VitestTestRunner {
82
83
  snapshotState: this.snapshotClient.snapshotState
83
84
  }, globalThis[GLOBAL_EXPECT]);
84
85
  }
85
- onAfterTryTest(test) {
86
+ onAfterTryTask(test) {
86
87
  const {
87
88
  assertionCalls,
88
89
  expectedAssertionsNumber,
@@ -96,12 +97,12 @@ class VitestTestRunner {
96
97
  if (isExpectingAssertions === true && assertionCalls === 0)
97
98
  throw isExpectingAssertionsError;
98
99
  }
99
- extendTestContext(context) {
100
+ extendTaskContext(context) {
100
101
  let _expect;
101
102
  Object.defineProperty(context, "expect", {
102
103
  get() {
103
104
  if (!_expect)
104
- _expect = createExpect(context.meta);
105
+ _expect = createExpect(context.task);
105
106
  return _expect;
106
107
  }
107
108
  });
@@ -240,7 +241,7 @@ class NodeBenchmarkRunner {
240
241
  async runSuite(suite) {
241
242
  await runBenchmarkSuite(suite, this);
242
243
  }
243
- async runTest() {
244
+ async runTask() {
244
245
  throw new Error("`test()` and `it()` is only available in test mode.");
245
246
  }
246
247
  }
@@ -0,0 +1,10 @@
1
+ import { Custom } from '@vitest/runner';
2
+ import '@vitest/runner/utils';
3
+ import { af as BenchFunction, ag as BenchmarkAPI } from './reporters-7bd09217.js';
4
+ import { Options } from 'tinybench';
5
+
6
+ declare function getBenchOptions(key: Custom): Options;
7
+ declare function getBenchFn(key: Custom): BenchFunction;
8
+ declare const bench: BenchmarkAPI;
9
+
10
+ export { getBenchOptions as a, bench as b, getBenchFn as g };
package/dist/suite.d.ts CHANGED
@@ -1,3 +1,17 @@
1
- export { getCurrentSuite, getFn, setFn } from '@vitest/runner';
1
+ export { createTaskCollector, getCurrentSuite, getFn, setFn } from '@vitest/runner';
2
2
  export { createChainable } from '@vitest/runner/utils';
3
+ export { g as getBenchFn, a as getBenchOptions } from './suite-543d56bd.js';
4
+ import './reporters-7bd09217.js';
5
+ import 'vite';
6
+ import 'vite-node';
7
+ import '@vitest/snapshot';
8
+ import '@vitest/expect';
3
9
  import '@vitest/utils';
10
+ import 'tinybench';
11
+ import 'vite-node/client';
12
+ import '@vitest/snapshot/manager';
13
+ import 'vite-node/server';
14
+ import 'node:worker_threads';
15
+ import 'rollup';
16
+ import 'node:fs';
17
+ import 'chai';
package/dist/suite.js CHANGED
@@ -1,2 +1,8 @@
1
- export { getCurrentSuite, getFn, setFn } from '@vitest/runner';
1
+ export { createTaskCollector, getCurrentSuite, getFn, setFn } from '@vitest/runner';
2
2
  export { createChainable } from '@vitest/runner/utils';
3
+ export { g as getBenchFn, a as getBenchOptions } from './vendor-benchmark.44931cfa.js';
4
+ import '@vitest/utils';
5
+ import './vendor-index.29282562.js';
6
+ import 'pathe';
7
+ import 'std-env';
8
+ import './vendor-global.97e4527c.js';