vitest 2.1.0-beta.5 → 2.1.0-beta.6

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 (46) hide show
  1. package/LICENSE.md +29 -0
  2. package/dist/browser.d.ts +4 -3
  3. package/dist/browser.js +2 -2
  4. package/dist/chunks/{RandomSequencer.B4M2ux5b.js → RandomSequencer.CjkAy_bL.js} +67 -21
  5. package/dist/chunks/{base.BYvKfYzm.js → base.B-9RAXb6.js} +1 -1
  6. package/dist/chunks/{cac.DosbLiJg.js → cac.BZlOqtiQ.js} +5 -5
  7. package/dist/chunks/{cli-api.D8zgNrBU.js → cli-api.B-2f6g4d.js} +7525 -7355
  8. package/dist/chunks/{constants.CaAN7icJ.js → constants.fzPh7AOq.js} +1 -1
  9. package/dist/chunks/{coverage.CqfT4xaf.js → coverage.zlNdAMHK.js} +5 -3
  10. package/dist/chunks/{creator.COdKw_ZN.js → creator.D0TxjnLa.js} +5 -2
  11. package/dist/chunks/{environment.0M5R1SX_.d.ts → environment.C5eAp3K6.d.ts} +1 -1
  12. package/dist/chunks/{globals.DRPLtPOv.js → globals.Br36EZIp.js} +3 -3
  13. package/dist/chunks/{index.Dx3f477d.js → index.C4LZENmc.js} +4432 -4422
  14. package/dist/chunks/index.CWhwfxXK.js +835 -0
  15. package/dist/chunks/{index.CxWPpGJz.js → index.dWDhoZDV.js} +2 -2
  16. package/dist/chunks/{index.CNZXZ9PJ.js → index.m3Xip5Zz.js} +1 -1
  17. package/dist/chunks/{reporters.DbwOGCsU.d.ts → reporters.B0Ao6Zu1.d.ts} +134 -117
  18. package/dist/chunks/{resolveConfig.RHsAM2_Q.js → resolveConfig.C0vpvVRF.js} +42 -33
  19. package/dist/chunks/{runBaseTests.BAhL8UH_.js → runBaseTests.Cf8lGnUq.js} +5 -5
  20. package/dist/chunks/{setup-common.KBrCO5LJ.js → setup-common.B7uEQsGB.js} +1 -1
  21. package/dist/chunks/{vi.B6QZ938s.js → vi.DBepMgvg.js} +9 -0
  22. package/dist/chunks/vite.Bvz2vSw0.d.ts +11 -0
  23. package/dist/chunks/{worker.BANO5ak1.d.ts → worker.CTdJUeeB.d.ts} +3 -2
  24. package/dist/chunks/{worker.Cx2xE71X.d.ts → worker.DTM-0OlZ.d.ts} +1 -1
  25. package/dist/cli.js +2 -2
  26. package/dist/config.cjs +1 -0
  27. package/dist/config.d.ts +70 -2
  28. package/dist/config.js +1 -0
  29. package/dist/coverage.d.ts +4 -3
  30. package/dist/coverage.js +27 -3
  31. package/dist/environments.d.ts +2 -2
  32. package/dist/execute.d.ts +2 -2
  33. package/dist/index.d.ts +11 -6
  34. package/dist/index.js +3 -3
  35. package/dist/node.d.ts +17 -7
  36. package/dist/node.js +39 -36
  37. package/dist/reporters.d.ts +2 -2
  38. package/dist/reporters.js +5 -5
  39. package/dist/runners.js +1 -1
  40. package/dist/workers/forks.js +1 -1
  41. package/dist/workers/runVmTests.js +5 -5
  42. package/dist/workers/threads.js +1 -1
  43. package/dist/workers.d.ts +4 -16
  44. package/dist/workers.js +1 -1
  45. package/package.json +12 -12
  46. package/dist/chunks/index.DNUmWFkO.js +0 -319
@@ -3,8 +3,8 @@ import { resolve } from 'pathe';
3
3
  import { distDir } from '../path.js';
4
4
  import { g as getWorkerState } from './utils.Ck2hJTRs.js';
5
5
  import { r as rpc } from './rpc.B7Mfb-Yf.js';
6
- import { t as takeCoverageInsideWorker } from './coverage.CqfT4xaf.js';
7
- import { l as loadDiffConfig, a as loadSnapshotSerializers } from './setup-common.KBrCO5LJ.js';
6
+ import { t as takeCoverageInsideWorker } from './coverage.zlNdAMHK.js';
7
+ import { l as loadDiffConfig, a as loadSnapshotSerializers } from './setup-common.B7uEQsGB.js';
8
8
 
9
9
  function setupChaiConfig(config) {
10
10
  Object.assign(chai.config, config);
@@ -1,7 +1,7 @@
1
1
  import { afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, onTestFinished, suite, test } from '@vitest/runner';
2
2
  import { b as bench } from './benchmark.C8CRJYG4.js';
3
3
  import { i as isFirstRun, a as runOnce } from './run-once.Sxe67Wng.js';
4
- import { c as createExpect, a as globalExpect, v as vi, b as vitest } from './vi.B6QZ938s.js';
4
+ import { c as createExpect, a as globalExpect, v as vi, b as vitest } from './vi.DBepMgvg.js';
5
5
  import { g as getWorkerState } from './utils.Ck2hJTRs.js';
6
6
  import * as chai from 'chai';
7
7
  import { assert, should } from 'chai';
@@ -1,12 +1,12 @@
1
1
  import * as _vitest_runner from '@vitest/runner';
2
2
  import { File, Test, Suite, TaskResultPack, Task, CancelReason, Custom, TaskMeta, SequenceHooks, SequenceSetupFiles } from '@vitest/runner';
3
3
  import * as vite from 'vite';
4
- import { ViteDevServer, TransformResult as TransformResult$1, UserConfig as UserConfig$1, ConfigEnv, ServerOptions, DepOptimizationConfig, AliasOptions } from 'vite';
4
+ import { ViteDevServer, TransformResult as TransformResult$1, ServerOptions, DepOptimizationConfig, AliasOptions, UserConfig as UserConfig$1, ConfigEnv } from 'vite';
5
5
  import { PrettyFormatOptions } from '@vitest/pretty-format';
6
6
  import { S as SerializedConfig, F as FakeTimerInstallOpts } from './config.CHuotKvS.js';
7
7
  import { RawSourceMap, ViteNodeServerOptions } from 'vite-node';
8
8
  import { SnapshotSummary, SnapshotStateOptions } from '@vitest/snapshot';
9
- import { b as Awaitable, P as ProvidedContext, U as UserConsoleLog, A as AfterSuiteRunMeta, c as Arrayable, d as ArgumentsType, O as OnServerRestartHandler, f as EnvironmentOptions } from './environment.0M5R1SX_.js';
9
+ import { b as Awaitable, P as ProvidedContext, U as UserConsoleLog, A as AfterSuiteRunMeta, c as Arrayable, d as ArgumentsType, O as OnServerRestartHandler, f as EnvironmentOptions } from './environment.C5eAp3K6.js';
10
10
  import { Writable } from 'node:stream';
11
11
  import { ViteNodeRunner } from 'vite-node/client';
12
12
  import { SnapshotManager } from '@vitest/snapshot/manager';
@@ -640,6 +640,7 @@ declare class WorkspaceProject {
640
640
  typechecker?: Typechecker;
641
641
  closingPromise: Promise<unknown> | undefined;
642
642
  testFilesList: string[] | null;
643
+ typecheckFilesList: string[] | null;
643
644
  testProject: TestProject;
644
645
  readonly id: string;
645
646
  readonly tmpDir: string;
@@ -650,6 +651,7 @@ declare class WorkspaceProject {
650
651
  isCore(): boolean;
651
652
  provide<T extends keyof ProvidedContext & string>(key: T, value: ProvidedContext[T]): void;
652
653
  getProvidedContext(): ProvidedContext;
654
+ createSpec(moduleId: string, pool: string): WorkspaceSpec;
653
655
  initializeGlobalSetup(): Promise<void>;
654
656
  teardownGlobalSetup(): Promise<void>;
655
657
  get logger(): Logger;
@@ -657,9 +659,13 @@ declare class WorkspaceProject {
657
659
  getModuleById(id: string): vite.ModuleNode | undefined;
658
660
  getSourceMapModuleById(id: string): TransformResult$1['map'] | undefined;
659
661
  get reporters(): Reporter[];
660
- globTestFiles(filters?: string[]): Promise<string[]>;
662
+ globTestFiles(filters?: string[]): Promise<{
663
+ testFiles: string[];
664
+ typecheckTestFiles: string[];
665
+ }>;
661
666
  globAllTestFiles(include: string[], exclude: string[], includeSource: string[] | undefined, cwd: string): Promise<string[]>;
662
667
  isTestFile(id: string): boolean | null;
668
+ isTypecheckFile(id: string): boolean | null;
663
669
  globFiles(include: string[], exclude: string[], cwd: string): Promise<string[]>;
664
670
  isTargetFile(id: string, source?: string): Promise<boolean>;
665
671
  isInSourceTestFile(code: string): boolean;
@@ -675,7 +681,48 @@ declare class WorkspaceProject {
675
681
  initBrowserProvider(): Promise<void>;
676
682
  }
677
683
 
678
- type WorkspaceSpec = [project: WorkspaceProject, testFile: string];
684
+ declare class WorkspaceSpec$1 {
685
+ /**
686
+ * @deprecated
687
+ */
688
+ readonly 0: WorkspaceProject;
689
+ /**
690
+ * @deprecated
691
+ */
692
+ readonly 1: string;
693
+ /**
694
+ * @deprecated
695
+ */
696
+ readonly 2: {
697
+ pool: Pool;
698
+ };
699
+ readonly project: TestProject;
700
+ readonly moduleId: string;
701
+ readonly pool: Pool;
702
+ constructor(workspaceProject: WorkspaceProject, moduleId: string, pool: Pool);
703
+ /**
704
+ * for backwards compatibility
705
+ * @deprecated
706
+ */
707
+ [Symbol.iterator](): Generator<string | WorkspaceProject, void, unknown>;
708
+ }
709
+
710
+ type WorkspaceSpec = WorkspaceSpec$1 & [
711
+ /**
712
+ * @deprecated use spec.project instead
713
+ */
714
+ project: WorkspaceProject,
715
+ /**
716
+ * @deprecated use spec.moduleId instead
717
+ */
718
+ file: string,
719
+ /**
720
+ * @deprecated use spec.pool instead
721
+ */
722
+ options: {
723
+ pool: Pool;
724
+ }
725
+ ];
679
726
  type RunWithFiles = (files: WorkspaceSpec[], invalidates?: string[]) => Awaitable$1<void>;
680
727
  interface ProcessPool {
681
728
  name: string;
@@ -698,11 +745,11 @@ declare class ReportedTaskImplementation {
698
745
  /**
699
746
  * Unique identifier.
700
747
  * This ID is deterministic and will be the same for the same test across multiple runs.
701
- * The ID is based on the project name, file path and test position.
748
+ * The ID is based on the project name, module url and test position.
702
749
  */
703
750
  readonly id: string;
704
751
  /**
705
- * Location in the file where the test or suite is defined.
752
+ * Location in the module where the test or suite is defined.
706
753
  */
707
754
  readonly location: {
708
755
  line: number;
@@ -712,16 +759,16 @@ declare class ReportedTaskImplementation {
712
759
  /**
713
760
  * Creates a new reported task instance and stores it in the project's state for future use.
714
761
  */
715
- static register(task: Task, project: WorkspaceProject): TestCase | TestSuite | TestFile;
762
+ static register(task: Task, project: WorkspaceProject): TestCase | TestSuite | TestModule;
716
763
  }
717
764
  declare class TestCase extends ReportedTaskImplementation {
718
765
  #private;
719
766
  readonly task: Test | Custom;
720
767
  readonly type = "test";
721
768
  /**
722
- * Direct reference to the test file where the test or suite is defined.
769
+ * Direct reference to the test module where the test or suite is defined.
723
770
  */
724
- readonly file: TestFile;
771
+ readonly module: TestModule;
725
772
  /**
726
773
  * Name of the test.
727
774
  */
@@ -731,9 +778,9 @@ declare class TestCase extends ReportedTaskImplementation {
731
778
  */
732
779
  readonly options: TaskOptions;
733
780
  /**
734
- * Parent suite. If the test was called directly inside the file, the parent will be the file.
781
+ * Parent suite. If the test was called directly inside the module, the parent will be the module itself.
735
782
  */
736
- readonly parent: TestSuite | TestFile;
783
+ readonly parent: TestSuite | TestModule;
737
784
  protected constructor(task: Test | Custom, project: WorkspaceProject);
738
785
  /**
739
786
  * Full name of the test including all parent suites separated with `>`.
@@ -809,13 +856,13 @@ declare class TestSuite extends SuiteImplementation {
809
856
  */
810
857
  readonly name: string;
811
858
  /**
812
- * Direct reference to the test file where the test or suite is defined.
859
+ * Direct reference to the test module where the test or suite is defined.
813
860
  */
814
- readonly file: TestFile;
861
+ readonly module: TestModule;
815
862
  /**
816
- * Parent suite. If suite was called directly inside the file, the parent will be the file.
863
+ * Parent suite. If suite was called directly inside the module, the parent will be the module itself.
817
864
  */
818
- readonly parent: TestSuite | TestFile;
865
+ readonly parent: TestSuite | TestModule;
819
866
  /**
820
867
  * Options that suite was initiated with.
821
868
  */
@@ -826,10 +873,10 @@ declare class TestSuite extends SuiteImplementation {
826
873
  */
827
874
  get fullName(): string;
828
875
  }
829
- declare class TestFile extends SuiteImplementation {
876
+ declare class TestModule extends SuiteImplementation {
830
877
  readonly task: File;
831
878
  readonly location: undefined;
832
- readonly type = "file";
879
+ readonly type = "module";
833
880
  /**
834
881
  * This is usually an absolute UNIX file path.
835
882
  * It can be a virtual id if the file is not on the disk.
@@ -838,10 +885,10 @@ declare class TestFile extends SuiteImplementation {
838
885
  readonly moduleId: string;
839
886
  protected constructor(task: File, project: WorkspaceProject);
840
887
  /**
841
- * Useful information about the file like duration, memory usage, etc.
842
- * If the file was not executed yet, all diagnostic values will return `0`.
888
+ * Useful information about the module like duration, memory usage, etc.
889
+ * If the module was not executed yet, all diagnostic values will return `0`.
843
890
  */
844
- diagnostic(): FileDiagnostic;
891
+ diagnostic(): ModuleDiagnostic;
845
892
  }
846
893
  interface TaskOptions {
847
894
  each: boolean | undefined;
@@ -913,7 +960,7 @@ interface TestDiagnostic {
913
960
  */
914
961
  flaky: boolean;
915
962
  }
916
- interface FileDiagnostic {
963
+ interface ModuleDiagnostic {
917
964
  /**
918
965
  * The time it takes to import and initiate an environment.
919
966
  */
@@ -923,16 +970,16 @@ interface FileDiagnostic {
923
970
  */
924
971
  prepareDuration: number;
925
972
  /**
926
- * The time it takes to import the test file.
927
- * This includes importing everything in the file and executing suite callbacks.
973
+ * The time it takes to import the test module.
974
+ * This includes importing everything in the module and executing suite callbacks.
928
975
  */
929
976
  collectDuration: number;
930
977
  /**
931
- * The time it takes to import the setup file.
978
+ * The time it takes to import the setup module.
932
979
  */
933
980
  setupDuration: number;
934
981
  /**
935
- * Accumulated duration of all tests and hooks in the file.
982
+ * Accumulated duration of all tests and hooks in the module.
936
983
  */
937
984
  duration: number;
938
985
  }
@@ -944,7 +991,7 @@ declare class StateManager {
944
991
  taskFileMap: WeakMap<Task, File>;
945
992
  errorsSet: Set<unknown>;
946
993
  processTimeoutCauses: Set<string>;
947
- reportedTasksMap: WeakMap<Task, TestCase | TestSuite | TestFile>;
994
+ reportedTasksMap: WeakMap<Task, TestCase | TestSuite | TestModule>;
948
995
  catchError(err: unknown, type: string): void;
949
996
  clearErrors(): void;
950
997
  getUnhandledErrors(): unknown[];
@@ -961,7 +1008,7 @@ declare class StateManager {
961
1008
  collectFiles(project: WorkspaceProject, files?: File[]): void;
962
1009
  clearFiles(project: WorkspaceProject, paths?: string[]): void;
963
1010
  updateId(task: Task, project: WorkspaceProject): void;
964
- getReportedEntity(task: Task): TestCase | TestSuite | TestFile | undefined;
1011
+ getReportedEntity(task: Task): TestCase | TestSuite | TestModule | undefined;
965
1012
  updateTasks(packs: TaskResultPack[]): void;
966
1013
  updateUserLog(log: UserConsoleLog): void;
967
1014
  getCountOfFailedTests(): number;
@@ -1261,6 +1308,17 @@ interface BaseCoverageOptions {
1261
1308
  * @default false
1262
1309
  */
1263
1310
  allowExternal?: boolean;
1311
+ /**
1312
+ * Apply exclusions again after coverage has been remapped to original sources.
1313
+ * This is useful when your source files are transpiled and may contain source maps
1314
+ * of non-source files.
1315
+ *
1316
+ * Use this option when you are seeing files that show up in report even if they
1317
+ * match your `coverage.exclude` patterns.
1318
+ *
1319
+ * @default false
1320
+ */
1321
+ excludeAfterRemap?: boolean;
1264
1322
  /**
1265
1323
  * Concurrency limit used when processing the coverage results.
1266
1324
  * Defaults to `Math.min(20, os.availableParallelism?.() ?? os.cpus().length)`
@@ -1340,8 +1398,10 @@ declare class Vitest {
1340
1398
  private coreWorkspaceProject;
1341
1399
  private resolvedProjects;
1342
1400
  projects: WorkspaceProject[];
1343
- private projectsTestFiles;
1344
1401
  distPath: string;
1402
+ private _cachedSpecs;
1403
+ /** @deprecated use `_cachedSpecs` */
1404
+ projectTestFiles: Map<string, WorkspaceSpec[]>;
1345
1405
  constructor(mode: VitestRunMode, options?: VitestOptions);
1346
1406
  private _onRestartListeners;
1347
1407
  private _onClose;
@@ -1349,8 +1409,18 @@ declare class Vitest {
1349
1409
  private _onCancelListeners;
1350
1410
  setServer(options: UserConfig, server: ViteDevServer, cliOptions: UserConfig): Promise<void>;
1351
1411
  provide<T extends keyof ProvidedContext & string>(key: T, value: ProvidedContext[T]): void;
1352
- private createCoreProject;
1412
+ /**
1413
+ * @deprecated internal, use `_createCoreProject` instead
1414
+ */
1415
+ createCoreProject(): Promise<WorkspaceProject>;
1416
+ /**
1417
+ * @internal
1418
+ */
1419
+ _createCoreProject(): Promise<WorkspaceProject>;
1353
1420
  getCoreWorkspaceProject(): WorkspaceProject;
1421
+ /**
1422
+ * @deprecated use Reported Task API instead
1423
+ */
1354
1424
  getProjectByTaskId(taskId: string): WorkspaceProject;
1355
1425
  getProjectByName(name?: string): WorkspaceProject;
1356
1426
  private getWorkspaceConfigPath;
@@ -1366,7 +1436,11 @@ declare class Vitest {
1366
1436
  init(): Promise<void>;
1367
1437
  private getTestDependencies;
1368
1438
  filterTestsBySource(specs: WorkspaceSpec[]): Promise<WorkspaceSpec[]>;
1439
+ /**
1440
+ * @deprecated remove when vscode extension supports "getFileWorkspaceSpecs"
1441
+ */
1369
1442
  getProjectsByTestFile(file: string): WorkspaceSpec[];
1443
+ getFileWorkspaceSpecs(file: string): WorkspaceSpec[];
1370
1444
  initializeGlobalSetup(paths: WorkspaceSpec[]): Promise<void>;
1371
1445
  private initializeDistPath;
1372
1446
  runFiles(specs: WorkspaceSpec[], allTestsRun: boolean): Promise<void>;
@@ -1399,7 +1473,12 @@ declare class Vitest {
1399
1473
  exit(force?: boolean): Promise<void>;
1400
1474
  report<T extends keyof Reporter>(name: T, ...args: ArgumentsType<Reporter[T]>): Promise<void>;
1401
1475
  getTestFilepaths(): Promise<string[]>;
1476
+ globTestSpecs(filters?: string[]): Promise<WorkspaceSpec[]>;
1477
+ /**
1478
+ * @deprecated use globTestSpecs instead
1479
+ */
1402
1480
  globTestFiles(filters?: string[]): Promise<WorkspaceSpec[]>;
1481
+ private ensureSpecCached;
1403
1482
  shouldKeepServer(): boolean;
1404
1483
  onServerRestart(fn: OnServerRestartHandler): void;
1405
1484
  onAfterSetServer(fn: OnServerRestartHandler): void;
@@ -1412,7 +1491,10 @@ type SerializedSpec = [
1412
1491
  name: string | undefined;
1413
1492
  root: string;
1414
1493
  },
1415
- file: string
1494
+ file: string,
1495
+ options: {
1496
+ pool: string;
1497
+ }
1416
1498
  ];
1417
1499
 
1418
1500
  interface Reporter {
@@ -1699,6 +1781,16 @@ declare const BenchmarkReportsMap: {
1699
1781
  };
1700
1782
  type BenchmarkBuiltinReporters = keyof typeof BenchmarkReportsMap;
1701
1783
 
1784
+ /**
1785
+ * @deprecated Use `TestModule` instead
1786
+ */
1787
+ declare const TestFile: typeof TestModule;
1788
+
1789
+ /**
1790
+ * @deprecated Use `ModuleDiagnostic` instead
1791
+ */
1792
+ type FileDiagnostic = ModuleDiagnostic;
1793
+
1702
1794
  declare const ReportersMap: {
1703
1795
  default: typeof DefaultReporter;
1704
1796
  basic: typeof BasicReporter;
@@ -1781,83 +1873,6 @@ interface BenchmarkUserOptions {
1781
1873
  outputJson?: string;
1782
1874
  }
1783
1875
 
1784
- declare const defaultBrowserPort = 63315;
1785
- declare const extraInlineDeps: RegExp[];
1786
-
1787
- declare const defaultInclude: string[];
1788
- declare const defaultExclude: string[];
1789
- declare const coverageConfigDefaults: ResolvedCoverageOptions;
1790
- declare const configDefaults: Readonly<{
1791
- allowOnly: boolean;
1792
- isolate: true;
1793
- watch: boolean;
1794
- globals: false;
1795
- environment: "node";
1796
- pool: "forks";
1797
- clearMocks: false;
1798
- restoreMocks: false;
1799
- mockReset: false;
1800
- unstubGlobals: false;
1801
- unstubEnvs: false;
1802
- include: string[];
1803
- exclude: string[];
1804
- teardownTimeout: number;
1805
- forceRerunTriggers: string[];
1806
- update: false;
1807
- reporters: never[];
1808
- silent: false;
1809
- hideSkippedTests: false;
1810
- api: false;
1811
- ui: false;
1812
- uiBase: string;
1813
- open: boolean;
1814
- css: {
1815
- include: never[];
1816
- };
1817
- coverage: CoverageV8Options;
1818
- fakeTimers: {
1819
- loopLimit: number;
1820
- shouldClearNativeTimers: true;
1821
- toFake: ("setTimeout" | "setInterval" | "clearInterval" | "clearTimeout" | "setImmediate" | "clearImmediate" | "Date")[];
1822
- };
1823
- maxConcurrency: number;
1824
- dangerouslyIgnoreUnhandledErrors: false;
1825
- typecheck: {
1826
- checker: "tsc";
1827
- include: string[];
1828
- exclude: string[];
1829
- };
1830
- slowTestThreshold: number;
1831
- disableConsoleIntercept: false;
1832
- }>;
1833
-
1834
- interface UserWorkspaceConfig extends UserConfig$1 {
1835
- test?: ProjectConfig;
1836
- }
1837
-
1838
- type UserConfigFnObject = (env: ConfigEnv) => UserConfig$1;
1839
- type UserConfigFnPromise = (env: ConfigEnv) => Promise<UserConfig$1>;
1840
- type UserConfigFn = (env: ConfigEnv) => UserConfig$1 | Promise<UserConfig$1>;
1841
- type UserConfigExport = UserConfig$1 | Promise<UserConfig$1> | UserConfigFnObject | UserConfigFnPromise | UserConfigFn;
1842
- type UserProjectConfigFn = (env: ConfigEnv) => UserWorkspaceConfig | Promise<UserWorkspaceConfig>;
1843
- type UserProjectConfigExport = UserWorkspaceConfig | Promise<UserWorkspaceConfig> | UserProjectConfigFn;
1844
- declare function defineConfig(config: UserConfig$1): UserConfig$1;
1845
- declare function defineConfig(config: Promise<UserConfig$1>): Promise<UserConfig$1>;
1846
- declare function defineConfig(config: UserConfigFnObject): UserConfigFnObject;
1847
- declare function defineConfig(config: UserConfigExport): UserConfigExport;
1848
- declare function defineProject(config: UserWorkspaceConfig): UserWorkspaceConfig;
1849
- declare function defineProject(config: Promise<UserWorkspaceConfig>): Promise<UserWorkspaceConfig>;
1850
- declare function defineProject(config: UserProjectConfigFn): UserProjectConfigFn;
1851
- declare function defineProject(config: UserProjectConfigExport): UserProjectConfigExport;
1852
- type WorkspaceProjectConfiguration = string | (UserProjectConfigExport & {
1853
- /**
1854
- * Relative path to the extendable config. All other options will be merged with this config.
1855
- * @example '../vite.config.ts'
1856
- */
1857
- extends?: string;
1858
- });
1859
- declare function defineWorkspace(config: WorkspaceProjectConfiguration[]): WorkspaceProjectConfiguration[];
1860
-
1861
1876
  type BuiltinEnvironment = 'node' | 'jsdom' | 'happy-dom' | 'edge-runtime';
1862
1877
  type VitestEnvironment = BuiltinEnvironment | (string & Record<never, never>);
1863
1878
 
@@ -2703,15 +2718,17 @@ type ProjectConfig = Omit<UserConfig, NonProjectOptions | 'sequencer' | 'deps' |
2703
2718
  };
2704
2719
  };
2705
2720
  type ResolvedProjectConfig = Omit<ResolvedConfig, NonProjectOptions>;
2706
-
2707
- type VitestInlineConfig = InlineConfig;
2708
- declare module 'vite' {
2709
- interface UserConfig {
2710
- /**
2711
- * Options for Vitest
2712
- */
2713
- test?: VitestInlineConfig;
2714
- }
2721
+ interface UserWorkspaceConfig extends UserConfig$1 {
2722
+ test?: ProjectConfig;
2715
2723
  }
2724
+ type UserProjectConfigFn = (env: ConfigEnv) => UserWorkspaceConfig | Promise<UserWorkspaceConfig>;
2725
+ type UserProjectConfigExport = UserWorkspaceConfig | Promise<UserWorkspaceConfig> | UserProjectConfigFn;
2726
+ type WorkspaceProjectConfiguration = string | (UserProjectConfigExport & {
2727
+ /**
2728
+ * Relative path to the extendable config. All other options will be merged with this config.
2729
+ * @example '../vite.config.ts'
2730
+ */
2731
+ extends?: string;
2732
+ });
2716
2733
 
2717
- export { type BrowserBuiltinProvider as $, type ApiConfig as A, type BaseCoverageOptions as B, type CoverageProvider as C, type DepsOptimizationOptions as D, type BenchmarkUserOptions as E, type VitestOptions as F, type TestSequencer as G, type WorkspaceSpec as H, type InlineConfig as I, type ProcessPool as J, getFilePoolName as K, Logger as L, VitestPackageInstaller as M, type TestSequencerConstructor as N, type BrowserProviderInitializationOptions as O, type Pool as P, type BrowserProvider as Q, type ResolvedCoverageOptions as R, type SerializedSpec as S, type TscErrorInfo as T, type UserConfig as U, type VitestEnvironment as V, WorkspaceProject as W, type CDPSession as X, type BrowserProviderModule as Y, type ResolvedBrowserOptions as Z, type BrowserProviderOptions as _, type CoverageProviderModule as a, type BrowserCommand as a0, type BrowserCommandContext as a1, type BrowserServer as a2, type BrowserServerState as a3, type BrowserServerStateContext as a4, type BrowserOrchestrator as a5, type JsonOptions as a6, type JUnitOptions as a7, type HTMLOptions as a8, TestCase as a9, extraInlineDeps as aA, DefaultReporter as aB, BasicReporter as aC, DotReporter as aD, JsonReporter as aE, VerboseReporter as aF, TapReporter as aG, JUnitReporter as aH, TapFlatReporter as aI, HangingProcessReporter as aJ, GithubActionsReporter as aK, BaseReporter as aL, ReportersMap as aM, type BuiltinReporters as aN, type BuiltinReporterOptions as aO, type JsonAssertionResult as aP, type JsonTestResult as aQ, type JsonTestResults as aR, BenchmarkReportsMap as aS, type BenchmarkBuiltinReporters as aT, TestFile as aa, TestSuite as ab, TestProject as ac, TestCollection as ad, type TaskOptions as ae, type TestDiagnostic as af, type FileDiagnostic as ag, type TestResult as ah, type TestResultPassed as ai, type TestResultFailed as aj, type TestResultSkipped as ak, type ResolvedProjectConfig as al, type UserConfigFnObject as am, type UserConfigFnPromise as an, type UserConfigFn as ao, type UserConfigExport as ap, type UserProjectConfigFn as aq, type UserProjectConfigExport as ar, defineConfig as as, defineProject as at, defineWorkspace as au, defaultBrowserPort as av, configDefaults as aw, defaultInclude as ax, defaultExclude as ay, coverageConfigDefaults as az, type RawErrsMap as b, type CollectLineNumbers as c, type CollectLines as d, type RootAndTarget as e, type Context as f, type ReportContext as g, type CoverageReporter as h, type CoverageProviderName as i, type CoverageOptions as j, type CoverageIstanbulOptions as k, type CoverageV8Options as l, type CustomProviderOptions as m, type Reporter as n, Vitest as o, type BrowserScript as p, type BrowserConfigOptions as q, type BuiltinEnvironment as r, type PoolOptions as s, type CSSModuleScopeStrategy as t, type VitestRunMode as u, type TransformModePatterns as v, type TypecheckConfig as w, type ResolvedConfig as x, type ProjectConfig as y, type UserWorkspaceConfig as z };
2734
+ export { type BrowserProvider as $, type ApiConfig as A, type BaseCoverageOptions as B, type CoverageProvider as C, type DepsOptimizationOptions as D, type ResolvedConfig as E, type ProjectConfig as F, type BenchmarkUserOptions as G, type VitestOptions as H, type InlineConfig as I, WorkspaceProject as J, type TestSequencer as K, Logger as L, type WorkspaceSpec as M, TestModule as N, type ModuleDiagnostic as O, type Pool as P, type ProcessPool as Q, type ResolvedCoverageOptions as R, type SerializedSpec as S, type TscErrorInfo as T, type UserWorkspaceConfig as U, Vitest as V, type WorkspaceProjectConfiguration as W, getFilePoolName as X, VitestPackageInstaller as Y, type TestSequencerConstructor as Z, type BrowserProviderInitializationOptions as _, type CoverageProviderModule as a, type CDPSession as a0, type BrowserProviderModule as a1, type ResolvedBrowserOptions as a2, type BrowserProviderOptions as a3, type BrowserBuiltinProvider as a4, type BrowserCommand as a5, type BrowserCommandContext as a6, type BrowserServer as a7, type BrowserServerState as a8, type BrowserServerStateContext as a9, TestFile as aA, type FileDiagnostic as aB, ReportersMap as aC, type BuiltinReporters as aD, type BuiltinReporterOptions as aE, type JsonAssertionResult as aF, type JsonTestResult as aG, type JsonTestResults as aH, BenchmarkReportsMap as aI, type BenchmarkBuiltinReporters as aJ, type BrowserOrchestrator as aa, type JsonOptions as ab, type JUnitOptions as ac, type HTMLOptions as ad, TestCase as ae, TestSuite as af, TestProject as ag, TestCollection as ah, type TaskOptions as ai, type TestDiagnostic as aj, type TestResult as ak, type TestResultPassed as al, type TestResultFailed as am, type TestResultSkipped as an, type ResolvedProjectConfig as ao, DefaultReporter as ap, BasicReporter as aq, DotReporter as ar, JsonReporter as as, VerboseReporter as at, TapReporter as au, JUnitReporter as av, TapFlatReporter as aw, HangingProcessReporter as ax, GithubActionsReporter as ay, BaseReporter as az, type CoverageV8Options as b, type UserProjectConfigFn as c, type UserProjectConfigExport as d, type VitestEnvironment as e, type RawErrsMap as f, type CollectLineNumbers as g, type CollectLines as h, type RootAndTarget as i, type Context as j, type ReportContext as k, type CoverageReporter as l, type CoverageProviderName as m, type CoverageOptions as n, type CoverageIstanbulOptions as o, type CustomProviderOptions as p, type Reporter as q, type BrowserScript as r, type BrowserConfigOptions as s, type BuiltinEnvironment as t, type PoolOptions as u, type CSSModuleScopeStrategy as v, type VitestRunMode as w, type TransformModePatterns as x, type TypecheckConfig as y, type UserConfig as z };
@@ -9,7 +9,7 @@ import assert from 'node:assert';
9
9
  import v8 from 'node:v8';
10
10
  import { format, inspect } from 'node:util';
11
11
  import c from 'tinyrainbow';
12
- import { e as extraInlineDeps, d as defaultPort, a as defaultBrowserPort, b as defaultInspectPort } from './constants.CaAN7icJ.js';
12
+ import { e as extraInlineDeps, d as defaultPort, a as defaultBrowserPort, b as defaultInspectPort } from './constants.fzPh7AOq.js';
13
13
  import * as nodeos from 'node:os';
14
14
  import nodeos__default from 'node:os';
15
15
  import { i as isWindows } from './env.CmHVDJnw.js';
@@ -18,7 +18,7 @@ import { hasFailed } from '@vitest/runner/utils';
18
18
  import { b as groupBy, A as AggregateErrorPonyfill, a as slash, t as toArray } from './base.BH-FAiX7.js';
19
19
  import { createDefer } from '@vitest/utils';
20
20
  import crypto, { createHash } from 'node:crypto';
21
- import { w as wrapSerializableConfig, T as Typechecker, R as RandomSequencer, B as BaseSequencer } from './RandomSequencer.B4M2ux5b.js';
21
+ import { w as wrapSerializableConfig, T as Typechecker, R as RandomSequencer, B as BaseSequencer } from './RandomSequencer.CjkAy_bL.js';
22
22
  import { g as getDefaultExportFromCjs } from './_commonjsHelpers.BFTU3MAI.js';
23
23
  import require$$0 from 'util';
24
24
  import p from 'path';
@@ -4010,7 +4010,9 @@ function getTransformMode(patterns, filename) {
4010
4010
  }
4011
4011
  async function groupFilesByEnv(files) {
4012
4012
  const filesWithEnv = await Promise.all(
4013
- files.map(async ([project, file]) => {
4013
+ files.map(async (spec) => {
4014
+ const file = spec.moduleId;
4015
+ const project = spec.project.workspaceProject;
4014
4016
  const code = await promises$1.readFile(file, "utf-8");
4015
4017
  let env = code.match(/@(?:vitest|jest)-environment\s+([\w-]+)\b/)?.[1];
4016
4018
  if (!env) {
@@ -4237,16 +4239,18 @@ function createForksPool(ctx, { execArgv, env }) {
4237
4239
  return config;
4238
4240
  };
4239
4241
  const workspaceMap = /* @__PURE__ */ new Map();
4240
- for (const [project, file] of specs) {
4242
+ for (const spec of specs) {
4243
+ const file = spec.moduleId;
4244
+ const project = spec.project.workspaceProject;
4241
4245
  const workspaceFiles = workspaceMap.get(file) ?? [];
4242
4246
  workspaceFiles.push(project);
4243
4247
  workspaceMap.set(file, workspaceFiles);
4244
4248
  }
4245
4249
  const singleFork = specs.filter(
4246
- ([project]) => project.config.poolOptions?.forks?.singleFork
4250
+ (spec) => spec.project.config.poolOptions?.forks?.singleFork
4247
4251
  );
4248
4252
  const multipleForks = specs.filter(
4249
- ([project]) => !project.config.poolOptions?.forks?.singleFork
4253
+ (spec) => !spec.project.config.poolOptions?.forks?.singleFork
4250
4254
  );
4251
4255
  if (multipleForks.length) {
4252
4256
  const filesByEnv = await groupFilesByEnv(multipleForks);
@@ -4439,10 +4443,10 @@ See https://vitest.dev/guide/common-errors.html#failed-to-terminate-worker for t
4439
4443
  workspaceMap.set(file, workspaceFiles);
4440
4444
  }
4441
4445
  const singleThreads = specs.filter(
4442
- ([project]) => project.config.poolOptions?.threads?.singleThread
4446
+ (spec) => spec.project.config.poolOptions?.threads?.singleThread
4443
4447
  );
4444
4448
  const multipleThreads = specs.filter(
4445
- ([project]) => !project.config.poolOptions?.threads?.singleThread
4449
+ (spec) => !spec.project.config.poolOptions?.threads?.singleThread
4446
4450
  );
4447
4451
  if (multipleThreads.length) {
4448
4452
  const filesByEnv = await groupFilesByEnv(multipleThreads);
@@ -4740,7 +4744,7 @@ function getMemoryLimit$1(config) {
4740
4744
 
4741
4745
  function createTypecheckPool(ctx) {
4742
4746
  const promisesMap = /* @__PURE__ */ new WeakMap();
4743
- const rerunTriggered = /* @__PURE__ */ new WeakMap();
4747
+ const rerunTriggered = /* @__PURE__ */ new WeakSet();
4744
4748
  async function onParseEnd(project, { files, sourceErrors }) {
4745
4749
  const checker = project.typechecker;
4746
4750
  await ctx.report("onTaskUpdate", checker.getTestPacks());
@@ -4756,7 +4760,7 @@ function createTypecheckPool(ctx) {
4756
4760
  ctx.state.catchError(error, "Typecheck Error");
4757
4761
  }
4758
4762
  promisesMap.get(project)?.resolve();
4759
- rerunTriggered.set(project, false);
4763
+ rerunTriggered.delete(project);
4760
4764
  if (ctx.config.watch && !ctx.runningPromise) {
4761
4765
  await ctx.report("onFinished", files, []);
4762
4766
  await ctx.report("onWatcherStart", files, [
@@ -4778,7 +4782,7 @@ function createTypecheckPool(ctx) {
4778
4782
  });
4779
4783
  checker.onParseEnd((result) => onParseEnd(project, result));
4780
4784
  checker.onWatcherRerun(async () => {
4781
- rerunTriggered.set(project, true);
4785
+ rerunTriggered.add(project);
4782
4786
  if (!ctx.runningPromise) {
4783
4787
  ctx.state.clearErrors();
4784
4788
  await ctx.report(
@@ -4804,19 +4808,19 @@ function createTypecheckPool(ctx) {
4804
4808
  await checker.start();
4805
4809
  }
4806
4810
  async function collectTests(specs) {
4807
- const specsByProject = groupBy(specs, ([project]) => project.getName());
4811
+ const specsByProject = groupBy(specs, (spec) => spec.project.name);
4808
4812
  for (const name in specsByProject) {
4809
- const project = specsByProject[name][0][0];
4810
- const files = specsByProject[name].map(([_, file]) => file);
4811
- const checker = await createWorkspaceTypechecker(project, files);
4813
+ const project = specsByProject[name][0].project;
4814
+ const files = specsByProject[name].map((spec) => spec.moduleId);
4815
+ const checker = await createWorkspaceTypechecker(project.workspaceProject, files);
4812
4816
  checker.setFiles(files);
4813
4817
  await checker.collectTests();
4814
- ctx.state.collectFiles(project, checker.getTestFiles());
4818
+ ctx.state.collectFiles(project.workspaceProject, checker.getTestFiles());
4815
4819
  await ctx.report("onCollected");
4816
4820
  }
4817
4821
  }
4818
4822
  async function runTests(specs) {
4819
- const specsByProject = groupBy(specs, ([project]) => project.getName());
4823
+ const specsByProject = groupBy(specs, (spec) => spec.project.name);
4820
4824
  const promises = [];
4821
4825
  for (const name in specsByProject) {
4822
4826
  const project = specsByProject[name][0][0];
@@ -4824,7 +4828,7 @@ function createTypecheckPool(ctx) {
4824
4828
  const promise = createDefer();
4825
4829
  const _p = new Promise((resolve) => {
4826
4830
  const _i = setInterval(() => {
4827
- if (!project.typechecker || rerunTriggered.get(project)) {
4831
+ if (!project.typechecker || rerunTriggered.has(project)) {
4828
4832
  resolve(true);
4829
4833
  clearInterval(_i);
4830
4834
  }
@@ -5013,14 +5017,7 @@ const builtinPools = [
5013
5017
  "vmForks",
5014
5018
  "typescript"
5015
5019
  ];
5016
- function getDefaultPoolName(project, file) {
5017
- if (project.config.typecheck.enabled) {
5018
- for (const glob of project.config.typecheck.include) {
5019
- if (mm.isMatch(file, glob, { cwd: project.config.root })) {
5020
- return "typescript";
5021
- }
5022
- }
5023
- }
5020
+ function getDefaultPoolName(project) {
5024
5021
  if (project.config.browser.enabled) {
5025
5022
  return "browser";
5026
5023
  }
@@ -5037,7 +5034,7 @@ function getFilePoolName(project, file) {
5037
5034
  return pool;
5038
5035
  }
5039
5036
  }
5040
- return getDefaultPoolName(project, file);
5037
+ return getDefaultPoolName(project);
5041
5038
  }
5042
5039
  function createPool(ctx) {
5043
5040
  const pools = {
@@ -5122,7 +5119,7 @@ function createPool(ctx) {
5122
5119
  typescript: () => createTypecheckPool(ctx)
5123
5120
  };
5124
5121
  for (const spec of files) {
5125
- const pool = getFilePoolName(spec[0], spec[1]);
5122
+ const { pool } = spec[2];
5126
5123
  filesByPool[pool] ??= [];
5127
5124
  filesByPool[pool].push(spec);
5128
5125
  }
@@ -7337,6 +7334,7 @@ const coverageConfigDefaults = {
7337
7334
  ".marko"
7338
7335
  ],
7339
7336
  allowExternal: false,
7337
+ excludeAfterRemap: false,
7340
7338
  ignoreEmptyLines: true,
7341
7339
  processingConcurrency: Math.min(
7342
7340
  20,
@@ -7669,10 +7667,21 @@ function resolveConfig(mode, options, viteConfig, logger) {
7669
7667
  );
7670
7668
  }
7671
7669
  }
7672
- if (resolved.coverage.provider === "v8" && resolved.coverage.enabled && isBrowserEnabled(resolved)) {
7673
- throw new Error(
7674
- "@vitest/coverage-v8 does not work with --browser. Use @vitest/coverage-istanbul instead"
7675
- );
7670
+ if (resolved.browser.enabled && resolved.coverage.enabled && resolved.coverage.provider === "v8") {
7671
+ if (!(resolved.browser.provider === "playwright" && resolved.browser.name === "chromium")) {
7672
+ const browserConfig = { browser: { provider: resolved.browser.provider, name: resolved.browser.name } };
7673
+ throw new Error(
7674
+ `@vitest/coverage-v8 does not work with
7675
+ ${JSON.stringify(browserConfig, null, 2)}
7676
+
7677
+ Use either:
7678
+ ${JSON.stringify({ browser: { provider: "playwright", name: "chromium" } }, null, 2)}
7679
+
7680
+ ...or change your coverage provider to:
7681
+ ${JSON.stringify({ coverage: { provider: "istanbul" } }, null, 2)}
7682
+ `
7683
+ );
7684
+ }
7676
7685
  }
7677
7686
  resolved.coverage.reporter = resolveCoverageReporters(resolved.coverage.reporter);
7678
7687
  if (resolved.coverage.enabled && resolved.coverage.reportsDirectory) {
@@ -8118,4 +8127,4 @@ function resolveCoverageReporters(configReporters) {
8118
8127
  return resolvedReporters;
8119
8128
  }
8120
8129
 
8121
- export { VitestCache as V, resolveConfig as a, resolveCoverageReporters as b, createMethodsRPC as c, braces_1 as d, configDefaults as e, isPackageExists as f, getFilePoolName as g, createPool as h, isBrowserEnabled as i, coverageConfigDefaults as j, mm as m, picomatch$1 as p, resolveApiServerConfig as r, utils$4 as u };
8130
+ export { VitestCache as V, resolveApiServerConfig as a, resolveConfig as b, createMethodsRPC as c, braces_1 as d, configDefaults as e, isPackageExists as f, getFilePoolName as g, createPool as h, isBrowserEnabled as i, coverageConfigDefaults as j, mm as m, picomatch$1 as p, resolveCoverageReporters as r, utils$4 as u };