vitest 1.0.0-beta.2 → 1.0.0-beta.3

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/LICENSE.md +0 -29
  2. package/dist/browser.d.ts +1 -1
  3. package/dist/child.js +9 -4
  4. package/dist/{chunk-api-setup.5d9a93c7.js → chunk-api-setup.37a43981.js} +0 -2
  5. package/dist/{chunk-install-pkg.43d58972.js → chunk-install-pkg.6349b322.js} +10 -12
  6. package/dist/{chunk-node-git.2f1df48f.js → chunk-node-git.6c12e560.js} +1 -1
  7. package/dist/cli-wrapper.js +1 -1
  8. package/dist/cli.js +11 -18
  9. package/dist/config.d.ts +2 -2
  10. package/dist/coverage.d.ts +1 -1
  11. package/dist/coverage.js +2 -2
  12. package/dist/entry-vm.js +1 -1
  13. package/dist/entry.js +1 -1
  14. package/dist/environments.d.ts +1 -1
  15. package/dist/environments.js +1 -13
  16. package/dist/execute.d.ts +1 -1
  17. package/dist/execute.js +1 -1
  18. package/dist/index.d.ts +5 -5
  19. package/dist/node.d.ts +5 -3
  20. package/dist/node.js +14 -16
  21. package/dist/{reporters-d10f25e1.d.ts → reporters-1678fe04.d.ts} +62 -30
  22. package/dist/reporters.d.ts +1 -1
  23. package/dist/reporters.js +1 -1
  24. package/dist/runners.d.ts +3 -2
  25. package/dist/runners.js +32 -35
  26. package/dist/{suite-919dd548.d.ts → suite-0579b50d.d.ts} +1 -1
  27. package/dist/suite.d.ts +2 -2
  28. package/dist/{vendor-environments.094f240c.js → vendor-environments.dcc4a34e.js} +4 -37
  29. package/dist/{vendor-execute.07d1a420.js → vendor-execute.e6e4e89b.js} +1 -0
  30. package/dist/{vendor-index.d36f5516.js → vendor-index.3d079eea.js} +6 -1
  31. package/dist/{vendor-index.e006069f.js → vendor-index.8efe7746.js} +371 -371
  32. package/dist/{vendor-index.0b5b3600.js → vendor-loader.9c966f23.js} +36 -9
  33. package/dist/{vendor-node.e5a35bfe.js → vendor-node.327f8f1f.js} +1928 -1953
  34. package/dist/{vendor-reporters.2953082e.js → vendor-reporters.b9600369.js} +40 -23
  35. package/dist/vm.js +9 -4
  36. package/dist/worker.js +9 -4
  37. package/package.json +11 -27
  38. package/dist/loader.js +0 -100
  39. package/dist/vendor-index.98139333.js +0 -129
@@ -402,26 +402,29 @@ declare class TypeCheckError extends Error {
402
402
  name: string;
403
403
  constructor(message: string, stacks: ParsedStack[]);
404
404
  }
405
- interface ErrorsCache {
405
+ interface TypecheckResults {
406
406
  files: File[];
407
407
  sourceErrors: TypeCheckError[];
408
+ time: number;
408
409
  }
409
410
  type Callback<Args extends Array<any> = []> = (...args: Args) => Awaitable<void>;
410
411
  declare class Typechecker {
411
412
  protected ctx: WorkspaceProject;
412
- protected files: string[];
413
413
  private _onParseStart?;
414
414
  private _onParseEnd?;
415
415
  private _onWatcherRerun?;
416
416
  private _result;
417
+ private _startTime;
417
418
  private _output;
418
419
  private _tests;
419
420
  private tempConfigPath?;
420
421
  private allowJs?;
421
422
  private process?;
422
- constructor(ctx: WorkspaceProject, files: string[]);
423
+ protected files: string[];
424
+ constructor(ctx: WorkspaceProject);
425
+ setFiles(files: string[]): void;
423
426
  onParseStart(fn: Callback): void;
424
- onParseEnd(fn: Callback<[ErrorsCache]>): void;
427
+ onParseEnd(fn: Callback<[TypecheckResults]>): void;
425
428
  onWatcherRerun(fn: Callback): void;
426
429
  protected collectFileTests(filepath: string): Promise<FileInformation | null>;
427
430
  protected getFiles(): string[];
@@ -430,6 +433,7 @@ declare class Typechecker {
430
433
  protected prepareResults(output: string): Promise<{
431
434
  files: File[];
432
435
  sourceErrors: TypeCheckError[];
436
+ time: number;
433
437
  }>;
434
438
  protected parseTscLikeOutput(output: string): Promise<Map<string, {
435
439
  error: TypeCheckError;
@@ -442,7 +446,7 @@ declare class Typechecker {
442
446
  getExitCode(): number | false;
443
447
  getOutput(): string;
444
448
  start(): Promise<void>;
445
- getResult(): ErrorsCache;
449
+ getResult(): TypecheckResults;
446
450
  getTestFiles(): File[];
447
451
  getTestPacks(): TaskResultPack[];
448
452
  }
@@ -514,27 +518,30 @@ declare class WorkspaceProject {
514
518
  isInSourceTestFile(code: string): boolean;
515
519
  filterFiles(testFiles: string[], filters: string[] | undefined, dir: string): string[];
516
520
  initBrowserServer(configFile: string | undefined): Promise<void>;
521
+ static createBasicProject(ctx: Vitest): WorkspaceProject;
517
522
  static createCoreProject(ctx: Vitest): Promise<WorkspaceProject>;
518
523
  setServer(options: UserConfig, server: ViteDevServer): Promise<void>;
519
524
  report<T extends keyof Reporter>(name: T, ...args: ArgumentsType$1<Reporter[T]>): Promise<void>;
520
- typecheck(filters?: string[]): Promise<void>;
521
- isBrowserEnabled(): boolean | 0;
525
+ isBrowserEnabled(): boolean;
522
526
  getSerializableConfig(): ResolvedConfig;
523
527
  close(): Promise<unknown>;
524
528
  initBrowserProvider(): Promise<void>;
525
529
  }
526
530
 
527
- interface BrowserProviderOptions {
531
+ interface BrowserProviderInitializationOptions {
528
532
  browser: string;
533
+ options?: BrowserProviderOptions;
529
534
  }
530
535
  interface BrowserProvider {
531
536
  name: string;
532
537
  getSupportedBrowsers(): readonly string[];
533
- initialize(ctx: WorkspaceProject, options: BrowserProviderOptions): Awaitable$1<void>;
538
+ initialize(ctx: WorkspaceProject, options: BrowserProviderInitializationOptions): Awaitable$1<void>;
534
539
  openPage(url: string): Awaitable$1<void>;
535
540
  catchError(cb: (error: Error) => Awaitable$1<void>): () => Awaitable$1<void>;
536
541
  close(): Awaitable$1<void>;
537
542
  }
543
+ interface BrowserProviderOptions {
544
+ }
538
545
  interface BrowserConfigOptions {
539
546
  /**
540
547
  * if running tests in the browser should be the default
@@ -547,11 +554,22 @@ interface BrowserConfigOptions {
547
554
  */
548
555
  name: string;
549
556
  /**
550
- * browser provider
557
+ * Browser provider
551
558
  *
552
559
  * @default 'webdriverio'
553
560
  */
554
561
  provider?: 'webdriverio' | 'playwright' | (string & {});
562
+ /**
563
+ * Options that are passed down to a browser provider.
564
+ * To support type hinting, add one of the types to your tsconfig.json "compilerOptions.types" field:
565
+ *
566
+ * - for webdriverio: `@vitest/browser/providers/webdriverio`
567
+ * - for playwright: `@vitest/browser/providers/playwright`
568
+ *
569
+ * @example
570
+ * { playwright: { launch: { devtools: true } }
571
+ */
572
+ providerOptions?: BrowserProviderOptions;
555
573
  /**
556
574
  * enable headless mode
557
575
  *
@@ -759,16 +777,16 @@ declare class Vitest {
759
777
  };
760
778
  constructor(mode: VitestRunMode);
761
779
  private _onRestartListeners;
780
+ private _onClose;
762
781
  private _onSetServer;
763
782
  private _onCancelListeners;
764
783
  setServer(options: UserConfig, server: ViteDevServer, cliOptions: UserConfig): Promise<void>;
765
784
  private createCoreProject;
766
- getCoreWorkspaceProject(): WorkspaceProject | null;
785
+ getCoreWorkspaceProject(): WorkspaceProject;
767
786
  getProjectByTaskId(taskId: string): WorkspaceProject;
768
787
  private resolveWorkspace;
769
788
  private initCoverageProvider;
770
789
  private initBrowserProviders;
771
- typecheck(filters?: string[]): Promise<void[]>;
772
790
  start(filters?: string[]): Promise<void>;
773
791
  private getTestDependencies;
774
792
  filterTestsBySource(specs: WorkspaceSpec[]): Promise<WorkspaceSpec[]>;
@@ -802,6 +820,7 @@ declare class Vitest {
802
820
  onServerRestart(fn: OnServerRestartHandler): void;
803
821
  onAfterSetServer(fn: OnServerRestartHandler): void;
804
822
  onCancel(fn: (reason: CancelReason) => void): void;
823
+ onClose(fn: () => void): void;
805
824
  }
806
825
 
807
826
  interface TestSequencer {
@@ -827,6 +846,7 @@ declare abstract class BaseReporter implements Reporter {
827
846
  private _lastRunTimer;
828
847
  private _lastRunCount;
829
848
  private _timeStart;
849
+ private _offUnhandledRejection?;
830
850
  constructor();
831
851
  get mode(): VitestRunMode;
832
852
  onInit(ctx: Vitest): void;
@@ -1175,6 +1195,7 @@ interface ResolvedTestEnvironment {
1175
1195
  }
1176
1196
  interface ContextRPC {
1177
1197
  config: ResolvedConfig;
1198
+ projectName: string;
1178
1199
  files: string[];
1179
1200
  invalidates?: string[];
1180
1201
  environment: ContextTestEnvironment;
@@ -1187,6 +1208,8 @@ interface WorkerContext extends ContextRPC {
1187
1208
  type ResolveIdFunction = (id: string, importer?: string) => Promise<ViteNodeResolveId | null>;
1188
1209
  interface AfterSuiteRunMeta {
1189
1210
  coverage?: unknown;
1211
+ transformMode: Environment['transformMode'];
1212
+ projectName?: string;
1190
1213
  }
1191
1214
  type WorkerRPC = BirpcReturn<RuntimeRPC, RunnerRPC>;
1192
1215
  interface WorkerGlobalState {
@@ -1549,7 +1572,7 @@ type BenchmarkAPI = ChainableFunction<'skip' | 'only' | 'todo', [
1549
1572
  runIf(condition: any): BenchmarkAPI;
1550
1573
  };
1551
1574
 
1552
- type Pool = 'browser' | 'threads' | 'forks' | 'vmThreads';
1575
+ type Pool = 'browser' | 'threads' | 'forks' | 'vmThreads' | 'typescript';
1553
1576
  interface PoolOptions {
1554
1577
  /**
1555
1578
  * Run tests in `node:worker_threads`.
@@ -1637,7 +1660,7 @@ interface EnvironmentOptions {
1637
1660
  happyDOM?: HappyDOMOptions;
1638
1661
  [x: string]: unknown;
1639
1662
  }
1640
- type VitestRunMode = 'test' | 'benchmark' | 'typecheck';
1663
+ type VitestRunMode = 'test' | 'benchmark';
1641
1664
  interface SequenceOptions {
1642
1665
  /**
1643
1666
  * Class that handles sorting and sharding algorithm.
@@ -1774,12 +1797,6 @@ interface DepsOptions {
1774
1797
  * @deprecated Use `server.deps.fallbackCJS` instead.
1775
1798
  */
1776
1799
  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
1800
  /**
1784
1801
  * A list of directories relative to the config file that should be treated as module directories.
1785
1802
  *
@@ -1873,7 +1890,7 @@ interface InlineConfig {
1873
1890
  *
1874
1891
  * @default 'threads'
1875
1892
  */
1876
- pool?: Omit<Pool, 'browser'>;
1893
+ pool?: Exclude<Pool, 'browser'>;
1877
1894
  /**
1878
1895
  * Pool options
1879
1896
  */
@@ -1891,7 +1908,7 @@ interface InlineConfig {
1891
1908
  * // ...
1892
1909
  * ]
1893
1910
  */
1894
- poolMatchGlobs?: [string, Omit<Pool, 'browser'>][];
1911
+ poolMatchGlobs?: [string, Exclude<Pool, 'browser'>][];
1895
1912
  /**
1896
1913
  * Update snapshot
1897
1914
  *
@@ -2077,6 +2094,13 @@ interface InlineConfig {
2077
2094
  * Return `false` to ignore the log.
2078
2095
  */
2079
2096
  onConsoleLog?: (log: string, type: 'stdout' | 'stderr') => false | void;
2097
+ /**
2098
+ * Enable stack trace filtering. If absent, all stack trace frames
2099
+ * will be shown.
2100
+ *
2101
+ * Return `false` to omit the frame.
2102
+ */
2103
+ onStackTrace?: (error: Error, frame: ParsedStack) => boolean | void;
2080
2104
  /**
2081
2105
  * Indicates if CSS files should be processed.
2082
2106
  *
@@ -2162,6 +2186,14 @@ interface InlineConfig {
2162
2186
  retry?: number;
2163
2187
  }
2164
2188
  interface TypecheckConfig {
2189
+ /**
2190
+ * Run typechecking tests alongisde regular tests.
2191
+ */
2192
+ enabled?: boolean;
2193
+ /**
2194
+ * When typechecking is enabled, only run typechecking tests.
2195
+ */
2196
+ only?: boolean;
2165
2197
  /**
2166
2198
  * What tools to use for type checking.
2167
2199
  */
@@ -2224,7 +2256,7 @@ interface UserConfig extends InlineConfig {
2224
2256
  */
2225
2257
  shard?: string;
2226
2258
  }
2227
- interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters' | 'browser' | 'coverage' | 'testNamePattern' | 'related' | 'api' | 'reporters' | 'resolveSnapshotPath' | 'benchmark' | 'shard' | 'cache' | 'sequence' | 'typecheck' | 'runner' | 'poolOptions'> {
2259
+ interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters' | 'browser' | 'coverage' | 'testNamePattern' | 'related' | 'api' | 'reporters' | 'resolveSnapshotPath' | 'benchmark' | 'shard' | 'cache' | 'sequence' | 'typecheck' | 'runner' | 'poolOptions' | 'pool'> {
2228
2260
  mode: VitestRunMode;
2229
2261
  base?: string;
2230
2262
  config?: string;
@@ -2239,9 +2271,7 @@ interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters'
2239
2271
  reporters: (Reporter | BuiltinReporters)[];
2240
2272
  defines: Record<string, any>;
2241
2273
  api?: ApiConfig;
2242
- benchmark?: Required<Omit<BenchmarkUserOptions, 'outputFile'>> & {
2243
- outputFile?: BenchmarkUserOptions['outputFile'];
2244
- };
2274
+ benchmark?: Required<Omit<BenchmarkUserOptions, 'outputFile'>> & Pick<BenchmarkUserOptions, 'outputFile'>;
2245
2275
  shard?: {
2246
2276
  index: number;
2247
2277
  count: number;
@@ -2257,12 +2287,14 @@ interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters'
2257
2287
  concurrent?: boolean;
2258
2288
  seed: number;
2259
2289
  };
2260
- typecheck: TypecheckConfig;
2290
+ typecheck: Omit<TypecheckConfig, 'enabled'> & {
2291
+ enabled: boolean;
2292
+ };
2261
2293
  runner?: string;
2262
2294
  }
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'> & {
2295
+ 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
2296
  sequencer?: Omit<SequenceOptions, 'sequencer' | 'seed'>;
2265
- deps?: Omit<DepsOptions, 'registerNodeLoader' | 'moduleDirectories'>;
2297
+ deps?: Omit<DepsOptions, 'moduleDirectories'>;
2266
2298
  };
2267
2299
  type RuntimeConfig = Pick<UserConfig, 'allowOnly' | 'testTimeout' | 'hookTimeout' | 'clearMocks' | 'mockReset' | 'restoreMocks' | 'fakeTimers' | 'maxConcurrency'> & {
2268
2300
  sequence?: {
@@ -2362,4 +2394,4 @@ type Context = RootAndTarget & {
2362
2394
  lastActivePath?: string;
2363
2395
  };
2364
2396
 
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 };
2397
+ export { type WorkerRPC as $, type AfterSuiteRunMeta as A, type BaseCoverageOptions as B, type CoverageV8Options as C, type ApiConfig as D, type Environment as E, type FakeTimerInstallOpts as F, type EnvironmentOptions as G, type HappyDOMOptions as H, type DepsOptimizationOptions as I, type JSDOMOptions as J, type TransformModePatterns as K, type InlineConfig as L, type MockFactoryWithHelper as M, type TypecheckConfig as N, type RuntimeRPC as O, type ProjectConfig as P, type RunnerRPC as Q, type ResolvedConfig as R, type ContextTestEnvironment as S, type TestSequencer as T, type UserConfig as U, type VitestRunMode as V, type WorkspaceSpec as W, type ResolvedTestEnvironment as X, type ContextRPC as Y, type WorkerContext as Z, type ResolveIdFunction as _, type ResolvedCoverageOptions as a, type WorkerGlobalState as a0, type Awaitable as a1, type Nullable as a2, type Arrayable as a3, type ArgumentsType$1 as a4, type MutableArray as a5, type Constructable as a6, type ModuleCache as a7, type EnvironmentReturn as a8, type VmEnvironmentReturn as a9, type BenchmarkBuiltinReporters as aA, type OnServerRestartHandler as aa, type ReportContext as ab, type CoverageReporter as ac, type CoverageIstanbulOptions as ad, type CustomProviderOptions as ae, type BenchmarkUserOptions as af, type Benchmark as ag, type BenchmarkResult as ah, type BenchFunction as ai, type BenchmarkAPI as aj, type PendingSuiteMock as ak, type MockFactory as al, type MockMap as am, DefaultReporter as an, BasicReporter as ao, DotReporter as ap, JsonReporter$1 as aq, VerboseReporter as ar, TapReporter as as, JUnitReporter as at, TapFlatReporter as au, HangingProcessReporter as av, BaseReporter as aw, ReportersMap as ax, type BuiltinReporters as ay, BenchmarkReportsMap as az, type CoverageOptions as b, type CoverageProvider as c, type CoverageProviderModule as d, Vitest as e, WorkspaceProject as f, type TestSequencerConstructor as g, type BrowserProviderInitializationOptions as h, type BrowserProvider as i, type BrowserProviderOptions as j, type RuntimeConfig as k, type UserConsoleLog as l, type ModuleGraphData as m, type Reporter as n, type RawErrsMap as o, type TscErrorInfo as p, type CollectLineNumbers as q, type CollectLines as r, startVitest as s, type RootAndTarget as t, type Context as u, type Pool as v, type PoolOptions as w, type BuiltinEnvironment as x, type VitestEnvironment as y, type CSSModuleScopeStrategy 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 { aw as BaseReporter, ao as BasicReporter, aA as BenchmarkBuiltinReporters, az as BenchmarkReportsMap, ay as BuiltinReporters, an as DefaultReporter, ap as DotReporter, av as HangingProcessReporter, at as JUnitReporter, aq as JsonReporter, n as Reporter, ax as ReportersMap, au as TapFlatReporter, as as TapReporter, ar as VerboseReporter } from './reporters-1678fe04.js';
2
2
  import 'vite';
3
3
  import '@vitest/runner';
4
4
  import 'vite-node';
package/dist/reporters.js CHANGED
@@ -1,4 +1,4 @@
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 { 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.b9600369.js';
2
2
  import 'node:perf_hooks';
3
3
  import 'picocolors';
4
4
  import './vendor-index.29282562.js';
package/dist/runners.d.ts CHANGED
@@ -1,12 +1,12 @@
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-1678fe04.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';
@@ -39,6 +39,7 @@ declare class NodeBenchmarkRunner implements VitestRunner {
39
39
  config: ResolvedConfig;
40
40
  private __vitest_executor;
41
41
  constructor(config: ResolvedConfig);
42
+ importTinybench(): Promise<typeof tinybench>;
42
43
  importFile(filepath: string, source: VitestRunnerImportSource): unknown;
43
44
  runSuite(suite: Suite): Promise<void>;
44
45
  runTask(): Promise<void>;
package/dist/runners.js CHANGED
@@ -127,11 +127,6 @@ function clearModuleMocks(config) {
127
127
  vi.unstubAllGlobals();
128
128
  }
129
129
 
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
130
  function createBenchmarkResult(name) {
136
131
  return {
137
132
  name,
@@ -143,7 +138,7 @@ function createBenchmarkResult(name) {
143
138
  const benchmarkTasks = /* @__PURE__ */ new WeakMap();
144
139
  async function runBenchmarkSuite(suite, runner) {
145
140
  var _a;
146
- const { Task, Bench } = await importTinybench();
141
+ const { Task, Bench } = await runner.importTinybench();
147
142
  const start = performance.now();
148
143
  const benchmarkGroup = [];
149
144
  const benchmarkSuiteGroup = [];
@@ -159,14 +154,30 @@ async function runBenchmarkSuite(suite, runner) {
159
154
  await Promise.all(benchmarkSuiteGroup.map((subSuite) => runBenchmarkSuite(subSuite, runner)));
160
155
  if (benchmarkGroup.length) {
161
156
  const defer = createDefer();
162
- const benchmarkMap = {};
163
157
  suite.result = {
164
158
  state: "run",
165
159
  startTime: start,
166
160
  benchmark: createBenchmarkResult(suite.name)
167
161
  };
168
162
  updateTask$1(suite);
169
- benchmarkGroup.forEach((benchmark, idx) => {
163
+ const addBenchTaskListener = (task, benchmark) => {
164
+ task.addEventListener("complete", (e) => {
165
+ const task2 = e.task;
166
+ const taskRes = task2.result;
167
+ const result = benchmark.result.benchmark;
168
+ Object.assign(result, taskRes);
169
+ updateTask$1(benchmark);
170
+ }, {
171
+ once: true
172
+ });
173
+ task.addEventListener("error", (e) => {
174
+ const task2 = e.task;
175
+ defer.reject(benchmark ? task2.result.error : e);
176
+ }, {
177
+ once: true
178
+ });
179
+ };
180
+ benchmarkGroup.forEach((benchmark) => {
170
181
  const options = getBenchOptions(benchmark);
171
182
  const benchmarkInstance = new Bench(options);
172
183
  const benchmarkFn = getBenchFn(benchmark);
@@ -175,43 +186,26 @@ async function runBenchmarkSuite(suite, runner) {
175
186
  startTime: start,
176
187
  benchmark: createBenchmarkResult(benchmark.name)
177
188
  };
178
- const id = idx.toString();
179
- benchmarkMap[id] = benchmark;
180
- const task = new Task(benchmarkInstance, id, benchmarkFn);
189
+ const task = new Task(benchmarkInstance, benchmark.name, benchmarkFn);
181
190
  benchmarkTasks.set(benchmark, task);
191
+ addBenchTaskListener(task, benchmark);
182
192
  updateTask$1(benchmark);
183
193
  });
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
- });
194
+ const { setTimeout } = getSafeTimers();
202
195
  const tasks = [];
203
196
  for (const benchmark of benchmarkGroup) {
204
197
  const task = benchmarkTasks.get(benchmark);
205
198
  await task.warmup();
206
- const { setTimeout } = getSafeTimers();
207
- tasks.push(await new Promise((resolve) => setTimeout(async () => {
208
- resolve(await task.run());
209
- })));
199
+ tasks.push([
200
+ await new Promise((resolve) => setTimeout(async () => {
201
+ resolve(await task.run());
202
+ })),
203
+ benchmark
204
+ ]);
210
205
  }
211
206
  suite.result.duration = performance.now() - start;
212
207
  suite.result.state = "pass";
213
- tasks.sort((a, b) => a.result.mean - b.result.mean).forEach((cycle, idx) => {
214
- const benchmark = benchmarkMap[cycle.name || ""];
208
+ tasks.sort(([taskA], [taskB]) => taskA.result.mean - taskB.result.mean).forEach(([, benchmark], idx) => {
215
209
  benchmark.result.state = "pass";
216
210
  if (benchmark) {
217
211
  const result = benchmark.result.benchmark;
@@ -232,6 +226,9 @@ class NodeBenchmarkRunner {
232
226
  this.config = config;
233
227
  }
234
228
  __vitest_executor;
229
+ async importTinybench() {
230
+ return await import('tinybench');
231
+ }
235
232
  importFile(filepath, source) {
236
233
  if (source === "setup")
237
234
  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 { ai as BenchFunction, aj as BenchmarkAPI } from './reporters-1678fe04.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-0579b50d.js';
4
+ import './reporters-1678fe04.js';
5
5
  import 'vite';
6
6
  import 'vite-node';
7
7
  import '@vitest/snapshot';
@@ -1,6 +1,3 @@
1
- import { resolve, normalize } from 'pathe';
2
- import { r as resolvePath } from './vendor-index.0b5b3600.js';
3
- import { ViteNodeRunner } from 'vite-node/client';
4
1
  import { Console } from 'node:console';
5
2
  import { importModule } from 'local-pkg';
6
3
 
@@ -479,7 +476,9 @@ var jsdom = {
479
476
  "Response",
480
477
  "BroadcastChannel",
481
478
  "MessageChannel",
482
- "MessagePort"
479
+ "MessagePort",
480
+ "TextEncoder",
481
+ "TextDecoder"
483
482
  ];
484
483
  for (const name of globalNames) {
485
484
  const value = globalThis[name];
@@ -646,9 +645,6 @@ const envPackageNames = {
646
645
  "happy-dom": "happy-dom",
647
646
  "edge-runtime": "@edge-runtime/vm"
648
647
  };
649
- function isBuiltinEnvironment(env) {
650
- return env in environments;
651
- }
652
648
  function getEnvPackageName(env) {
653
649
  if (env === "node")
654
650
  return null;
@@ -658,34 +654,5 @@ function getEnvPackageName(env) {
658
654
  return null;
659
655
  return `vitest-environment-${env}`;
660
656
  }
661
- const _loaders = /* @__PURE__ */ new Map();
662
- async function createEnvironmentLoader(options) {
663
- if (!_loaders.has(options.root)) {
664
- const loader = new ViteNodeRunner(options);
665
- await loader.executeId("/@vite/env");
666
- _loaders.set(options.root, loader);
667
- }
668
- return _loaders.get(options.root);
669
- }
670
- async function loadEnvironment(name, options) {
671
- if (isBuiltinEnvironment(name))
672
- return environments[name];
673
- const loader = await createEnvironmentLoader(options);
674
- const root = loader.root;
675
- const packageId = name[0] === "." || name[0] === "/" ? resolve(root, name) : await resolvePath(`vitest-environment-${name}`, { url: [root] }) ?? resolve(root, name);
676
- const pkg = await loader.executeId(normalize(packageId));
677
- if (!pkg || !pkg.default || typeof pkg.default !== "object") {
678
- throw new TypeError(
679
- `Environment "${name}" is not a valid environment. Path "${packageId}" should export default object with a "setup" or/and "setupVM" method.`
680
- );
681
- }
682
- const environment = pkg.default;
683
- if (environment.transformMode !== "web" && environment.transformMode !== "ssr") {
684
- throw new TypeError(
685
- `Environment "${name}" is not a valid environment. Path "${packageId}" should export default object with a "transformMode" method equal to "ssr" or "web".`
686
- );
687
- }
688
- return environment;
689
- }
690
657
 
691
- export { environments as e, getEnvPackageName as g, loadEnvironment as l, populateGlobal as p };
658
+ export { environments as e, getEnvPackageName as g, populateGlobal as p };
@@ -1009,6 +1009,7 @@ async function startVitestExecutor(options) {
1009
1009
  }
1010
1010
  rpc().onUnhandledError(error, type);
1011
1011
  }
1012
+ process.setMaxListeners(25);
1012
1013
  process.on("uncaughtException", (e) => catchError(e, "Uncaught Exception"));
1013
1014
  process.on("unhandledRejection", (e) => catchError(e, "Unhandled Rejection"));
1014
1015
  const getTransformMode = () => {
@@ -68,8 +68,13 @@ async function resolveTestRunner(config, executor) {
68
68
  };
69
69
  const originalOnAfterRun = testRunner.onAfterRunFiles;
70
70
  testRunner.onAfterRunFiles = async (files) => {
71
+ const state = getWorkerState();
71
72
  const coverage = await takeCoverageInsideWorker(config.coverage, executor);
72
- rpc().onAfterSuiteRun({ coverage });
73
+ rpc().onAfterSuiteRun({
74
+ coverage,
75
+ transformMode: state.environment.transformMode,
76
+ projectName: state.ctx.projectName
77
+ });
73
78
  await (originalOnAfterRun == null ? void 0 : originalOnAfterRun.call(testRunner, files));
74
79
  };
75
80
  const originalOnAfterRunTask = testRunner.onAfterRunTask;