vitest 1.0.0-beta.2 → 1.0.0-beta.4

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 (53) hide show
  1. package/LICENSE.md +17 -29
  2. package/dist/browser.d.ts +1 -2
  3. package/dist/browser.js +3 -3
  4. package/dist/child.js +13 -7
  5. package/dist/{chunk-api-setup.5d9a93c7.js → chunk-api-setup.6d19ab38.js} +6 -4
  6. package/dist/{chunk-install-pkg.43d58972.js → chunk-install-pkg.e1d6323e.js} +12 -14
  7. package/dist/{chunk-integrations-globals.9df12d91.js → chunk-integrations-globals.2b099e04.js} +6 -6
  8. package/dist/{chunk-node-git.2f1df48f.js → chunk-node-git.6c12e560.js} +1 -1
  9. package/dist/cli-wrapper.js +1 -1
  10. package/dist/cli.js +16 -20
  11. package/dist/config.cjs +1 -0
  12. package/dist/config.d.ts +2 -3
  13. package/dist/config.js +1 -0
  14. package/dist/coverage.d.ts +1 -2
  15. package/dist/coverage.js +2 -2
  16. package/dist/entry-vm.js +8 -8
  17. package/dist/entry.js +8 -8
  18. package/dist/environments.d.ts +1 -2
  19. package/dist/environments.js +1 -13
  20. package/dist/execute.d.ts +2 -3
  21. package/dist/execute.js +1 -2
  22. package/dist/index.d.ts +232 -59
  23. package/dist/index.js +7 -7
  24. package/dist/node.d.ts +10 -4
  25. package/dist/node.js +16 -18
  26. package/dist/{reporters-d10f25e1.d.ts → reporters-50c2bd49.d.ts} +100 -35
  27. package/dist/reporters.d.ts +1 -2
  28. package/dist/reporters.js +3 -3
  29. package/dist/runners.d.ts +3 -3
  30. package/dist/runners.js +37 -41
  31. package/dist/{suite-919dd548.d.ts → suite-ad69b7cd.d.ts} +1 -1
  32. package/dist/suite.d.ts +2 -3
  33. package/dist/suite.js +3 -3
  34. package/dist/{vendor-benchmark.44931cfa.js → vendor-benchmark.b6befc50.js} +1 -1
  35. package/dist/{vendor-environments.094f240c.js → vendor-environments.dcc4a34e.js} +4 -37
  36. package/dist/{vendor-execute.07d1a420.js → vendor-execute.157302d6.js} +3 -3
  37. package/dist/vendor-global.c3664e75.js +14 -0
  38. package/dist/{vendor-index.29282562.js → vendor-index.2b92937b.js} +1 -1
  39. package/dist/{vendor-index.d36f5516.js → vendor-index.57925a34.js} +8 -3
  40. package/dist/{vendor-index.68ecee35.js → vendor-index.72df742e.js} +11 -4
  41. package/dist/{vendor-index.e006069f.js → vendor-index.8efe7746.js} +371 -371
  42. package/dist/{vendor-index.0b5b3600.js → vendor-loader.9c966f23.js} +36 -9
  43. package/dist/{vendor-node.e5a35bfe.js → vendor-node.65461b16.js} +2660 -2021
  44. package/dist/{vendor-reporters.2953082e.js → vendor-reporters.d24d80a4.js} +42 -25
  45. package/dist/{vendor-rpc.cbd8e972.js → vendor-rpc.171f65fb.js} +1 -1
  46. package/dist/{vendor-run-once.3e5ef7d7.js → vendor-run-once.fb836747.js} +1 -1
  47. package/dist/{vendor-vi.d30b47ae.js → vendor-vi.3baa7c4a.js} +32 -35
  48. package/dist/vm.js +14 -8
  49. package/dist/worker.js +14 -8
  50. package/package.json +12 -28
  51. package/dist/loader.js +0 -100
  52. package/dist/vendor-global.97e4527c.js +0 -9
  53. package/dist/vendor-index.98139333.js +0 -129
@@ -12,7 +12,6 @@ import { ViteNodeRunner } from 'vite-node/client';
12
12
  import { SnapshotManager } from '@vitest/snapshot/manager';
13
13
  import { ViteNodeServer } from 'vite-node/server';
14
14
  import { MessagePort } from 'node:worker_threads';
15
- import * as rollup from 'rollup';
16
15
  import { Stats } from 'node:fs';
17
16
  import * as chai from 'chai';
18
17
 
@@ -402,26 +401,29 @@ declare class TypeCheckError extends Error {
402
401
  name: string;
403
402
  constructor(message: string, stacks: ParsedStack[]);
404
403
  }
405
- interface ErrorsCache {
404
+ interface TypecheckResults {
406
405
  files: File[];
407
406
  sourceErrors: TypeCheckError[];
407
+ time: number;
408
408
  }
409
409
  type Callback<Args extends Array<any> = []> = (...args: Args) => Awaitable<void>;
410
410
  declare class Typechecker {
411
411
  protected ctx: WorkspaceProject;
412
- protected files: string[];
413
412
  private _onParseStart?;
414
413
  private _onParseEnd?;
415
414
  private _onWatcherRerun?;
416
415
  private _result;
416
+ private _startTime;
417
417
  private _output;
418
418
  private _tests;
419
419
  private tempConfigPath?;
420
420
  private allowJs?;
421
421
  private process?;
422
- constructor(ctx: WorkspaceProject, files: string[]);
422
+ protected files: string[];
423
+ constructor(ctx: WorkspaceProject);
424
+ setFiles(files: string[]): void;
423
425
  onParseStart(fn: Callback): void;
424
- onParseEnd(fn: Callback<[ErrorsCache]>): void;
426
+ onParseEnd(fn: Callback<[TypecheckResults]>): void;
425
427
  onWatcherRerun(fn: Callback): void;
426
428
  protected collectFileTests(filepath: string): Promise<FileInformation | null>;
427
429
  protected getFiles(): string[];
@@ -430,6 +432,7 @@ declare class Typechecker {
430
432
  protected prepareResults(output: string): Promise<{
431
433
  files: File[];
432
434
  sourceErrors: TypeCheckError[];
435
+ time: number;
433
436
  }>;
434
437
  protected parseTscLikeOutput(output: string): Promise<Map<string, {
435
438
  error: TypeCheckError;
@@ -442,7 +445,7 @@ declare class Typechecker {
442
445
  getExitCode(): number | false;
443
446
  getOutput(): string;
444
447
  start(): Promise<void>;
445
- getResult(): ErrorsCache;
448
+ getResult(): TypecheckResults;
446
449
  getTestFiles(): File[];
447
450
  getTestPacks(): TaskResultPack[];
448
451
  }
@@ -493,18 +496,20 @@ declare class WorkspaceProject {
493
496
  closingPromise: Promise<unknown> | undefined;
494
497
  browserProvider: BrowserProvider | undefined;
495
498
  testFilesList: string[];
496
- private _globalSetupInit;
497
499
  private _globalSetups;
500
+ private _provided;
498
501
  constructor(path: string | number, ctx: Vitest);
499
502
  getName(): string;
500
503
  isCore(): boolean;
504
+ provide: (key: string, value: unknown) => void;
505
+ getProvidedContext(): ProvidedContext;
501
506
  initializeGlobalSetup(): Promise<void>;
502
507
  teardownGlobalSetup(): Promise<void>;
503
508
  get logger(): Logger;
504
509
  getModulesByFilepath(file: string): Set<vite.ModuleNode>;
505
510
  getModuleById(id: string): vite.ModuleNode | undefined;
506
- getSourceMapModuleById(id: string): rollup.SourceMap | null | undefined;
507
- getBrowserSourceMapModuleById(id: string): rollup.SourceMap | null | undefined;
511
+ getSourceMapModuleById(id: string): RawSourceMap | null | undefined;
512
+ getBrowserSourceMapModuleById(id: string): RawSourceMap | null | undefined;
508
513
  get reporters(): Reporter[];
509
514
  globTestFiles(filters?: string[]): Promise<string[]>;
510
515
  globAllTestFiles(config: ResolvedConfig, cwd: string): Promise<string[]>;
@@ -514,27 +519,30 @@ declare class WorkspaceProject {
514
519
  isInSourceTestFile(code: string): boolean;
515
520
  filterFiles(testFiles: string[], filters: string[] | undefined, dir: string): string[];
516
521
  initBrowserServer(configFile: string | undefined): Promise<void>;
522
+ static createBasicProject(ctx: Vitest): WorkspaceProject;
517
523
  static createCoreProject(ctx: Vitest): Promise<WorkspaceProject>;
518
524
  setServer(options: UserConfig, server: ViteDevServer): Promise<void>;
519
525
  report<T extends keyof Reporter>(name: T, ...args: ArgumentsType$1<Reporter[T]>): Promise<void>;
520
- typecheck(filters?: string[]): Promise<void>;
521
- isBrowserEnabled(): boolean | 0;
526
+ isBrowserEnabled(): boolean;
522
527
  getSerializableConfig(): ResolvedConfig;
523
528
  close(): Promise<unknown>;
524
529
  initBrowserProvider(): Promise<void>;
525
530
  }
526
531
 
527
- interface BrowserProviderOptions {
532
+ interface BrowserProviderInitializationOptions {
528
533
  browser: string;
534
+ options?: BrowserProviderOptions;
529
535
  }
530
536
  interface BrowserProvider {
531
537
  name: string;
532
538
  getSupportedBrowsers(): readonly string[];
533
- initialize(ctx: WorkspaceProject, options: BrowserProviderOptions): Awaitable$1<void>;
539
+ initialize(ctx: WorkspaceProject, options: BrowserProviderInitializationOptions): Awaitable$1<void>;
534
540
  openPage(url: string): Awaitable$1<void>;
535
541
  catchError(cb: (error: Error) => Awaitable$1<void>): () => Awaitable$1<void>;
536
542
  close(): Awaitable$1<void>;
537
543
  }
544
+ interface BrowserProviderOptions {
545
+ }
538
546
  interface BrowserConfigOptions {
539
547
  /**
540
548
  * if running tests in the browser should be the default
@@ -547,11 +555,22 @@ interface BrowserConfigOptions {
547
555
  */
548
556
  name: string;
549
557
  /**
550
- * browser provider
558
+ * Browser provider
551
559
  *
552
560
  * @default 'webdriverio'
553
561
  */
554
- provider?: 'webdriverio' | 'playwright' | (string & {});
562
+ provider?: 'webdriverio' | 'playwright' | 'none' | (string & {});
563
+ /**
564
+ * Options that are passed down to a browser provider.
565
+ * To support type hinting, add one of the types to your tsconfig.json "compilerOptions.types" field:
566
+ *
567
+ * - for webdriverio: `@vitest/browser/providers/webdriverio`
568
+ * - for playwright: `@vitest/browser/providers/playwright`
569
+ *
570
+ * @example
571
+ * { playwright: { launch: { devtools: true } }
572
+ */
573
+ providerOptions?: BrowserProviderOptions;
555
574
  /**
556
575
  * enable headless mode
557
576
  *
@@ -636,6 +655,8 @@ interface ModuleGraphData {
636
655
  inlined: string[];
637
656
  }
638
657
  type OnServerRestartHandler = (reason?: string) => Promise<void> | void;
658
+ interface ProvidedContext {
659
+ }
639
660
 
640
661
  declare class StateManager {
641
662
  filesMap: Map<string, File[]>;
@@ -759,16 +780,16 @@ declare class Vitest {
759
780
  };
760
781
  constructor(mode: VitestRunMode);
761
782
  private _onRestartListeners;
783
+ private _onClose;
762
784
  private _onSetServer;
763
785
  private _onCancelListeners;
764
786
  setServer(options: UserConfig, server: ViteDevServer, cliOptions: UserConfig): Promise<void>;
765
787
  private createCoreProject;
766
- getCoreWorkspaceProject(): WorkspaceProject | null;
788
+ getCoreWorkspaceProject(): WorkspaceProject;
767
789
  getProjectByTaskId(taskId: string): WorkspaceProject;
768
790
  private resolveWorkspace;
769
791
  private initCoverageProvider;
770
792
  private initBrowserProviders;
771
- typecheck(filters?: string[]): Promise<void[]>;
772
793
  start(filters?: string[]): Promise<void>;
773
794
  private getTestDependencies;
774
795
  filterTestsBySource(specs: WorkspaceSpec[]): Promise<WorkspaceSpec[]>;
@@ -802,6 +823,7 @@ declare class Vitest {
802
823
  onServerRestart(fn: OnServerRestartHandler): void;
803
824
  onAfterSetServer(fn: OnServerRestartHandler): void;
804
825
  onCancel(fn: (reason: CancelReason) => void): void;
826
+ onClose(fn: () => void): void;
805
827
  }
806
828
 
807
829
  interface TestSequencer {
@@ -827,6 +849,7 @@ declare abstract class BaseReporter implements Reporter {
827
849
  private _lastRunTimer;
828
850
  private _lastRunCount;
829
851
  private _timeStart;
852
+ private _offUnhandledRejection?;
830
853
  constructor();
831
854
  get mode(): VitestRunMode;
832
855
  onInit(ctx: Vitest): void;
@@ -1175,9 +1198,11 @@ interface ResolvedTestEnvironment {
1175
1198
  }
1176
1199
  interface ContextRPC {
1177
1200
  config: ResolvedConfig;
1201
+ projectName: string;
1178
1202
  files: string[];
1179
1203
  invalidates?: string[];
1180
1204
  environment: ContextTestEnvironment;
1205
+ providedContext: Record<string, any>;
1181
1206
  }
1182
1207
 
1183
1208
  interface WorkerContext extends ContextRPC {
@@ -1187,6 +1212,8 @@ interface WorkerContext extends ContextRPC {
1187
1212
  type ResolveIdFunction = (id: string, importer?: string) => Promise<ViteNodeResolveId | null>;
1188
1213
  interface AfterSuiteRunMeta {
1189
1214
  coverage?: unknown;
1215
+ transformMode: Environment['transformMode'];
1216
+ projectName?: string;
1190
1217
  }
1191
1218
  type WorkerRPC = BirpcReturn<RuntimeRPC, RunnerRPC>;
1192
1219
  interface WorkerGlobalState {
@@ -1200,6 +1227,7 @@ interface WorkerGlobalState {
1200
1227
  onCancel: Promise<CancelReason>;
1201
1228
  moduleCache: ModuleCacheMap;
1202
1229
  mockMap: MockMap;
1230
+ providedContext: Record<string, any>;
1203
1231
  durations: {
1204
1232
  environment: number;
1205
1233
  prepare: number;
@@ -1549,7 +1577,7 @@ type BenchmarkAPI = ChainableFunction<'skip' | 'only' | 'todo', [
1549
1577
  runIf(condition: any): BenchmarkAPI;
1550
1578
  };
1551
1579
 
1552
- type Pool = 'browser' | 'threads' | 'forks' | 'vmThreads';
1580
+ type Pool = 'browser' | 'threads' | 'forks' | 'vmThreads' | 'typescript';
1553
1581
  interface PoolOptions {
1554
1582
  /**
1555
1583
  * Run tests in `node:worker_threads`.
@@ -1612,6 +1640,18 @@ interface WorkerContextOptions {
1612
1640
  * @default true
1613
1641
  */
1614
1642
  isolate?: boolean;
1643
+ /**
1644
+ * Pass additional arguments to `node` process when spawning `worker_threads` or `child_process`.
1645
+ *
1646
+ * See [Command-line API | Node.js](https://nodejs.org/docs/latest/api/cli.html) for more information.
1647
+ *
1648
+ * Set to `process.execArgv` to pass all arguments of the current process.
1649
+ *
1650
+ * Be careful when using, it as some options may crash worker, e.g. --prof, --title. See https://github.com/nodejs/node/issues/41103
1651
+ *
1652
+ * @default [] // no execution arguments are passed
1653
+ */
1654
+ execArgv?: string[];
1615
1655
  }
1616
1656
  interface VmOptions {
1617
1657
  /**
@@ -1621,6 +1661,18 @@ interface VmOptions {
1621
1661
  memoryLimit?: string | number;
1622
1662
  /** Isolation is always enabled */
1623
1663
  isolate?: true;
1664
+ /**
1665
+ * Pass additional arguments to `node` process when spawning `worker_threads` or `child_process`.
1666
+ *
1667
+ * See [Command-line API | Node.js](https://nodejs.org/docs/latest/api/cli.html) for more information.
1668
+ *
1669
+ * Set to `process.execArgv` to pass all arguments of the current process.
1670
+ *
1671
+ * Be careful when using, it as some options may crash worker, e.g. --prof, --title. See https://github.com/nodejs/node/issues/41103
1672
+ *
1673
+ * @default [] // no execution arguments are passed
1674
+ */
1675
+ execArgv?: string[];
1624
1676
  }
1625
1677
 
1626
1678
  type BuiltinEnvironment = 'node' | 'jsdom' | 'happy-dom' | 'edge-runtime';
@@ -1637,7 +1689,7 @@ interface EnvironmentOptions {
1637
1689
  happyDOM?: HappyDOMOptions;
1638
1690
  [x: string]: unknown;
1639
1691
  }
1640
- type VitestRunMode = 'test' | 'benchmark' | 'typecheck';
1692
+ type VitestRunMode = 'test' | 'benchmark';
1641
1693
  interface SequenceOptions {
1642
1694
  /**
1643
1695
  * Class that handles sorting and sharding algorithm.
@@ -1774,12 +1826,6 @@ interface DepsOptions {
1774
1826
  * @deprecated Use `server.deps.fallbackCJS` instead.
1775
1827
  */
1776
1828
  fallbackCJS?: boolean;
1777
- /**
1778
- * Use experimental Node loader to resolve imports inside node_modules using Vite resolve algorithm.
1779
- * @default false
1780
- * @deprecated If you rely on aliases inside external packages, use `deps.optimizer.{web,ssr}.include` instead.
1781
- */
1782
- registerNodeLoader?: boolean;
1783
1829
  /**
1784
1830
  * A list of directories relative to the config file that should be treated as module directories.
1785
1831
  *
@@ -1873,7 +1919,7 @@ interface InlineConfig {
1873
1919
  *
1874
1920
  * @default 'threads'
1875
1921
  */
1876
- pool?: Omit<Pool, 'browser'>;
1922
+ pool?: Exclude<Pool, 'browser'>;
1877
1923
  /**
1878
1924
  * Pool options
1879
1925
  */
@@ -1891,7 +1937,7 @@ interface InlineConfig {
1891
1937
  * // ...
1892
1938
  * ]
1893
1939
  */
1894
- poolMatchGlobs?: [string, Omit<Pool, 'browser'>][];
1940
+ poolMatchGlobs?: [string, Exclude<Pool, 'browser'>][];
1895
1941
  /**
1896
1942
  * Update snapshot
1897
1943
  *
@@ -2077,6 +2123,13 @@ interface InlineConfig {
2077
2123
  * Return `false` to ignore the log.
2078
2124
  */
2079
2125
  onConsoleLog?: (log: string, type: 'stdout' | 'stderr') => false | void;
2126
+ /**
2127
+ * Enable stack trace filtering. If absent, all stack trace frames
2128
+ * will be shown.
2129
+ *
2130
+ * Return `false` to omit the frame.
2131
+ */
2132
+ onStackTrace?: (error: Error, frame: ParsedStack) => boolean | void;
2080
2133
  /**
2081
2134
  * Indicates if CSS files should be processed.
2082
2135
  *
@@ -2160,8 +2213,20 @@ interface InlineConfig {
2160
2213
  * @default 0
2161
2214
  */
2162
2215
  retry?: number;
2216
+ /**
2217
+ * Show full diff when snapshot fails instead of a patch.
2218
+ */
2219
+ expandSnapshotDiff?: boolean;
2163
2220
  }
2164
2221
  interface TypecheckConfig {
2222
+ /**
2223
+ * Run typechecking tests alongisde regular tests.
2224
+ */
2225
+ enabled?: boolean;
2226
+ /**
2227
+ * When typechecking is enabled, only run typechecking tests.
2228
+ */
2229
+ only?: boolean;
2165
2230
  /**
2166
2231
  * What tools to use for type checking.
2167
2232
  */
@@ -2224,7 +2289,7 @@ interface UserConfig extends InlineConfig {
2224
2289
  */
2225
2290
  shard?: string;
2226
2291
  }
2227
- interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters' | 'browser' | 'coverage' | 'testNamePattern' | 'related' | 'api' | 'reporters' | 'resolveSnapshotPath' | 'benchmark' | 'shard' | 'cache' | 'sequence' | 'typecheck' | 'runner' | 'poolOptions'> {
2292
+ interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters' | 'browser' | 'coverage' | 'testNamePattern' | 'related' | 'api' | 'reporters' | 'resolveSnapshotPath' | 'benchmark' | 'shard' | 'cache' | 'sequence' | 'typecheck' | 'runner' | 'poolOptions' | 'pool'> {
2228
2293
  mode: VitestRunMode;
2229
2294
  base?: string;
2230
2295
  config?: string;
@@ -2239,9 +2304,7 @@ interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters'
2239
2304
  reporters: (Reporter | BuiltinReporters)[];
2240
2305
  defines: Record<string, any>;
2241
2306
  api?: ApiConfig;
2242
- benchmark?: Required<Omit<BenchmarkUserOptions, 'outputFile'>> & {
2243
- outputFile?: BenchmarkUserOptions['outputFile'];
2244
- };
2307
+ benchmark?: Required<Omit<BenchmarkUserOptions, 'outputFile'>> & Pick<BenchmarkUserOptions, 'outputFile'>;
2245
2308
  shard?: {
2246
2309
  index: number;
2247
2310
  count: number;
@@ -2257,12 +2320,14 @@ interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters'
2257
2320
  concurrent?: boolean;
2258
2321
  seed: number;
2259
2322
  };
2260
- typecheck: TypecheckConfig;
2323
+ typecheck: Omit<TypecheckConfig, 'enabled'> & {
2324
+ enabled: boolean;
2325
+ };
2261
2326
  runner?: string;
2262
2327
  }
2263
- 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'> & {
2328
+ 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' | 'onStackTrace' | 'dangerouslyIgnoreUnhandledErrors' | 'slowTestThreshold' | 'inspect' | 'inspectBrk' | 'deps' | 'coverage'> & {
2264
2329
  sequencer?: Omit<SequenceOptions, 'sequencer' | 'seed'>;
2265
- deps?: Omit<DepsOptions, 'registerNodeLoader' | 'moduleDirectories'>;
2330
+ deps?: Omit<DepsOptions, 'moduleDirectories'>;
2266
2331
  };
2267
2332
  type RuntimeConfig = Pick<UserConfig, 'allowOnly' | 'testTimeout' | 'hookTimeout' | 'clearMocks' | 'mockReset' | 'restoreMocks' | 'fakeTimers' | 'maxConcurrency'> & {
2268
2333
  sequence?: {
@@ -2362,4 +2427,4 @@ type Context = RootAndTarget & {
2362
2427
  lastActivePath?: string;
2363
2428
  };
2364
2429
 
2365
- export { type Nullable as $, type AfterSuiteRunMeta as A, type BaseCoverageOptions as B, type CoverageV8Options as C, type DepsOptimizationOptions as D, type Environment as E, type FakeTimerInstallOpts as F, type TypecheckConfig as G, type HappyDOMOptions as H, type InlineConfig as I, type JSDOMOptions as J, type RuntimeRPC as K, type RunnerRPC as L, type MockFactoryWithHelper as M, type ContextTestEnvironment as N, type ResolvedTestEnvironment as O, type ProjectConfig as P, type ContextRPC as Q, type ResolvedConfig as R, type WorkerContext as S, type TestSequencer as T, type UserConfig as U, type VitestRunMode as V, type WorkspaceSpec as W, type ResolveIdFunction as X, type WorkerRPC as Y, type WorkerGlobalState as Z, type Awaitable as _, type ResolvedCoverageOptions as a, type Arrayable as a0, type ArgumentsType$1 as a1, type MutableArray as a2, type Constructable as a3, type ModuleCache as a4, type EnvironmentReturn as a5, type VmEnvironmentReturn as a6, type OnServerRestartHandler as a7, type ReportContext as a8, type CoverageReporter as a9, type CoverageIstanbulOptions as aa, type CustomProviderOptions as ab, type BenchmarkUserOptions as ac, type Benchmark as ad, type BenchmarkResult as ae, type BenchFunction as af, type BenchmarkAPI as ag, type PendingSuiteMock as ah, type MockFactory as ai, type 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, type BuiltinReporters as av, BenchmarkReportsMap as aw, type BenchmarkBuiltinReporters as ax, Vitest as b, WorkspaceProject as c, type TestSequencerConstructor as d, type CoverageOptions as e, type CoverageProvider as f, type CoverageProviderModule as g, type RuntimeConfig as h, type UserConsoleLog as i, type ModuleGraphData as j, type Reporter as k, type RawErrsMap as l, type TscErrorInfo as m, type CollectLineNumbers as n, type CollectLines as o, type RootAndTarget as p, type Context as q, type Pool as r, startVitest as s, type PoolOptions as t, type BuiltinEnvironment as u, type VitestEnvironment as v, type CSSModuleScopeStrategy as w, type ApiConfig as x, type EnvironmentOptions as y, type TransformModePatterns as z };
2430
+ export { type ResolveIdFunction as $, type AfterSuiteRunMeta as A, type BaseCoverageOptions as B, type CoverageV8Options as C, type CSSModuleScopeStrategy as D, type Environment as E, type FakeTimerInstallOpts as F, type ApiConfig as G, type HappyDOMOptions as H, type EnvironmentOptions as I, type JSDOMOptions as J, type DepsOptimizationOptions as K, type TransformModePatterns as L, type MockFactoryWithHelper as M, type InlineConfig as N, type TypecheckConfig as O, type ProjectConfig as P, type RuntimeRPC as Q, type ResolvedConfig as R, type RunnerRPC as S, type TestSequencer as T, type UserConfig as U, type VitestRunMode as V, type WorkspaceSpec as W, type ContextTestEnvironment as X, type ResolvedTestEnvironment as Y, type ContextRPC as Z, type WorkerContext as _, type ResolvedCoverageOptions as a, type WorkerRPC as a0, type WorkerGlobalState as a1, type Awaitable as a2, type Nullable as a3, type Arrayable as a4, type ArgumentsType$1 as a5, type MutableArray as a6, type Constructable as a7, type ModuleCache as a8, type EnvironmentReturn as a9, BenchmarkReportsMap as aA, type BenchmarkBuiltinReporters as aB, type VmEnvironmentReturn as aa, type OnServerRestartHandler as ab, type ReportContext as ac, type CoverageReporter as ad, type CoverageIstanbulOptions as ae, type CustomProviderOptions as af, type BenchmarkUserOptions as ag, type Benchmark as ah, type BenchmarkResult as ai, type BenchFunction as aj, type BenchmarkAPI as ak, type PendingSuiteMock as al, type MockFactory as am, type MockMap as an, DefaultReporter as ao, BasicReporter as ap, DotReporter as aq, JsonReporter$1 as ar, VerboseReporter as as, TapReporter as at, JUnitReporter as au, TapFlatReporter as av, HangingProcessReporter as aw, BaseReporter as ax, ReportersMap as ay, type BuiltinReporters as az, type CoverageOptions as b, type CoverageProvider as c, type CoverageProviderModule as d, Vitest as e, type ProvidedContext as f, WorkspaceProject as g, type TestSequencerConstructor as h, type BrowserProviderInitializationOptions as i, type BrowserProvider as j, type BrowserProviderOptions as k, type RuntimeConfig as l, type UserConsoleLog as m, type ModuleGraphData as n, type Reporter as o, type RawErrsMap as p, type TscErrorInfo as q, type CollectLineNumbers as r, startVitest as s, type CollectLines as t, type RootAndTarget as u, type Context as v, type Pool as w, type PoolOptions as x, type BuiltinEnvironment as y, type VitestEnvironment as z };
@@ -1,4 +1,4 @@
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-d10f25e1.js';
1
+ export { ax as BaseReporter, ap as BasicReporter, aB as BenchmarkBuiltinReporters, aA as BenchmarkReportsMap, az as BuiltinReporters, ao as DefaultReporter, aq as DotReporter, aw as HangingProcessReporter, au as JUnitReporter, ar as JsonReporter, o as Reporter, ay as ReportersMap, av as TapFlatReporter, at as TapReporter, as as VerboseReporter } from './reporters-50c2bd49.js';
2
2
  import 'vite';
3
3
  import '@vitest/runner';
4
4
  import 'vite-node';
@@ -11,6 +11,5 @@ import 'vite-node/client';
11
11
  import '@vitest/snapshot/manager';
12
12
  import 'vite-node/server';
13
13
  import 'node:worker_threads';
14
- import 'rollup';
15
14
  import 'node:fs';
16
15
  import 'chai';
package/dist/reporters.js CHANGED
@@ -1,12 +1,12 @@
1
- export { f as BasicReporter, B as BenchmarkReportsMap, D as DefaultReporter, g as DotReporter, H as HangingProcessReporter, h as JUnitReporter, J as JsonReporter, R as ReportersMap, i as TapFlatReporter, T as TapReporter, V as VerboseReporter } from './vendor-reporters.2953082e.js';
1
+ export { b as BasicReporter, B as BenchmarkReportsMap, D as DefaultReporter, e as DotReporter, H as HangingProcessReporter, f as JUnitReporter, J as JsonReporter, R as ReportersMap, g as TapFlatReporter, T as TapReporter, V as VerboseReporter } from './vendor-reporters.d24d80a4.js';
2
2
  import 'node:perf_hooks';
3
3
  import 'picocolors';
4
- import './vendor-index.29282562.js';
4
+ import './vendor-index.2b92937b.js';
5
5
  import 'pathe';
6
6
  import 'std-env';
7
7
  import '@vitest/runner/utils';
8
8
  import '@vitest/utils';
9
- import './vendor-global.97e4527c.js';
9
+ import './vendor-global.c3664e75.js';
10
10
  import './chunk-runtime-console.f3263f87.js';
11
11
  import 'node:stream';
12
12
  import 'node:console';
package/dist/runners.d.ts CHANGED
@@ -1,17 +1,16 @@
1
1
  import { VitestRunner, VitestRunnerImportSource, Suite, Test, CancelReason, Custom, TaskContext, ExtendedContext } from '@vitest/runner';
2
- import { R as ResolvedConfig } from './reporters-d10f25e1.js';
2
+ import { R as ResolvedConfig } from './reporters-50c2bd49.js';
3
+ import * as tinybench from 'tinybench';
3
4
  import 'vite';
4
5
  import 'vite-node';
5
6
  import '@vitest/snapshot';
6
7
  import '@vitest/expect';
7
8
  import '@vitest/runner/utils';
8
9
  import '@vitest/utils';
9
- import 'tinybench';
10
10
  import 'vite-node/client';
11
11
  import '@vitest/snapshot/manager';
12
12
  import 'vite-node/server';
13
13
  import 'node:worker_threads';
14
- import 'rollup';
15
14
  import 'node:fs';
16
15
  import 'chai';
17
16
 
@@ -39,6 +38,7 @@ declare class NodeBenchmarkRunner implements VitestRunner {
39
38
  config: ResolvedConfig;
40
39
  private __vitest_executor;
41
40
  constructor(config: ResolvedConfig);
41
+ importTinybench(): Promise<typeof tinybench>;
42
42
  importFile(filepath: string, source: VitestRunnerImportSource): unknown;
43
43
  runSuite(suite: Suite): Promise<void>;
44
44
  runTask(): Promise<void>;
package/dist/runners.js CHANGED
@@ -1,14 +1,13 @@
1
1
  import { setState, GLOBAL_EXPECT, getState } from '@vitest/expect';
2
- import { g as getSnapshotClient, c as createExpect, v as vi } from './vendor-vi.d30b47ae.js';
3
- import './vendor-index.29282562.js';
4
- import { a as rpc } from './vendor-rpc.cbd8e972.js';
2
+ import { g as getSnapshotClient, c as createExpect, v as vi } from './vendor-vi.3baa7c4a.js';
3
+ import './vendor-index.2b92937b.js';
4
+ import { a as rpc } from './vendor-rpc.171f65fb.js';
5
5
  import { g as getFullName } from './vendor-tasks.f9d75aed.js';
6
- import { g as getWorkerState } from './vendor-global.97e4527c.js';
6
+ import { g as getWorkerState } from './vendor-global.c3664e75.js';
7
7
  import { getNames } from '@vitest/runner/utils';
8
- import { performance } from 'node:perf_hooks';
9
8
  import { updateTask } from '@vitest/runner';
10
9
  import { createDefer, getSafeTimers } from '@vitest/utils';
11
- import { a as getBenchOptions, g as getBenchFn } from './vendor-benchmark.44931cfa.js';
10
+ import { a as getBenchOptions, g as getBenchFn } from './vendor-benchmark.b6befc50.js';
12
11
  import 'chai';
13
12
  import './vendor-_commonjsHelpers.7d1333e8.js';
14
13
  import '@vitest/snapshot';
@@ -127,11 +126,6 @@ function clearModuleMocks(config) {
127
126
  vi.unstubAllGlobals();
128
127
  }
129
128
 
130
- async function importTinybench() {
131
- if (!globalThis.EventTarget)
132
- await import('./vendor-index.98139333.js').then(function (n) { return n.i; });
133
- return await import('tinybench');
134
- }
135
129
  function createBenchmarkResult(name) {
136
130
  return {
137
131
  name,
@@ -143,7 +137,7 @@ function createBenchmarkResult(name) {
143
137
  const benchmarkTasks = /* @__PURE__ */ new WeakMap();
144
138
  async function runBenchmarkSuite(suite, runner) {
145
139
  var _a;
146
- const { Task, Bench } = await importTinybench();
140
+ const { Task, Bench } = await runner.importTinybench();
147
141
  const start = performance.now();
148
142
  const benchmarkGroup = [];
149
143
  const benchmarkSuiteGroup = [];
@@ -159,14 +153,30 @@ async function runBenchmarkSuite(suite, runner) {
159
153
  await Promise.all(benchmarkSuiteGroup.map((subSuite) => runBenchmarkSuite(subSuite, runner)));
160
154
  if (benchmarkGroup.length) {
161
155
  const defer = createDefer();
162
- const benchmarkMap = {};
163
156
  suite.result = {
164
157
  state: "run",
165
158
  startTime: start,
166
159
  benchmark: createBenchmarkResult(suite.name)
167
160
  };
168
161
  updateTask$1(suite);
169
- benchmarkGroup.forEach((benchmark, idx) => {
162
+ const addBenchTaskListener = (task, benchmark) => {
163
+ task.addEventListener("complete", (e) => {
164
+ const task2 = e.task;
165
+ const taskRes = task2.result;
166
+ const result = benchmark.result.benchmark;
167
+ Object.assign(result, taskRes);
168
+ updateTask$1(benchmark);
169
+ }, {
170
+ once: true
171
+ });
172
+ task.addEventListener("error", (e) => {
173
+ const task2 = e.task;
174
+ defer.reject(benchmark ? task2.result.error : e);
175
+ }, {
176
+ once: true
177
+ });
178
+ };
179
+ benchmarkGroup.forEach((benchmark) => {
170
180
  const options = getBenchOptions(benchmark);
171
181
  const benchmarkInstance = new Bench(options);
172
182
  const benchmarkFn = getBenchFn(benchmark);
@@ -175,43 +185,26 @@ async function runBenchmarkSuite(suite, runner) {
175
185
  startTime: start,
176
186
  benchmark: createBenchmarkResult(benchmark.name)
177
187
  };
178
- const id = idx.toString();
179
- benchmarkMap[id] = benchmark;
180
- const task = new Task(benchmarkInstance, id, benchmarkFn);
188
+ const task = new Task(benchmarkInstance, benchmark.name, benchmarkFn);
181
189
  benchmarkTasks.set(benchmark, task);
190
+ addBenchTaskListener(task, benchmark);
182
191
  updateTask$1(benchmark);
183
192
  });
184
- benchmarkGroup.forEach((benchmark) => {
185
- const task = benchmarkTasks.get(benchmark);
186
- task.addEventListener("complete", (e) => {
187
- const task2 = e.task;
188
- const _benchmark = benchmarkMap[task2.name || ""];
189
- if (_benchmark) {
190
- const taskRes = task2.result;
191
- const result = _benchmark.result.benchmark;
192
- Object.assign(result, taskRes);
193
- updateTask$1(_benchmark);
194
- }
195
- });
196
- task.addEventListener("error", (e) => {
197
- const task2 = e.task;
198
- const _benchmark = benchmarkMap[task2.name || ""];
199
- defer.reject(_benchmark ? task2.result.error : e);
200
- });
201
- });
193
+ const { setTimeout } = getSafeTimers();
202
194
  const tasks = [];
203
195
  for (const benchmark of benchmarkGroup) {
204
196
  const task = benchmarkTasks.get(benchmark);
205
197
  await task.warmup();
206
- const { setTimeout } = getSafeTimers();
207
- tasks.push(await new Promise((resolve) => setTimeout(async () => {
208
- resolve(await task.run());
209
- })));
198
+ tasks.push([
199
+ await new Promise((resolve) => setTimeout(async () => {
200
+ resolve(await task.run());
201
+ })),
202
+ benchmark
203
+ ]);
210
204
  }
211
205
  suite.result.duration = performance.now() - start;
212
206
  suite.result.state = "pass";
213
- tasks.sort((a, b) => a.result.mean - b.result.mean).forEach((cycle, idx) => {
214
- const benchmark = benchmarkMap[cycle.name || ""];
207
+ tasks.sort(([taskA], [taskB]) => taskA.result.mean - taskB.result.mean).forEach(([, benchmark], idx) => {
215
208
  benchmark.result.state = "pass";
216
209
  if (benchmark) {
217
210
  const result = benchmark.result.benchmark;
@@ -232,6 +225,9 @@ class NodeBenchmarkRunner {
232
225
  this.config = config;
233
226
  }
234
227
  __vitest_executor;
228
+ async importTinybench() {
229
+ return await import('tinybench');
230
+ }
235
231
  importFile(filepath, source) {
236
232
  if (source === "setup")
237
233
  getWorkerState().moduleCache.delete(filepath);
@@ -1,6 +1,6 @@
1
1
  import { Custom } from '@vitest/runner';
2
2
  import '@vitest/runner/utils';
3
- import { af as BenchFunction, ag as BenchmarkAPI } from './reporters-d10f25e1.js';
3
+ import { aj as BenchFunction, ak as BenchmarkAPI } from './reporters-50c2bd49.js';
4
4
  import { Options } from 'tinybench';
5
5
 
6
6
  declare function getBenchOptions(key: Custom): Options;
package/dist/suite.d.ts CHANGED
@@ -1,7 +1,7 @@
1
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-919dd548.js';
4
- import './reporters-d10f25e1.js';
3
+ export { g as getBenchFn, a as getBenchOptions } from './suite-ad69b7cd.js';
4
+ import './reporters-50c2bd49.js';
5
5
  import 'vite';
6
6
  import 'vite-node';
7
7
  import '@vitest/snapshot';
@@ -12,6 +12,5 @@ import 'vite-node/client';
12
12
  import '@vitest/snapshot/manager';
13
13
  import 'vite-node/server';
14
14
  import 'node:worker_threads';
15
- import 'rollup';
16
15
  import 'node:fs';
17
16
  import 'chai';
package/dist/suite.js CHANGED
@@ -1,8 +1,8 @@
1
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';
3
+ export { g as getBenchFn, a as getBenchOptions } from './vendor-benchmark.b6befc50.js';
4
4
  import '@vitest/utils';
5
- import './vendor-index.29282562.js';
5
+ import './vendor-index.2b92937b.js';
6
6
  import 'pathe';
7
7
  import 'std-env';
8
- import './vendor-global.97e4527c.js';
8
+ import './vendor-global.c3664e75.js';
@@ -1,7 +1,7 @@
1
1
  import { getCurrentSuite } from '@vitest/runner';
2
2
  import { createChainable } from '@vitest/runner/utils';
3
3
  import { noop } from '@vitest/utils';
4
- import { i as isRunningInBenchmark } from './vendor-index.29282562.js';
4
+ import { i as isRunningInBenchmark } from './vendor-index.2b92937b.js';
5
5
 
6
6
  const benchFns = /* @__PURE__ */ new WeakMap();
7
7
  const benchOptsMap = /* @__PURE__ */ new WeakMap();