vitest 2.1.1 → 2.1.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 (57) hide show
  1. package/LICENSE.md +320 -30
  2. package/dist/browser.d.ts +5 -5
  3. package/dist/browser.js +1 -1
  4. package/dist/chunks/{base.CsQmmYBA.js → base.BO5Jx7vw.js} +1 -1
  5. package/dist/chunks/{base.BlXpj3e_.js → base.DwXGwWst.js} +1 -10
  6. package/dist/chunks/{benchmark.puBFxyfE.d.ts → benchmark.JVlTzojj.d.ts} +2 -0
  7. package/dist/chunks/{cac.BVmpoFAv.js → cac.BSMVokHR.js} +7 -7
  8. package/dist/chunks/cli-api.btGgw3PC.js +11819 -0
  9. package/dist/chunks/{config.CHuotKvS.d.ts → config.Crbj2GAb.d.ts} +3 -0
  10. package/dist/chunks/{console.DI3gHgtH.js → console.CfT1Wjed.js} +1 -1
  11. package/dist/chunks/{creator.BteLTfY8.js → creator.CBPphXqR.js} +4 -7
  12. package/dist/chunks/{environment.C5eAp3K6.d.ts → environment.CzISCQ7o.d.ts} +1 -0
  13. package/dist/chunks/{globals.C03P0O1a.js → globals.Bdzt04Qm.js} +3 -3
  14. package/dist/chunks/index.-d_XpZEA.js +140 -0
  15. package/dist/chunks/{index.DkN6V87F.js → index.4GFF2h22.js} +2 -1
  16. package/dist/chunks/{index.zPibhCkV.js → index.Dz2opmmU.js} +653 -585
  17. package/dist/chunks/{index.Bn75ITYg.js → index.X0nbfr6-.js} +37 -28
  18. package/dist/chunks/{reporters.WnPwkmgA.d.ts → reporters.C4ZHgdxQ.d.ts} +20 -15
  19. package/dist/chunks/{resolveConfig.-K5hHm0S.js → resolveConfig.Dha6ilPI.js} +3544 -3374
  20. package/dist/chunks/{runBaseTests.9YDrdSI4.js → runBaseTests.Cx4wXyTR.js} +6 -6
  21. package/dist/chunks/{setup-common.DV1PI68g.js → setup-common.BKyF15v_.js} +1 -1
  22. package/dist/chunks/{suite.CcK46U-P.d.ts → suite.BMWOKiTe.d.ts} +1 -1
  23. package/dist/chunks/{utils.Dbnmsfq1.js → utils.CY6Spixo.js} +26 -47
  24. package/dist/chunks/vi.BskyZC5g.js +3945 -0
  25. package/dist/chunks/{vite.D2yAwzwa.d.ts → vite.YH7MrecS.d.ts} +1 -1
  26. package/dist/chunks/{vm.CPXwWp4C.js → vm.DB_hLchi.js} +1 -1
  27. package/dist/chunks/{worker.CmPmTxgH.d.ts → worker.B6RjTtbk.d.ts} +42 -28
  28. package/dist/chunks/{worker.Bws9Zuxu.d.ts → worker.CcJLfX8w.d.ts} +1 -1
  29. package/dist/cli.js +2 -2
  30. package/dist/config.cjs +2 -1
  31. package/dist/config.d.ts +19 -14
  32. package/dist/config.js +2 -1
  33. package/dist/coverage.d.ts +67 -30
  34. package/dist/coverage.js +250 -109
  35. package/dist/environments.d.ts +2 -2
  36. package/dist/execute.d.ts +3 -3
  37. package/dist/index.d.ts +36 -19
  38. package/dist/index.js +5 -5
  39. package/dist/node.d.ts +8 -8
  40. package/dist/node.js +10 -9
  41. package/dist/reporters.d.ts +4 -4
  42. package/dist/reporters.js +4 -3
  43. package/dist/runners.d.ts +1 -1
  44. package/dist/runners.js +8 -2
  45. package/dist/suite.d.ts +2 -2
  46. package/dist/worker.js +11 -3
  47. package/dist/workers/forks.js +1 -1
  48. package/dist/workers/runVmTests.js +8 -5
  49. package/dist/workers/threads.js +1 -1
  50. package/dist/workers/vmForks.js +2 -2
  51. package/dist/workers/vmThreads.js +2 -2
  52. package/dist/workers.d.ts +4 -4
  53. package/dist/workers.js +4 -4
  54. package/package.json +12 -13
  55. package/dist/chunks/cli-api.BKkmK21J.js +0 -11404
  56. package/dist/chunks/index.iyKRMe3s.js +0 -131
  57. package/dist/chunks/vi.D6IHiKAI.js +0 -3746
@@ -1,4 +1,4 @@
1
- import { I as InlineConfig } from './reporters.WnPwkmgA.js';
1
+ import { I as InlineConfig } from './reporters.C4ZHgdxQ.js';
2
2
 
3
3
  type VitestInlineConfig = InlineConfig;
4
4
  declare module 'vite' {
@@ -1,7 +1,7 @@
1
1
  import vm, { isContext } from 'node:vm';
2
2
  import { fileURLToPath, pathToFileURL } from 'node:url';
3
3
  import { dirname, basename, extname, normalize, join, resolve } from 'pathe';
4
- import { createCustomConsole } from './console.DI3gHgtH.js';
4
+ import { createCustomConsole } from './console.CfT1Wjed.js';
5
5
  import { g as getDefaultRequestStubs, s as startVitestExecutor } from './execute._eQQfgI8.js';
6
6
  import { distDir } from '../path.js';
7
7
  import { dirname as dirname$1 } from 'node:path';
@@ -1,32 +1,8 @@
1
- import { FetchResult, ViteNodeResolveId, RawSourceMap, ModuleCacheMap } from 'vite-node';
1
+ import { ViteNodeResolveId, ModuleCacheMap } from 'vite-node';
2
2
  import { File, TaskResultPack, CancelReason, Task } from '@vitest/runner';
3
- import { S as SerializedConfig } from './config.CHuotKvS.js';
3
+ import { S as SerializedConfig } from './config.Crbj2GAb.js';
4
4
  import { SnapshotResult } from '@vitest/snapshot';
5
- import { T as TransformMode, U as UserConsoleLog, A as AfterSuiteRunMeta, E as Environment } from './environment.C5eAp3K6.js';
6
-
7
- interface RuntimeRPC {
8
- fetch: (id: string, transformMode: TransformMode) => Promise<{
9
- externalize?: string;
10
- id?: string;
11
- }>;
12
- transform: (id: string, transformMode: TransformMode) => Promise<FetchResult>;
13
- resolveId: (id: string, importer: string | undefined, transformMode: TransformMode) => Promise<ViteNodeResolveId | null>;
14
- getSourceMap: (id: string, force?: boolean) => Promise<RawSourceMap | undefined>;
15
- onFinished: (files: File[], errors?: unknown[]) => void;
16
- onPathsCollected: (paths: string[]) => void;
17
- onUserConsoleLog: (log: UserConsoleLog) => void;
18
- onUnhandledError: (err: unknown, type: string) => void;
19
- onCollected: (files: File[]) => Promise<void>;
20
- onAfterSuiteRun: (meta: AfterSuiteRunMeta) => void;
21
- onTaskUpdate: (pack: TaskResultPack[]) => Promise<void>;
22
- onCancel: (reason: CancelReason) => void;
23
- getCountOfFailedTests: () => number;
24
- snapshotSaved: (snapshot: SnapshotResult) => void;
25
- resolveSnapshotPath: (testPath: string) => string;
26
- }
27
- interface RunnerRPC {
28
- onCancel: (reason: CancelReason) => void;
29
- }
5
+ import { T as TransformMode, U as UserConsoleLog, A as AfterSuiteRunMeta, E as Environment } from './environment.CzISCQ7o.js';
30
6
 
31
7
  type ArgumentsType<T> = T extends (...args: infer A) => any ? A : never;
32
8
  type ReturnType<T> = T extends (...args: any) => infer R ? R : never;
@@ -93,6 +69,44 @@ type BirpcReturn<RemoteFunctions, LocalFunctions = Record<string, never>> = {
93
69
  $functions: LocalFunctions;
94
70
  };
95
71
 
72
+ interface RuntimeRPC {
73
+ fetch: (id: string, transformMode: TransformMode) => Promise<{
74
+ externalize?: string;
75
+ id?: string;
76
+ }>;
77
+ transform: (id: string, transformMode: TransformMode) => Promise<{
78
+ code?: string;
79
+ }>;
80
+ resolveId: (id: string, importer: string | undefined, transformMode: TransformMode) => Promise<{
81
+ external?: boolean | 'absolute' | 'relative';
82
+ id: string;
83
+ /** @deprecated */
84
+ meta?: Record<string, any> | null;
85
+ /** @deprecated */
86
+ moduleSideEffects?: boolean | 'no-treeshake' | null;
87
+ /** @deprecated */
88
+ syntheticNamedExports?: boolean | string | null;
89
+ } | null>;
90
+ /**
91
+ * @deprecated unused
92
+ */
93
+ getSourceMap: (id: string, force?: boolean) => Promise<any>;
94
+ onFinished: (files: File[], errors?: unknown[]) => void;
95
+ onPathsCollected: (paths: string[]) => void;
96
+ onUserConsoleLog: (log: UserConsoleLog) => void;
97
+ onUnhandledError: (err: unknown, type: string) => void;
98
+ onCollected: (files: File[]) => Promise<void>;
99
+ onAfterSuiteRun: (meta: AfterSuiteRunMeta) => void;
100
+ onTaskUpdate: (pack: TaskResultPack[]) => Promise<void>;
101
+ onCancel: (reason: CancelReason) => void;
102
+ getCountOfFailedTests: () => number;
103
+ snapshotSaved: (snapshot: SnapshotResult) => void;
104
+ resolveSnapshotPath: (testPath: string) => string;
105
+ }
106
+ interface RunnerRPC {
107
+ onCancel: (reason: CancelReason) => void;
108
+ }
109
+
96
110
  /** @deprecated unused */
97
111
  type ResolveIdFunction = (id: string, importer?: string) => Promise<ViteNodeResolveId | null>;
98
112
  type WorkerRPC = BirpcReturn<RuntimeRPC, RunnerRPC>;
@@ -129,4 +143,4 @@ interface WorkerGlobalState {
129
143
  };
130
144
  }
131
145
 
132
- export type { BirpcOptions as B, ContextRPC as C, RuntimeRPC as R, WorkerGlobalState as W, BirpcReturn as a, RunnerRPC as b, ResolveIdFunction as c, WorkerRPC as d, ContextTestEnvironment as e };
146
+ export type { BirpcOptions as B, ContextRPC as C, RuntimeRPC as R, WorkerGlobalState as W, BirpcReturn as a, WorkerRPC as b, RunnerRPC as c, ResolveIdFunction as d, ContextTestEnvironment as e };
@@ -1,5 +1,5 @@
1
1
  import { MessagePort } from 'node:worker_threads';
2
- import { C as ContextRPC } from './worker.CmPmTxgH.js';
2
+ import { C as ContextRPC } from './worker.B6RjTtbk.js';
3
3
 
4
4
  interface WorkerContext extends ContextRPC {
5
5
  port: MessagePort;
package/dist/cli.js CHANGED
@@ -1,8 +1,8 @@
1
- import { c as createCLI } from './chunks/cac.BVmpoFAv.js';
1
+ import { c as createCLI } from './chunks/cac.BSMVokHR.js';
2
2
  import 'pathe';
3
3
  import 'events';
4
4
  import 'tinyrainbow';
5
- import './chunks/base.BlXpj3e_.js';
5
+ import './chunks/base.DwXGwWst.js';
6
6
  import '@vitest/utils';
7
7
  import './chunks/constants.fzPh7AOq.js';
8
8
 
package/dist/config.cjs CHANGED
@@ -68,7 +68,8 @@ const coverageConfigDefaults = {
68
68
  ".jsx",
69
69
  ".vue",
70
70
  ".svelte",
71
- ".marko"
71
+ ".marko",
72
+ ".astro"
72
73
  ],
73
74
  allowExternal: false,
74
75
  excludeAfterRemap: false,
package/dist/config.d.ts CHANGED
@@ -1,14 +1,14 @@
1
- import './chunks/vite.D2yAwzwa.js';
2
- import { ConfigEnv, UserConfig } from 'vite';
3
- export { ConfigEnv, Plugin, UserConfig, mergeConfig } from 'vite';
4
- import { R as ResolvedCoverageOptions, b as CoverageV8Options, U as UserWorkspaceConfig, c as UserProjectConfigFn, d as UserProjectConfigExport, W as WorkspaceProjectConfiguration } from './chunks/reporters.WnPwkmgA.js';
1
+ import './chunks/vite.YH7MrecS.js';
2
+ import { UserConfig as UserConfig$1, ConfigEnv } from 'vite';
3
+ export { ConfigEnv, Plugin, UserConfig as ViteUserConfig, mergeConfig } from 'vite';
4
+ import { R as ResolvedCoverageOptions, c as CoverageV8Options, U as UserWorkspaceConfig, d as UserProjectConfigFn, e as UserProjectConfigExport, W as WorkspaceProjectConfiguration } from './chunks/reporters.C4ZHgdxQ.js';
5
5
  import '@vitest/runner';
6
6
  import '@vitest/pretty-format';
7
- import './chunks/config.CHuotKvS.js';
7
+ import './chunks/config.Crbj2GAb.js';
8
8
  import '@vitest/snapshot';
9
9
  import '@vitest/snapshot/environment';
10
10
  import 'vite-node';
11
- import './chunks/environment.C5eAp3K6.js';
11
+ import './chunks/environment.CzISCQ7o.js';
12
12
  import 'node:stream';
13
13
  import 'vite-node/client';
14
14
  import '@vitest/snapshot/manager';
@@ -17,7 +17,7 @@ import '@vitest/utils';
17
17
  import '@vitest/utils/source-map';
18
18
  import 'node:fs';
19
19
  import 'chai';
20
- import './chunks/benchmark.puBFxyfE.js';
20
+ import './chunks/benchmark.JVlTzojj.js';
21
21
  import '@vitest/runner/utils';
22
22
  import 'tinybench';
23
23
 
@@ -71,12 +71,17 @@ declare const configDefaults: Readonly<{
71
71
  disableConsoleIntercept: false;
72
72
  }>;
73
73
 
74
- type UserConfigFnObject = (env: ConfigEnv) => UserConfig;
75
- type UserConfigFnPromise = (env: ConfigEnv) => Promise<UserConfig>;
76
- type UserConfigFn = (env: ConfigEnv) => UserConfig | Promise<UserConfig>;
77
- type UserConfigExport = UserConfig | Promise<UserConfig> | UserConfigFnObject | UserConfigFnPromise | UserConfigFn;
78
- declare function defineConfig(config: UserConfig): UserConfig;
79
- declare function defineConfig(config: Promise<UserConfig>): Promise<UserConfig>;
74
+ /**
75
+ * @deprecated Use `ViteUserConfig` instead
76
+ */
77
+ type UserConfig = UserConfig$1;
78
+
79
+ type UserConfigFnObject = (env: ConfigEnv) => UserConfig$1;
80
+ type UserConfigFnPromise = (env: ConfigEnv) => Promise<UserConfig$1>;
81
+ type UserConfigFn = (env: ConfigEnv) => UserConfig$1 | Promise<UserConfig$1>;
82
+ type UserConfigExport = UserConfig$1 | Promise<UserConfig$1> | UserConfigFnObject | UserConfigFnPromise | UserConfigFn;
83
+ declare function defineConfig(config: UserConfig$1): UserConfig$1;
84
+ declare function defineConfig(config: Promise<UserConfig$1>): Promise<UserConfig$1>;
80
85
  declare function defineConfig(config: UserConfigFnObject): UserConfigFnObject;
81
86
  declare function defineConfig(config: UserConfigExport): UserConfigExport;
82
87
  declare function defineProject(config: UserWorkspaceConfig): UserWorkspaceConfig;
@@ -85,4 +90,4 @@ declare function defineProject(config: UserProjectConfigFn): UserProjectConfigFn
85
90
  declare function defineProject(config: UserProjectConfigExport): UserProjectConfigExport;
86
91
  declare function defineWorkspace(config: WorkspaceProjectConfiguration[]): WorkspaceProjectConfiguration[];
87
92
 
88
- export { type UserConfigExport, type UserConfigFn, type UserConfigFnObject, type UserConfigFnPromise, UserProjectConfigExport, UserProjectConfigFn, UserWorkspaceConfig, WorkspaceProjectConfiguration, configDefaults, coverageConfigDefaults, defaultBrowserPort, defaultExclude, defaultInclude, defineConfig, defineProject, defineWorkspace, extraInlineDeps };
93
+ export { type UserConfig, type UserConfigExport, type UserConfigFn, type UserConfigFnObject, type UserConfigFnPromise, UserProjectConfigExport, UserProjectConfigFn, UserWorkspaceConfig, WorkspaceProjectConfiguration, configDefaults, coverageConfigDefaults, defaultBrowserPort, defaultExclude, defaultInclude, defineConfig, defineProject, defineWorkspace, extraInlineDeps };
package/dist/config.js CHANGED
@@ -66,7 +66,8 @@ const coverageConfigDefaults = {
66
66
  ".jsx",
67
67
  ".vue",
68
68
  ".svelte",
69
- ".marko"
69
+ ".marko",
70
+ ".astro"
70
71
  ],
71
72
  allowExternal: false,
72
73
  excludeAfterRemap: false,
@@ -1,12 +1,12 @@
1
1
  import * as vite from 'vite';
2
- import { B as BaseCoverageOptions, R as ResolvedCoverageOptions, V as Vitest } from './chunks/reporters.WnPwkmgA.js';
2
+ import { A as AfterSuiteRunMeta } from './chunks/environment.CzISCQ7o.js';
3
+ import { R as ResolvedCoverageOptions, V as Vitest, a as ReportContext } from './chunks/reporters.C4ZHgdxQ.js';
3
4
  import '@vitest/runner';
4
5
  import '@vitest/pretty-format';
5
- import './chunks/config.CHuotKvS.js';
6
+ import './chunks/config.Crbj2GAb.js';
6
7
  import '@vitest/snapshot';
7
8
  import '@vitest/snapshot/environment';
8
9
  import 'vite-node';
9
- import './chunks/environment.C5eAp3K6.js';
10
10
  import 'node:stream';
11
11
  import 'vite-node/client';
12
12
  import '@vitest/snapshot/manager';
@@ -15,7 +15,7 @@ import '@vitest/utils';
15
15
  import '@vitest/utils/source-map';
16
16
  import 'node:fs';
17
17
  import 'chai';
18
- import './chunks/benchmark.puBFxyfE.js';
18
+ import './chunks/benchmark.JVlTzojj.js';
19
19
  import '@vitest/runner/utils';
20
20
  import 'tinybench';
21
21
 
@@ -129,39 +129,76 @@ interface ResolvedThreshold {
129
129
  name: string;
130
130
  thresholds: Partial<Record<Threshold, number | undefined>>;
131
131
  }
132
- declare class BaseCoverageProvider {
133
- /**
134
- * Check if current coverage is above configured thresholds and bump the thresholds if needed
135
- */
136
- updateThresholds({ thresholds: allThresholds, perFile, configurationFile, onUpdate, }: {
137
- thresholds: ResolvedThreshold[];
138
- perFile?: boolean;
139
- configurationFile: unknown;
140
- onUpdate: () => void;
141
- }): void;
142
- /**
143
- * Check collected coverage against configured thresholds. Sets exit code to 1 when thresholds not reached.
144
- */
145
- checkThresholds({ thresholds: allThresholds, perFile, onError, }: {
146
- thresholds: ResolvedThreshold[];
147
- perFile?: boolean;
148
- onError: (error: string) => void;
149
- }): void;
132
+ /**
133
+ * Holds info about raw coverage results that are stored on file system:
134
+ *
135
+ * ```json
136
+ * "project-a": {
137
+ * "web": {
138
+ * "tests/math.test.ts": "coverage-1.json",
139
+ * "tests/utils.test.ts": "coverage-2.json",
140
+ * // ^^^^^^^^^^^^^^^ Raw coverage on file system
141
+ * },
142
+ * "ssr": { ... },
143
+ * "browser": { ... },
144
+ * },
145
+ * "project-b": ...
146
+ * ```
147
+ */
148
+ type CoverageFiles = Map<NonNullable<AfterSuiteRunMeta['projectName']> | symbol, Record<AfterSuiteRunMeta['transformMode'], {
149
+ [TestFilenames: string]: string;
150
+ }>>;
151
+ declare class BaseCoverageProvider<Options extends ResolvedCoverageOptions<'istanbul' | 'v8'>> {
152
+ ctx: Vitest;
153
+ readonly name: 'v8' | 'istanbul';
154
+ version: string;
155
+ options: Options;
156
+ coverageFiles: CoverageFiles;
157
+ pendingPromises: Promise<void>[];
158
+ coverageFilesDirectory: string;
159
+ _initialize(ctx: Vitest): void;
160
+ createCoverageMap(): CoverageMap;
161
+ generateReports(_: CoverageMap, __: boolean | undefined): Promise<void>;
162
+ parseConfigModule(_: string): Promise<{
163
+ generate: () => {
164
+ code: string;
165
+ };
166
+ }>;
167
+ resolveOptions(): Options;
168
+ clean(clean?: boolean): Promise<void>;
169
+ onAfterSuiteRun({ coverage, transformMode, projectName, testFiles }: AfterSuiteRunMeta): void;
170
+ readCoverageFiles<CoverageType>({ onFileRead, onFinished, onDebug }: {
171
+ /** Callback invoked with a single coverage result */
172
+ onFileRead: (data: CoverageType) => void;
173
+ /** Callback invoked once all results of a project for specific transform mode are read */
174
+ onFinished: (project: Vitest['projects'][number], transformMode: AfterSuiteRunMeta['transformMode']) => Promise<void>;
175
+ onDebug: ((...logs: any[]) => void) & {
176
+ enabled: boolean;
177
+ };
178
+ }): Promise<void>;
179
+ cleanAfterRun(): Promise<void>;
180
+ onTestFailure(): Promise<void>;
181
+ reportCoverage(coverageMap: unknown, { allTestsRun }: ReportContext): Promise<void>;
182
+ reportThresholds(coverageMap: CoverageMap, allTestsRun: boolean | undefined): Promise<void>;
150
183
  /**
151
184
  * Constructs collected coverage and users' threshold options into separate sets
152
185
  * where each threshold set holds their own coverage maps. Threshold set is either
153
186
  * for specific files defined by glob pattern or global for all other files.
154
187
  */
155
- resolveThresholds({ coverageMap, thresholds, createCoverageMap, root, }: {
156
- coverageMap: CoverageMap;
157
- thresholds: NonNullable<BaseCoverageOptions['thresholds']>;
158
- createCoverageMap: () => CoverageMap;
159
- root: string;
160
- }): ResolvedThreshold[];
188
+ private resolveThresholds;
189
+ /**
190
+ * Check collected coverage against configured thresholds. Sets exit code to 1 when thresholds not reached.
191
+ */
192
+ private checkThresholds;
161
193
  /**
162
- * Resolve reporters from various configuration options
194
+ * Check if current coverage is above configured thresholds and bump the thresholds if needed
163
195
  */
164
- resolveReporters(configReporters: NonNullable<BaseCoverageOptions['reporter']>): ResolvedCoverageOptions['reporter'];
196
+ updateThresholds({ thresholds: allThresholds, onUpdate, configurationFile }: {
197
+ thresholds: ResolvedThreshold[];
198
+ configurationFile: unknown;
199
+ onUpdate: () => void;
200
+ }): Promise<void>;
201
+ mergeReports(coverageMaps: unknown[]): Promise<void>;
165
202
  hasTerminalReporter(reporters: ResolvedCoverageOptions['reporter']): boolean;
166
203
  toSlices<T>(array: T[], size: number): T[][];
167
204
  createUncoveredFileTransformer(ctx: Vitest): (filename: string) => Promise<vite.TransformResult | null | undefined>;