vitest 4.0.0-beta.1 → 4.0.0-beta.10

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 (85) hide show
  1. package/LICENSE.md +2 -2
  2. package/dist/browser.d.ts +13 -14
  3. package/dist/browser.js +6 -5
  4. package/dist/chunks/base.Cjha6usc.js +129 -0
  5. package/dist/chunks/{benchmark.CYdenmiT.js → benchmark.CJUa-Hsa.js} +6 -8
  6. package/dist/chunks/{benchmark.d.BwvBVTda.d.ts → benchmark.d.DAaHLpsq.d.ts} +4 -4
  7. package/dist/chunks/{browser.d.q8Z0P0q1.d.ts → browser.d.yFAklsD1.d.ts} +5 -5
  8. package/dist/chunks/{cac.D3EzDDZd.js → cac.DCxo_nSu.js} +70 -152
  9. package/dist/chunks/{cli-api.Dn5gKePv.js → cli-api.BJJXh9BV.js} +1330 -1677
  10. package/dist/chunks/{config.d.HJdfX-8k.d.ts → config.d.B_LthbQq.d.ts} +58 -63
  11. package/dist/chunks/{console.CtFJOzRO.js → console.7h5kHUIf.js} +34 -70
  12. package/dist/chunks/{constants.DnKduX2e.js → constants.D_Q9UYh-.js} +1 -9
  13. package/dist/chunks/{coverage.Cwa-XhJt.js → coverage.BCU-r2QL.js} +515 -781
  14. package/dist/chunks/{coverage.DVF1vEu8.js → coverage.D_JHT54q.js} +2 -2
  15. package/dist/chunks/{coverage.d.S9RMNXIe.d.ts → coverage.d.BZtK59WP.d.ts} +10 -8
  16. package/dist/chunks/{creator.GK6I-cL4.js → creator.08Gi-vCA.js} +93 -77
  17. package/dist/chunks/{date.Bq6ZW5rf.js → date.-jtEtIeV.js} +6 -17
  18. package/dist/chunks/{environment.d.CUq4cUgQ.d.ts → environment.d.BsToaxti.d.ts} +27 -6
  19. package/dist/chunks/{git.BVQ8w_Sw.js → git.BFNcloKD.js} +1 -2
  20. package/dist/chunks/{global.d.CVbXEflG.d.ts → global.d.BK3X7FW1.d.ts} +2 -5
  21. package/dist/chunks/{globals.Cxal6MLI.js → globals.DG-S3xFe.js} +8 -8
  22. package/dist/chunks/{index.CZI_8rVt.js → index.BIP7prJq.js} +289 -608
  23. package/dist/chunks/{index.B521nVV-.js → index.Bgo3tNWt.js} +23 -4
  24. package/dist/chunks/{index.TfbsX-3I.js → index.BjKEiSn0.js} +14 -24
  25. package/dist/chunks/{index.BWf_gE5n.js → index.CMfqw92x.js} +7 -6
  26. package/dist/chunks/{index.CmSc2RE5.js → index.DIWhzsUh.js} +72 -118
  27. package/dist/chunks/{inspector.C914Efll.js → inspector.CvQD-Nie.js} +10 -25
  28. package/dist/chunks/moduleRunner.d.D9nBoC4p.d.ts +201 -0
  29. package/dist/chunks/moduleTransport.I-bgQy0S.js +19 -0
  30. package/dist/chunks/{node.fjCdwEIl.js → node.CyipiPvJ.js} +1 -1
  31. package/dist/chunks/{plugin.d.C2EcJUjo.d.ts → plugin.d.BMVSnsGV.d.ts} +1 -1
  32. package/dist/chunks/{reporters.d.DxZg19fy.d.ts → reporters.d.BUWjmRYq.d.ts} +1226 -1291
  33. package/dist/chunks/resolveSnapshotEnvironment.Bkht6Yor.js +81 -0
  34. package/dist/chunks/resolver.Bx6lE0iq.js +119 -0
  35. package/dist/chunks/rpc.BKr6mtxz.js +65 -0
  36. package/dist/chunks/{setup-common.D7ZqXFx-.js → setup-common.uiMcU3cv.js} +17 -29
  37. package/dist/chunks/startModuleRunner.p67gbNo9.js +665 -0
  38. package/dist/chunks/{suite.d.FvehnV49.d.ts → suite.d.BJWk38HB.d.ts} +1 -1
  39. package/dist/chunks/test.BiqSKISg.js +214 -0
  40. package/dist/chunks/{typechecker.CVytUJuF.js → typechecker.DB-fIMaH.js} +144 -213
  41. package/dist/chunks/{utils.CAioKnHs.js → utils.C2YI6McM.js} +5 -14
  42. package/dist/chunks/{utils.XdZDrNZV.js → utils.D2R2NiOH.js} +8 -27
  43. package/dist/chunks/{vi.bdSIJ99Y.js → vi.ZPgvtBao.js} +156 -305
  44. package/dist/chunks/{vm.BThCzidc.js → vm.Ca0Y0W5f.js} +116 -226
  45. package/dist/chunks/{worker.d.DoNjFAiv.d.ts → worker.d.BDsXGkwh.d.ts} +28 -22
  46. package/dist/chunks/{worker.d.CmvJfRGs.d.ts → worker.d.BNcX_2mH.d.ts} +1 -1
  47. package/dist/cli.js +4 -4
  48. package/dist/config.cjs +3 -9
  49. package/dist/config.d.ts +49 -54
  50. package/dist/config.js +1 -1
  51. package/dist/coverage.d.ts +27 -26
  52. package/dist/coverage.js +6 -7
  53. package/dist/environments.d.ts +9 -13
  54. package/dist/environments.js +1 -1
  55. package/dist/index.d.ts +38 -45
  56. package/dist/index.js +7 -9
  57. package/dist/module-evaluator.d.ts +13 -0
  58. package/dist/module-evaluator.js +276 -0
  59. package/dist/module-runner.js +15 -0
  60. package/dist/node.d.ts +40 -41
  61. package/dist/node.js +23 -33
  62. package/dist/reporters.d.ts +12 -13
  63. package/dist/reporters.js +3 -3
  64. package/dist/runners.d.ts +3 -3
  65. package/dist/runners.js +13 -232
  66. package/dist/snapshot.js +2 -2
  67. package/dist/suite.d.ts +2 -2
  68. package/dist/suite.js +2 -2
  69. package/dist/worker.js +90 -47
  70. package/dist/workers/forks.js +34 -10
  71. package/dist/workers/runVmTests.js +36 -56
  72. package/dist/workers/threads.js +34 -10
  73. package/dist/workers/vmForks.js +11 -10
  74. package/dist/workers/vmThreads.js +11 -10
  75. package/dist/workers.d.ts +5 -4
  76. package/dist/workers.js +35 -17
  77. package/globals.d.ts +17 -17
  78. package/package.json +32 -31
  79. package/dist/chunks/base.Bj3pWTr1.js +0 -38
  80. package/dist/chunks/execute.B7h3T_Hc.js +0 -708
  81. package/dist/chunks/index.D-VkfKhf.js +0 -105
  82. package/dist/chunks/rpc.CsFtxqeq.js +0 -83
  83. package/dist/chunks/runBaseTests.BC7ZIH5L.js +0 -129
  84. package/dist/execute.d.ts +0 -148
  85. package/dist/execute.js +0 -13
@@ -1,6 +1,7 @@
1
1
  import { CancelReason, File, TestAnnotation, TaskResultPack, TaskEventPack, FileSpecification, Task } from '@vitest/runner';
2
- import { a as SerializedConfig } from './config.d.HJdfX-8k.js';
3
- import { T as TransformMode, U as UserConsoleLog, A as AfterSuiteRunMeta, E as Environment } from './environment.d.CUq4cUgQ.js';
2
+ import { FetchFunctionOptions, FetchResult, EvaluatedModules } from 'vite/module-runner';
3
+ import { a as SerializedConfig } from './config.d.B_LthbQq.js';
4
+ import { F as FetchCachedFileSystemResult, R as ResolveFunctionResult, U as UserConsoleLog, A as AfterSuiteRunMeta, E as Environment } from './environment.d.BsToaxti.js';
4
5
  import { SnapshotResult } from '@vitest/snapshot';
5
6
 
6
7
  type ArgumentsType<T> = T extends (...args: infer A) => any ? A : never;
@@ -92,26 +93,23 @@ type BirpcReturn<RemoteFunctions, LocalFunctions = Record<string, never>> = {
92
93
  $functions: LocalFunctions;
93
94
  $close: (error?: Error) => void;
94
95
  $closed: boolean;
96
+ $rejectPendingCalls: (handler?: PendingCallHandler) => Promise<void>[];
95
97
  };
98
+ type PendingCallHandler = (options: Pick<PromiseEntry, 'method' | 'reject'>) => void | Promise<void>;
99
+ interface PromiseEntry {
100
+ resolve: (arg: any) => void;
101
+ reject: (error: any) => void;
102
+ method: string;
103
+ timeoutId?: ReturnType<typeof setTimeout>;
104
+ }
105
+ declare const setTimeout: typeof globalThis.setTimeout;
96
106
 
97
107
  interface RuntimeRPC {
98
- fetch: (id: string, transformMode: TransformMode) => Promise<{
99
- externalize?: string
100
- id?: string
101
- }>;
102
- transform: (id: string, transformMode: TransformMode) => Promise<{
103
- code?: string
108
+ fetch: (id: string, importer: string | undefined, environment: string, options?: FetchFunctionOptions) => Promise<FetchResult | FetchCachedFileSystemResult>;
109
+ resolve: (id: string, importer: string | undefined, environment: string) => Promise<ResolveFunctionResult | null>;
110
+ transform: (id: string) => Promise<{
111
+ code?: string;
104
112
  }>;
105
- resolveId: (id: string, importer: string | undefined, transformMode: TransformMode) => Promise<{
106
- external?: boolean | "absolute" | "relative"
107
- id: string
108
- /** @deprecated */
109
- meta?: Record<string, any> | null
110
- /** @deprecated */
111
- moduleSideEffects?: boolean | "no-treeshake" | null
112
- /** @deprecated */
113
- syntheticNamedExports?: boolean | string | null
114
- } | null>;
115
113
  onUserConsoleLog: (log: UserConsoleLog) => void;
116
114
  onUnhandledError: (err: unknown, type: string) => void;
117
115
  onQueued: (file: File) => void;
@@ -131,7 +129,6 @@ interface RunnerRPC {
131
129
  type WorkerRPC = BirpcReturn<RuntimeRPC, RunnerRPC>;
132
130
  interface ContextTestEnvironment {
133
131
  name: string;
134
- transformMode?: TransformMode;
135
132
  options: Record<string, any> | null;
136
133
  }
137
134
  type TestExecutionMethod = "run" | "collect";
@@ -152,16 +149,25 @@ interface WorkerGlobalState {
152
149
  rpc: WorkerRPC;
153
150
  current?: Task;
154
151
  filepath?: string;
152
+ metaEnv: {
153
+ [key: string]: any;
154
+ BASE_URL: string;
155
+ MODE: string;
156
+ DEV: boolean;
157
+ PROD: boolean;
158
+ SSR: boolean;
159
+ };
155
160
  environment: Environment;
156
161
  environmentTeardownRun?: boolean;
157
162
  onCancel: Promise<CancelReason>;
158
- moduleCache: Map<string, any>;
163
+ evaluatedModules: EvaluatedModules;
164
+ resolvingModules: Set<string>;
159
165
  moduleExecutionInfo: Map<string, any>;
160
166
  onCleanup: (listener: () => unknown) => void;
161
167
  providedContext: Record<string, any>;
162
168
  durations: {
163
- environment: number
164
- prepare: number
169
+ environment: number;
170
+ prepare: number;
165
171
  };
166
172
  onFilterStackTrace?: (trace: string) => string;
167
173
  }
@@ -1,5 +1,5 @@
1
1
  import { MessagePort } from 'node:worker_threads';
2
- import { C as ContextRPC } from './worker.d.DoNjFAiv.js';
2
+ import { C as ContextRPC } from './worker.d.BDsXGkwh.js';
3
3
 
4
4
  interface WorkerContext extends ContextRPC {
5
5
  port: MessagePort;
package/dist/cli.js CHANGED
@@ -1,13 +1,13 @@
1
- import { c as createCLI } from './chunks/cac.D3EzDDZd.js';
1
+ import { c as createCLI } from './chunks/cac.DCxo_nSu.js';
2
2
  import '@vitest/utils';
3
3
  import 'events';
4
4
  import 'pathe';
5
5
  import 'tinyrainbow';
6
- import './chunks/constants.DnKduX2e.js';
7
- import './chunks/index.CZI_8rVt.js';
6
+ import './chunks/constants.D_Q9UYh-.js';
7
+ import './chunks/index.BIP7prJq.js';
8
8
  import 'node:fs';
9
9
  import 'node:fs/promises';
10
- import './chunks/typechecker.CVytUJuF.js';
10
+ import './chunks/typechecker.DB-fIMaH.js';
11
11
  import 'node:os';
12
12
  import 'node:perf_hooks';
13
13
  import '@vitest/utils/source-map';
package/dist/config.cjs CHANGED
@@ -4,19 +4,14 @@ var os = require('node:os');
4
4
  var stdEnv = require('std-env');
5
5
  var vite = require('vite');
6
6
 
7
- // if changed, update also jsdocs and docs
8
- const defaultBrowserPort = 63315;
9
- const extraInlineDeps = [
10
- /^(?!.*node_modules).*\.mjs$/,
11
- /^(?!.*node_modules).*\.cjs\.js$/,
12
- /vite\w*\/dist\/client\/env.mjs/
13
- ];
14
-
15
7
  const isNode = typeof process < "u" && typeof process.stdout < "u" && !process.versions?.deno && !globalThis.window;
16
8
  const isDeno = typeof process < "u" && typeof process.stdout < "u" && process.versions?.deno !== void 0;
17
9
  (isNode || isDeno) && process.platform === "win32";
18
10
  (isNode || isDeno) && process.stdout?.isTTY && !stdEnv.isCI;
19
11
 
12
+ // if changed, update also jsdocs and docs
13
+ const defaultBrowserPort = 63315;
14
+
20
15
  const defaultInclude = ["**/*.{test,spec}.?(c|m)[jt]s?(x)"];
21
16
  const defaultExclude = ["**/node_modules/**", "**/.git/**"];
22
17
  // These are the generic defaults for coverage. Providers may also set some provider specific defaults.
@@ -98,4 +93,3 @@ exports.defaultExclude = defaultExclude;
98
93
  exports.defaultInclude = defaultInclude;
99
94
  exports.defineConfig = defineConfig;
100
95
  exports.defineProject = defineProject;
101
- exports.extraInlineDeps = extraInlineDeps;
package/dist/config.d.ts CHANGED
@@ -1,33 +1,30 @@
1
1
  import { HookHandler, ConfigEnv, UserConfig } from 'vite';
2
2
  export { ConfigEnv, Plugin, UserConfig as ViteUserConfig, mergeConfig } from 'vite';
3
- import { I as InlineConfig, c as CoverageV8Options, R as ResolvedCoverageOptions, U as UserWorkspaceConfig, d as UserProjectConfigFn, e as UserProjectConfigExport } from './chunks/reporters.d.DxZg19fy.js';
4
- export { a as TestProjectConfiguration, g as TestProjectInlineConfiguration, f as TestUserConfig, W as WatcherTriggerPattern } from './chunks/reporters.d.DxZg19fy.js';
5
- import { V as VitestPluginContext } from './chunks/plugin.d.C2EcJUjo.js';
6
- import { F as FakeTimerInstallOpts } from './chunks/config.d.HJdfX-8k.js';
3
+ import { I as InlineConfig, c as CoverageV8Options, R as ResolvedCoverageOptions, U as UserWorkspaceConfig, d as UserProjectConfigFn, e as UserProjectConfigExport } from './chunks/reporters.d.BUWjmRYq.js';
4
+ export { a as TestProjectConfiguration, g as TestProjectInlineConfiguration, f as TestUserConfig, W as WatcherTriggerPattern } from './chunks/reporters.d.BUWjmRYq.js';
5
+ import { V as VitestPluginContext } from './chunks/plugin.d.BMVSnsGV.js';
6
+ import { F as FakeTimerInstallOpts } from './chunks/config.d.B_LthbQq.js';
7
7
  import '@vitest/runner';
8
- import './chunks/environment.d.CUq4cUgQ.js';
9
8
  import '@vitest/utils';
9
+ import './chunks/environment.d.BsToaxti.js';
10
10
  import 'node:stream';
11
- import 'node:console';
12
- import './chunks/browser.d.q8Z0P0q1.js';
13
- import './chunks/worker.d.DoNjFAiv.js';
14
- import '@vitest/snapshot';
15
11
  import '@vitest/mocker';
16
12
  import '@vitest/utils/source-map';
13
+ import './chunks/browser.d.yFAklsD1.js';
14
+ import './chunks/worker.d.BDsXGkwh.js';
15
+ import 'vite/module-runner';
16
+ import '@vitest/snapshot';
17
17
  import '@vitest/pretty-format';
18
18
  import '@vitest/utils/diff';
19
- import 'vite-node';
20
- import 'chai';
19
+ import '@vitest/expect';
21
20
  import 'vitest/optional-types.js';
22
- import './chunks/benchmark.d.BwvBVTda.js';
21
+ import './chunks/benchmark.d.DAaHLpsq.js';
23
22
  import '@vitest/runner/utils';
24
23
  import 'tinybench';
25
- import './chunks/coverage.d.S9RMNXIe.js';
26
- import 'vite-node/client';
24
+ import './chunks/coverage.d.BZtK59WP.js';
27
25
  import '@vitest/snapshot/manager';
28
26
  import 'node:fs';
29
-
30
- /* eslint-disable unused-imports/no-unused-vars */
27
+ import 'node:console';
31
28
 
32
29
  type VitestInlineConfig = InlineConfig;
33
30
  declare module "vite" {
@@ -43,50 +40,48 @@ declare module "vite" {
43
40
  }
44
41
 
45
42
  declare const defaultBrowserPort = 63315;
46
- declare const extraInlineDeps: RegExp[];
47
43
 
48
44
  declare const defaultInclude: string[];
49
45
  declare const defaultExclude: string[];
50
- // These are the generic defaults for coverage. Providers may also set some provider specific defaults.
51
46
  declare const coverageConfigDefaults: ResolvedCoverageOptions;
52
47
  declare const configDefaults: Readonly<{
53
- allowOnly: boolean
54
- isolate: boolean
55
- watch: boolean
56
- globals: boolean
57
- environment: "node"
58
- pool: "forks"
59
- clearMocks: boolean
60
- restoreMocks: boolean
61
- mockReset: boolean
62
- unstubGlobals: boolean
63
- unstubEnvs: boolean
64
- include: string[]
65
- exclude: string[]
66
- teardownTimeout: number
67
- forceRerunTriggers: string[]
68
- update: boolean
69
- reporters: never[]
70
- silent: boolean
71
- hideSkippedTests: boolean
72
- api: boolean
73
- ui: boolean
74
- uiBase: string
75
- open: boolean
48
+ allowOnly: boolean;
49
+ isolate: boolean;
50
+ watch: boolean;
51
+ globals: boolean;
52
+ environment: "node";
53
+ pool: "forks";
54
+ clearMocks: boolean;
55
+ restoreMocks: boolean;
56
+ mockReset: boolean;
57
+ unstubGlobals: boolean;
58
+ unstubEnvs: boolean;
59
+ include: string[];
60
+ exclude: string[];
61
+ teardownTimeout: number;
62
+ forceRerunTriggers: string[];
63
+ update: boolean;
64
+ reporters: never[];
65
+ silent: boolean;
66
+ hideSkippedTests: boolean;
67
+ api: boolean;
68
+ ui: boolean;
69
+ uiBase: string;
70
+ open: boolean;
76
71
  css: {
77
- include: never[]
78
- }
79
- coverage: CoverageV8Options
80
- fakeTimers: FakeTimerInstallOpts
81
- maxConcurrency: number
82
- dangerouslyIgnoreUnhandledErrors: boolean
72
+ include: never[];
73
+ };
74
+ coverage: CoverageV8Options;
75
+ fakeTimers: FakeTimerInstallOpts;
76
+ maxConcurrency: number;
77
+ dangerouslyIgnoreUnhandledErrors: boolean;
83
78
  typecheck: {
84
- checker: "tsc"
85
- include: string[]
86
- exclude: string[]
87
- }
88
- slowTestThreshold: number
89
- disableConsoleIntercept: boolean
79
+ checker: "tsc";
80
+ include: string[];
81
+ exclude: string[];
82
+ };
83
+ slowTestThreshold: number;
84
+ disableConsoleIntercept: boolean;
90
85
  }>;
91
86
 
92
87
  type ViteUserConfigFnObject = (env: ConfigEnv) => UserConfig;
@@ -102,5 +97,5 @@ declare function defineProject(config: Promise<UserWorkspaceConfig>): Promise<Us
102
97
  declare function defineProject(config: UserProjectConfigFn): UserProjectConfigFn;
103
98
  declare function defineProject(config: UserProjectConfigExport): UserProjectConfigExport;
104
99
 
105
- export { UserProjectConfigExport, UserProjectConfigFn, UserWorkspaceConfig, configDefaults, coverageConfigDefaults, defaultBrowserPort, defaultExclude, defaultInclude, defineConfig, defineProject, extraInlineDeps };
100
+ export { UserProjectConfigExport, UserProjectConfigFn, UserWorkspaceConfig, configDefaults, coverageConfigDefaults, defaultBrowserPort, defaultExclude, defaultInclude, defineConfig, defineProject };
106
101
  export type { ViteUserConfigExport, ViteUserConfigFn, ViteUserConfigFnObject, ViteUserConfigFnPromise };
package/dist/config.js CHANGED
@@ -1,6 +1,6 @@
1
- export { d as defaultBrowserPort, e as extraInlineDeps } from './chunks/constants.DnKduX2e.js';
2
1
  export { c as configDefaults, a as coverageConfigDefaults, d as defaultExclude, b as defaultInclude } from './chunks/defaults.CXFFjsi8.js';
3
2
  export { mergeConfig } from 'vite';
3
+ export { d as defaultBrowserPort } from './chunks/constants.D_Q9UYh-.js';
4
4
  import 'node:os';
5
5
  import './chunks/env.D4Lgay0q.js';
6
6
  import 'std-env';
@@ -1,28 +1,27 @@
1
- import { R as ResolvedCoverageOptions, V as Vitest, C as CoverageMap, b as ReportContext } from './chunks/reporters.d.DxZg19fy.js';
1
+ import { R as ResolvedCoverageOptions, V as Vitest, C as CoverageMap, b as ReportContext } from './chunks/reporters.d.BUWjmRYq.js';
2
2
  import { TransformResult } from 'vite';
3
- import { A as AfterSuiteRunMeta } from './chunks/environment.d.CUq4cUgQ.js';
3
+ import { A as AfterSuiteRunMeta } from './chunks/environment.d.BsToaxti.js';
4
4
  import '@vitest/runner';
5
5
  import '@vitest/utils';
6
6
  import 'node:stream';
7
- import 'node:console';
8
- import './chunks/browser.d.q8Z0P0q1.js';
9
- import './chunks/worker.d.DoNjFAiv.js';
10
- import './chunks/config.d.HJdfX-8k.js';
7
+ import '@vitest/mocker';
8
+ import '@vitest/utils/source-map';
9
+ import './chunks/browser.d.yFAklsD1.js';
10
+ import './chunks/worker.d.BDsXGkwh.js';
11
+ import 'vite/module-runner';
12
+ import './chunks/config.d.B_LthbQq.js';
11
13
  import '@vitest/pretty-format';
12
14
  import '@vitest/snapshot';
13
15
  import '@vitest/utils/diff';
14
- import '@vitest/mocker';
15
- import '@vitest/utils/source-map';
16
- import 'vite-node';
17
- import 'chai';
16
+ import '@vitest/expect';
18
17
  import 'vitest/optional-types.js';
19
- import './chunks/benchmark.d.BwvBVTda.js';
18
+ import './chunks/benchmark.d.DAaHLpsq.js';
20
19
  import '@vitest/runner/utils';
21
20
  import 'tinybench';
22
- import './chunks/coverage.d.S9RMNXIe.js';
23
- import 'vite-node/client';
21
+ import './chunks/coverage.d.BZtK59WP.js';
24
22
  import '@vitest/snapshot/manager';
25
23
  import 'node:fs';
24
+ import 'node:console';
26
25
 
27
26
  type Threshold = "lines" | "functions" | "statements" | "branches";
28
27
  interface ResolvedThreshold {
@@ -46,8 +45,8 @@ interface ResolvedThreshold {
46
45
  * "project-b": ...
47
46
  * ```
48
47
  */
49
- type CoverageFiles = Map<NonNullable<AfterSuiteRunMeta["projectName"]> | symbol, Record<AfterSuiteRunMeta["transformMode"], {
50
- [TestFilenames: string]: string
48
+ type CoverageFiles = Map<NonNullable<AfterSuiteRunMeta["projectName"]> | symbol, Record<AfterSuiteRunMeta["environment"], {
49
+ [TestFilenames: string]: string;
51
50
  }>>;
52
51
  declare class BaseCoverageProvider<Options extends ResolvedCoverageOptions<"istanbul" | "v8">> {
53
52
  ctx: Vitest;
@@ -58,30 +57,32 @@ declare class BaseCoverageProvider<Options extends ResolvedCoverageOptions<"ista
58
57
  coverageFiles: CoverageFiles;
59
58
  pendingPromises: Promise<void>[];
60
59
  coverageFilesDirectory: string;
60
+ roots: string[];
61
61
  _initialize(ctx: Vitest): void;
62
62
  /**
63
63
  * Check if file matches `coverage.include` but not `coverage.exclude`
64
64
  */
65
- isIncluded(_filename: string): boolean;
65
+ isIncluded(_filename: string, root?: string): boolean;
66
+ private getUntestedFilesByRoot;
66
67
  getUntestedFiles(testedFiles: string[]): Promise<string[]>;
67
68
  createCoverageMap(): CoverageMap;
68
69
  generateReports(_: CoverageMap, __: boolean | undefined): Promise<void>;
69
70
  parseConfigModule(_: string): Promise<{
70
71
  generate: () => {
71
- code: string
72
- }
72
+ code: string;
73
+ };
73
74
  }>;
74
75
  resolveOptions(): Options;
75
76
  clean(clean?: boolean): Promise<void>;
76
- onAfterSuiteRun({ coverage, transformMode, projectName, testFiles }: AfterSuiteRunMeta): void;
77
+ onAfterSuiteRun({ coverage, environment, projectName, testFiles }: AfterSuiteRunMeta): void;
77
78
  readCoverageFiles<CoverageType>({ onFileRead, onFinished, onDebug }: {
78
79
  /** Callback invoked with a single coverage result */
79
- onFileRead: (data: CoverageType) => void
80
+ onFileRead: (data: CoverageType) => void;
80
81
  /** Callback invoked once all results of a project for specific transform mode are read */
81
- onFinished: (project: Vitest["projects"][number], transformMode: AfterSuiteRunMeta["transformMode"]) => Promise<void>
82
+ onFinished: (project: Vitest["projects"][number], environment: string) => Promise<void>;
82
83
  onDebug: ((...logs: any[]) => void) & {
83
- enabled: boolean
84
- }
84
+ enabled: boolean;
85
+ };
85
86
  }): Promise<void>;
86
87
  cleanAfterRun(): Promise<void>;
87
88
  onTestFailure(): Promise<void>;
@@ -101,9 +102,9 @@ declare class BaseCoverageProvider<Options extends ResolvedCoverageOptions<"ista
101
102
  * Check if current coverage is above configured thresholds and bump the thresholds if needed
102
103
  */
103
104
  updateThresholds({ thresholds: allThresholds, onUpdate, configurationFile }: {
104
- thresholds: ResolvedThreshold[]
105
- configurationFile: unknown
106
- onUpdate: () => void
105
+ thresholds: ResolvedThreshold[];
106
+ configurationFile: unknown;
107
+ onUpdate: () => void;
107
108
  }): Promise<void>;
108
109
  mergeReports(coverageMaps: unknown[]): Promise<void>;
109
110
  hasTerminalReporter(reporters: ResolvedCoverageOptions["reporter"]): boolean;
package/dist/coverage.js CHANGED
@@ -1,17 +1,16 @@
1
- export { B as BaseCoverageProvider } from './chunks/coverage.Cwa-XhJt.js';
1
+ export { B as BaseCoverageProvider } from './chunks/coverage.BCU-r2QL.js';
2
2
  import 'node:fs';
3
3
  import 'node:path';
4
+ import '@vitest/utils';
4
5
  import 'pathe';
5
6
  import 'picomatch';
6
7
  import 'tinyglobby';
7
8
  import 'tinyrainbow';
8
- import 'vite-node/utils';
9
9
  import './chunks/defaults.CXFFjsi8.js';
10
10
  import 'node:os';
11
11
  import './chunks/env.D4Lgay0q.js';
12
12
  import 'std-env';
13
13
  import 'node:crypto';
14
- import '@vitest/utils';
15
14
  import 'node:module';
16
15
  import 'node:process';
17
16
  import 'node:fs/promises';
@@ -20,16 +19,16 @@ import 'node:assert';
20
19
  import 'node:v8';
21
20
  import 'node:util';
22
21
  import 'vite';
23
- import './chunks/constants.DnKduX2e.js';
22
+ import './chunks/constants.D_Q9UYh-.js';
24
23
  import 'node:tty';
25
24
  import 'node:events';
26
- import './chunks/index.B521nVV-.js';
25
+ import './chunks/index.Bgo3tNWt.js';
27
26
  import 'tinypool';
28
- import './chunks/typechecker.CVytUJuF.js';
27
+ import './chunks/typechecker.DB-fIMaH.js';
29
28
  import 'node:perf_hooks';
30
29
  import '@vitest/utils/source-map';
31
30
  import 'tinyexec';
32
31
  import './path.js';
33
32
  import '@vitest/runner/utils';
34
33
  import 'node:worker_threads';
35
- import './chunks/coverage.DVF1vEu8.js';
34
+ import './chunks/coverage.D_JHT54q.js';
@@ -1,25 +1,21 @@
1
- import { E as Environment } from './chunks/environment.d.CUq4cUgQ.js';
2
- export { a as EnvironmentReturn, V as VmEnvironmentReturn } from './chunks/environment.d.CUq4cUgQ.js';
1
+ import { E as Environment } from './chunks/environment.d.BsToaxti.js';
2
+ export { a as EnvironmentReturn, V as VmEnvironmentReturn } from './chunks/environment.d.BsToaxti.js';
3
3
 
4
4
  declare const environments: {
5
- "node": Environment
6
- "jsdom": Environment
7
- "happy-dom": Environment
8
- "edge-runtime": Environment
5
+ "node": Environment;
6
+ "jsdom": Environment;
7
+ "happy-dom": Environment;
8
+ "edge-runtime": Environment;
9
9
  };
10
10
 
11
11
  interface PopulateOptions {
12
- // we bind functions such as addEventListener and others
13
- // because they rely on `this` in happy-dom, and in jsdom it
14
- // has a priority for getting implementation from symbols
15
- // (global doesn't have these symbols, but window - does)
16
12
  bindFunctions?: boolean;
17
13
  additionalKeys?: string[];
18
14
  }
19
15
  declare function populateGlobal(global: any, win: any, options?: PopulateOptions): {
20
- keys: Set<string>
21
- skipKeys: string[]
22
- originals: Map<string | symbol, any>
16
+ keys: Set<string>;
17
+ skipKeys: string[];
18
+ originals: Map<string | symbol, any>;
23
19
  };
24
20
 
25
21
  export { Environment, environments as builtinEnvironments, populateGlobal };
@@ -1,2 +1,2 @@
1
- export { e as builtinEnvironments, p as populateGlobal } from './chunks/index.CmSc2RE5.js';
1
+ export { e as builtinEnvironments, p as populateGlobal } from './chunks/index.DIWhzsUh.js';
2
2
  import 'node:console';