vitest 4.0.0-beta.1 → 4.0.0-beta.11

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 (90) hide show
  1. package/LICENSE.md +83 -2
  2. package/dist/browser.d.ts +19 -16
  3. package/dist/browser.js +11 -7
  4. package/dist/chunks/{benchmark.CYdenmiT.js → benchmark.LXhJ0F0X.js} +7 -9
  5. package/dist/chunks/{benchmark.d.BwvBVTda.d.ts → benchmark.d.DAaHLpsq.d.ts} +4 -4
  6. package/dist/chunks/{browser.d.q8Z0P0q1.d.ts → browser.d.Dx7DO_Ce.d.ts} +5 -5
  7. package/dist/chunks/{cac.D3EzDDZd.js → cac.elvK37c9.js} +71 -153
  8. package/dist/chunks/{cli-api.Dn5gKePv.js → cli-api.C7plPyhs.js} +1376 -1693
  9. package/dist/chunks/{config.d.HJdfX-8k.d.ts → config.d.B_LthbQq.d.ts} +58 -63
  10. package/dist/chunks/{console.CtFJOzRO.js → console.CiTi59Jy.js} +35 -71
  11. package/dist/chunks/{constants.DnKduX2e.js → constants.D_Q9UYh-.js} +1 -9
  12. package/dist/chunks/{coverage.Cwa-XhJt.js → coverage.CG6Uhorw.js} +522 -792
  13. package/dist/chunks/{coverage.DVF1vEu8.js → coverage.D_JHT54q.js} +2 -2
  14. package/dist/chunks/{coverage.d.S9RMNXIe.d.ts → coverage.d.BZtK59WP.d.ts} +10 -8
  15. package/dist/chunks/{creator.GK6I-cL4.js → creator.08Gi-vCA.js} +93 -77
  16. package/dist/chunks/{date.Bq6ZW5rf.js → date.-jtEtIeV.js} +6 -17
  17. package/dist/chunks/{environment.d.CUq4cUgQ.d.ts → environment.d.BsToaxti.d.ts} +27 -6
  18. package/dist/chunks/{git.BVQ8w_Sw.js → git.BFNcloKD.js} +1 -2
  19. package/dist/chunks/{global.d.CVbXEflG.d.ts → global.d.BK3X7FW1.d.ts} +2 -5
  20. package/dist/chunks/{globals.Cxal6MLI.js → globals.BjvYA-AD.js} +11 -9
  21. package/dist/chunks/{index.BWf_gE5n.js → index.AZOjjqWP.js} +7 -6
  22. package/dist/chunks/{index.B521nVV-.js → index.Bgo3tNWt.js} +23 -4
  23. package/dist/chunks/{index.TfbsX-3I.js → index.BhY64fF0.js} +16 -26
  24. package/dist/chunks/{index.CZI_8rVt.js → index.BwBttQPf.js} +340 -663
  25. package/dist/chunks/{index.CmSc2RE5.js → index.DIWhzsUh.js} +72 -118
  26. package/dist/chunks/{inspector.C914Efll.js → inspector.CvQD-Nie.js} +10 -25
  27. package/dist/chunks/moduleRunner.d.BNa-CL9e.d.ts +201 -0
  28. package/dist/chunks/{node.fjCdwEIl.js → node.BsdMi6DV.js} +2 -2
  29. package/dist/chunks/{plugin.d.C2EcJUjo.d.ts → plugin.d.C5phQR6o.d.ts} +1 -1
  30. package/dist/chunks/{reporters.d.DxZg19fy.d.ts → reporters.d.CVzhsTvK.d.ts} +1233 -1293
  31. package/dist/chunks/resolveSnapshotEnvironment.DQVamkje.js +81 -0
  32. package/dist/chunks/rpc.jKGRSXIH.js +65 -0
  33. package/dist/chunks/{setup-common.D7ZqXFx-.js → setup-common.NAWRuMRP.js} +18 -30
  34. package/dist/chunks/startModuleRunner.oAuCu1yL.js +682 -0
  35. package/dist/chunks/{suite.d.FvehnV49.d.ts → suite.d.BJWk38HB.d.ts} +1 -1
  36. package/dist/chunks/test.KC5tH8hC.js +214 -0
  37. package/dist/chunks/typechecker.gXq-5P3n.js +1438 -0
  38. package/dist/chunks/{utils.XdZDrNZV.js → utils.DGKhod2J.js} +9 -28
  39. package/dist/chunks/{vi.bdSIJ99Y.js → vi.CiJ0Laa6.js} +159 -306
  40. package/dist/chunks/worker.d.B_Fd9M_w.d.ts +100 -0
  41. package/dist/chunks/worker.rPGLlbkW.js +200 -0
  42. package/dist/cli.js +8 -6
  43. package/dist/config.cjs +3 -9
  44. package/dist/config.d.ts +49 -54
  45. package/dist/config.js +1 -1
  46. package/dist/coverage.d.ts +27 -26
  47. package/dist/coverage.js +6 -8
  48. package/dist/environments.d.ts +9 -13
  49. package/dist/environments.js +1 -1
  50. package/dist/index.d.ts +38 -45
  51. package/dist/index.js +10 -10
  52. package/dist/module-evaluator.d.ts +13 -0
  53. package/dist/module-evaluator.js +276 -0
  54. package/dist/module-runner.js +15 -0
  55. package/dist/node.d.ts +44 -42
  56. package/dist/node.js +30 -36
  57. package/dist/reporters.d.ts +12 -13
  58. package/dist/reporters.js +7 -5
  59. package/dist/runners.d.ts +3 -3
  60. package/dist/runners.js +15 -232
  61. package/dist/snapshot.js +3 -3
  62. package/dist/suite.d.ts +2 -2
  63. package/dist/suite.js +4 -3
  64. package/dist/worker-base.js +203 -0
  65. package/dist/{chunks/vm.BThCzidc.js → worker-vm.js} +179 -228
  66. package/dist/workers/runVmTests.js +39 -56
  67. package/globals.d.ts +17 -17
  68. package/package.json +40 -38
  69. package/browser.d.ts +0 -1
  70. package/dist/chunks/base.Bj3pWTr1.js +0 -38
  71. package/dist/chunks/execute.B7h3T_Hc.js +0 -708
  72. package/dist/chunks/index.D-VkfKhf.js +0 -105
  73. package/dist/chunks/rpc.CsFtxqeq.js +0 -83
  74. package/dist/chunks/runBaseTests.BC7ZIH5L.js +0 -129
  75. package/dist/chunks/typechecker.CVytUJuF.js +0 -874
  76. package/dist/chunks/utils.CAioKnHs.js +0 -61
  77. package/dist/chunks/worker.d.CmvJfRGs.d.ts +0 -8
  78. package/dist/chunks/worker.d.DoNjFAiv.d.ts +0 -169
  79. package/dist/execute.d.ts +0 -148
  80. package/dist/execute.js +0 -13
  81. package/dist/worker.js +0 -124
  82. package/dist/workers/forks.js +0 -43
  83. package/dist/workers/threads.js +0 -31
  84. package/dist/workers/vmForks.js +0 -47
  85. package/dist/workers/vmThreads.js +0 -37
  86. package/dist/workers.d.ts +0 -37
  87. package/dist/workers.js +0 -30
  88. package/execute.d.ts +0 -1
  89. package/utils.d.ts +0 -1
  90. package/workers.d.ts +0 -1
@@ -0,0 +1,100 @@
1
+ import { CancelReason, File, TestAnnotation, TaskResultPack, TaskEventPack, FileSpecification, Task } from '@vitest/runner';
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';
5
+ import { SnapshotResult } from '@vitest/snapshot';
6
+
7
+ type ArgumentsType<T> = T extends (...args: infer A) => any ? A : never;
8
+ type ReturnType<T> = T extends (...args: any) => infer R ? R : never;
9
+ type PromisifyFn<T> = ReturnType<T> extends Promise<any> ? T : (...args: ArgumentsType<T>) => Promise<Awaited<ReturnType<T>>>;
10
+ type BirpcFn<T> = PromisifyFn<T> & {
11
+ /**
12
+ * Send event without asking for response
13
+ */
14
+ asEvent: (...args: ArgumentsType<T>) => void;
15
+ };
16
+ type BirpcReturn<RemoteFunctions, LocalFunctions = Record<string, never>> = {
17
+ [K in keyof RemoteFunctions]: BirpcFn<RemoteFunctions[K]>;
18
+ } & {
19
+ $functions: LocalFunctions;
20
+ $close: (error?: Error) => void;
21
+ $closed: boolean;
22
+ $rejectPendingCalls: (handler?: PendingCallHandler) => Promise<void>[];
23
+ };
24
+ type PendingCallHandler = (options: Pick<PromiseEntry, 'method' | 'reject'>) => void | Promise<void>;
25
+ interface PromiseEntry {
26
+ resolve: (arg: any) => void;
27
+ reject: (error: any) => void;
28
+ method: string;
29
+ timeoutId?: ReturnType<typeof setTimeout>;
30
+ }
31
+ declare const setTimeout: typeof globalThis.setTimeout;
32
+
33
+ interface RuntimeRPC {
34
+ fetch: (id: string, importer: string | undefined, environment: string, options?: FetchFunctionOptions) => Promise<FetchResult | FetchCachedFileSystemResult>;
35
+ resolve: (id: string, importer: string | undefined, environment: string) => Promise<ResolveFunctionResult | null>;
36
+ transform: (id: string) => Promise<{
37
+ code?: string;
38
+ }>;
39
+ onUserConsoleLog: (log: UserConsoleLog) => void;
40
+ onUnhandledError: (err: unknown, type: string) => void;
41
+ onQueued: (file: File) => void;
42
+ onCollected: (files: File[]) => Promise<void>;
43
+ onAfterSuiteRun: (meta: AfterSuiteRunMeta) => void;
44
+ onTaskAnnotate: (testId: string, annotation: TestAnnotation) => Promise<TestAnnotation>;
45
+ onTaskUpdate: (pack: TaskResultPack[], events: TaskEventPack[]) => Promise<void>;
46
+ onCancel: (reason: CancelReason) => void;
47
+ getCountOfFailedTests: () => number;
48
+ snapshotSaved: (snapshot: SnapshotResult) => void;
49
+ resolveSnapshotPath: (testPath: string) => string;
50
+ }
51
+ interface RunnerRPC {
52
+ onCancel: (reason: CancelReason) => void;
53
+ }
54
+
55
+ type WorkerRPC = BirpcReturn<RuntimeRPC, RunnerRPC>;
56
+ interface ContextTestEnvironment {
57
+ name: string;
58
+ options: Record<string, any> | null;
59
+ }
60
+ type TestExecutionMethod = "run" | "collect";
61
+ interface ContextRPC {
62
+ pool: string;
63
+ workerId: number;
64
+ config: SerializedConfig;
65
+ projectName: string;
66
+ files: string[] | FileSpecification[];
67
+ environment: ContextTestEnvironment;
68
+ providedContext: Record<string, any>;
69
+ invalidates?: string[];
70
+ }
71
+ interface WorkerGlobalState {
72
+ ctx: ContextRPC;
73
+ config: SerializedConfig;
74
+ rpc: WorkerRPC;
75
+ current?: Task;
76
+ filepath?: string;
77
+ metaEnv: {
78
+ [key: string]: any;
79
+ BASE_URL: string;
80
+ MODE: string;
81
+ DEV: boolean;
82
+ PROD: boolean;
83
+ SSR: boolean;
84
+ };
85
+ environment: Environment;
86
+ environmentTeardownRun?: boolean;
87
+ onCancel: Promise<CancelReason>;
88
+ evaluatedModules: EvaluatedModules;
89
+ resolvingModules: Set<string>;
90
+ moduleExecutionInfo: Map<string, any>;
91
+ onCleanup: (listener: () => unknown) => void;
92
+ providedContext: Record<string, any>;
93
+ durations: {
94
+ environment: number;
95
+ prepare: number;
96
+ };
97
+ onFilterStackTrace?: (trace: string) => string;
98
+ }
99
+
100
+ export type { BirpcReturn as B, ContextRPC as C, RunnerRPC as R, TestExecutionMethod as T, WorkerGlobalState as W, RuntimeRPC as a, ContextTestEnvironment as b };
@@ -0,0 +1,200 @@
1
+ import { createStackString, parseStacktrace } from '@vitest/utils/source-map';
2
+ import { ModuleRunner, EvaluatedModules } from 'vite/module-runner';
3
+ import { readFileSync } from 'node:fs';
4
+ import { isBuiltin } from 'node:module';
5
+ import { pathToFileURL } from 'node:url';
6
+ import { resolve } from 'pathe';
7
+ import { b as VitestTransport } from './startModuleRunner.oAuCu1yL.js';
8
+ import { e as environments } from './index.DIWhzsUh.js';
9
+ import { s as setupInspect } from './inspector.CvQD-Nie.js';
10
+ import { c as createRuntimeRpc, a as rpcDone } from './rpc.jKGRSXIH.js';
11
+ import { i as isChildProcess } from './utils.DGKhod2J.js';
12
+
13
+ function isBuiltinEnvironment(env) {
14
+ return env in environments;
15
+ }
16
+ const isWindows = process.platform === "win32", _loaders = /* @__PURE__ */ new Map();
17
+ async function createEnvironmentLoader(root, rpc) {
18
+ const cachedLoader = _loaders.get(root);
19
+ if (!cachedLoader || cachedLoader.isClosed()) {
20
+ _loaders.delete(root);
21
+ const moduleRunner = new ModuleRunner({
22
+ hmr: false,
23
+ sourcemapInterceptor: "prepareStackTrace",
24
+ transport: new VitestTransport({
25
+ async fetchModule(id, importer, options) {
26
+ const result = await rpc.fetch(id, importer, "__vitest__", options);
27
+ if ("cached" in result) {
28
+ const code = readFileSync(result.tmp, "utf-8");
29
+ return {
30
+ code,
31
+ ...result
32
+ };
33
+ }
34
+ if (isWindows && "externalize" in result)
35
+ // TODO: vitest returns paths for external modules, but Vite returns file://
36
+ // https://github.com/vitejs/vite/pull/20449
37
+ result.externalize = isBuiltin(id) || /^(?:node:|data:|http:|https:|file:)/.test(id) ? result.externalize : pathToFileURL(result.externalize).toString();
38
+ return result;
39
+ },
40
+ async resolveId(id, importer) {
41
+ return rpc.resolve(id, importer, "__vitest__");
42
+ }
43
+ })
44
+ });
45
+ _loaders.set(root, moduleRunner), await moduleRunner.import("/@vite/env");
46
+ }
47
+ return _loaders.get(root);
48
+ }
49
+ async function loadEnvironment(ctx, rpc) {
50
+ const name = ctx.environment.name;
51
+ if (isBuiltinEnvironment(name)) return { environment: environments[name] };
52
+ const root = ctx.config.root, loader = await createEnvironmentLoader(root, rpc), packageId = name[0] === "." || name[0] === "/" ? resolve(root, name) : (await rpc.resolve(`vitest-environment-${name}`, void 0, "__vitest__"))?.id ?? resolve(root, name), pkg = await loader.import(packageId);
53
+ if (!pkg || !pkg.default || typeof pkg.default !== "object") throw new TypeError(`Environment "${name}" is not a valid environment. Path "${packageId}" should export default object with a "setup" or/and "setupVM" method.`);
54
+ const environment = pkg.default;
55
+ if (environment.transformMode != null && environment.transformMode !== "web" && environment.transformMode !== "ssr") throw new TypeError(`Environment "${name}" is not a valid environment. Path "${packageId}" should export default object with a "transformMode" method equal to "ssr" or "web", received "${environment.transformMode}".`);
56
+ if (environment.transformMode)
57
+ // keep for backwards compat
58
+ console.warn(`The Vitest environment ${environment.name} defines the "transformMode". This options was deprecated in Vitest 4 and will be removed in the next major version. Please, use "viteEnvironment" instead.`), environment.viteEnvironment ??= environment.transformMode === "ssr" ? "ssr" : "client";
59
+ return {
60
+ environment,
61
+ loader
62
+ };
63
+ }
64
+
65
+ const REGEXP_WRAP_PREFIX = "$$vitest:", processSend = process.send?.bind(process), processOn = process.on?.bind(process), processOff = process.off?.bind(process), dispose = [];
66
+ function createThreadsRpcOptions({ port }) {
67
+ return {
68
+ post: (v) => {
69
+ port.postMessage(v);
70
+ },
71
+ on: (fn) => {
72
+ port.addListener("message", fn);
73
+ }
74
+ };
75
+ }
76
+ function disposeInternalListeners() {
77
+ for (const fn of dispose) try {
78
+ fn();
79
+ } catch {}
80
+ dispose.length = 0;
81
+ }
82
+ function createForksRpcOptions(nodeV8) {
83
+ return {
84
+ serialize: nodeV8.serialize,
85
+ deserialize: (v) => nodeV8.deserialize(Buffer.from(v)),
86
+ post(v) {
87
+ processSend(v);
88
+ },
89
+ on(fn) {
90
+ const handler = (message, ...extras) => {
91
+ if (!message?.__tinypool_worker_message__) return fn(message, ...extras);
92
+ };
93
+ processOn("message", handler), dispose.push(() => processOff("message", handler));
94
+ }
95
+ };
96
+ }
97
+ /**
98
+ * Reverts the wrapping done by `utils/config-helpers.ts`'s `wrapSerializableConfig`
99
+ */
100
+ function unwrapSerializableConfig(config) {
101
+ if (config.testNamePattern && typeof config.testNamePattern === "string") {
102
+ const testNamePattern = config.testNamePattern;
103
+ if (testNamePattern.startsWith(REGEXP_WRAP_PREFIX)) config.testNamePattern = parseRegexp(testNamePattern.slice(9));
104
+ }
105
+ if (config.defines && Array.isArray(config.defines.keys) && config.defines.original) {
106
+ const { keys, original } = config.defines, defines = {};
107
+ // Apply all keys from the original. Entries which had undefined value are missing from original now
108
+ for (const key of keys) defines[key] = original[key];
109
+ config.defines = defines;
110
+ }
111
+ return config;
112
+ }
113
+ function parseRegexp(input) {
114
+ // Parse input
115
+ // eslint-disable-next-line regexp/no-misleading-capturing-group
116
+ const m = input.match(/(\/?)(.+)\1([a-z]*)/i);
117
+ // Create the regular expression
118
+ return m ? m[3] && !/^(?!.*?(.).*?\1)[gmixXsuUAJ]+$/.test(m[3]) ? new RegExp(input) : new RegExp(m[2], m[3]) : /$^/;
119
+ }
120
+
121
+ if (isChildProcess()) {
122
+ const isProfiling = process.execArgv.some((execArg) => execArg.startsWith("--prof") || execArg.startsWith("--cpu-prof") || execArg.startsWith("--heap-prof") || execArg.startsWith("--diagnostic-dir"));
123
+ if (isProfiling)
124
+ // Work-around for nodejs/node#55094
125
+ process.on("SIGTERM", () => {
126
+ process.exit();
127
+ });
128
+ }
129
+ const resolvingModules = /* @__PURE__ */ new Set(), globalListeners = /* @__PURE__ */ new Set();
130
+ // this is what every pool executes when running tests
131
+ async function execute(method, ctx, worker) {
132
+ disposeInternalListeners();
133
+ const prepareStart = performance.now(), cleanups = [setupInspect(ctx)];
134
+ process.env.VITEST_WORKER_ID = String(ctx.workerId);
135
+ const poolId = process.__tinypool_state__?.workerId;
136
+ process.env.VITEST_POOL_ID = String(poolId);
137
+ let environmentLoader;
138
+ try {
139
+ if (!worker.getRpcOptions || typeof worker.getRpcOptions !== "function") throw new TypeError(`Test worker should expose "getRpcOptions" method. Received "${typeof worker.getRpcOptions}".`);
140
+ // RPC is used to communicate between worker (be it a thread worker or child process or a custom implementation) and the main thread
141
+ const { rpc, onCancel } = createRuntimeRpc(worker.getRpcOptions(ctx));
142
+ // do not close the RPC channel so that we can get the error messages sent to the main thread
143
+ cleanups.push(async () => {
144
+ await Promise.all(rpc.$rejectPendingCalls(({ method, reject }) => {
145
+ reject(/* @__PURE__ */ new Error(`[vitest-worker]: Closing rpc while "${method}" was pending`));
146
+ }));
147
+ });
148
+ const beforeEnvironmentTime = performance.now(), { environment, loader } = await loadEnvironment(ctx, rpc);
149
+ environmentLoader = loader;
150
+ const state = {
151
+ ctx,
152
+ evaluatedModules: new EvaluatedModules(),
153
+ resolvingModules,
154
+ moduleExecutionInfo: /* @__PURE__ */ new Map(),
155
+ config: ctx.config,
156
+ onCancel,
157
+ environment,
158
+ durations: {
159
+ environment: beforeEnvironmentTime,
160
+ prepare: prepareStart
161
+ },
162
+ rpc,
163
+ onCleanup: (listener) => globalListeners.add(listener),
164
+ providedContext: ctx.providedContext,
165
+ onFilterStackTrace(stack) {
166
+ return createStackString(parseStacktrace(stack));
167
+ },
168
+ metaEnv: createImportMetaEnvProxy()
169
+ }, methodName = method === "collect" ? "collectTests" : "runTests";
170
+ if (!worker[methodName] || typeof worker[methodName] !== "function") throw new TypeError(`Test worker should expose "runTests" method. Received "${typeof worker.runTests}".`);
171
+ await worker[methodName](state);
172
+ } finally {
173
+ await Promise.all(cleanups.map((fn) => fn())), await rpcDone().catch(() => {}), environmentLoader?.close();
174
+ }
175
+ }
176
+ async function teardown() {
177
+ const promises = [...globalListeners].map((l) => l());
178
+ await Promise.all(promises);
179
+ }
180
+ function createImportMetaEnvProxy() {
181
+ // packages/vitest/src/node/plugins/index.ts:146
182
+ const booleanKeys = [
183
+ "DEV",
184
+ "PROD",
185
+ "SSR"
186
+ ];
187
+ return new Proxy(process.env, {
188
+ get(_, key) {
189
+ return typeof key === "string" ? booleanKeys.includes(key) ? !!process.env[key] : process.env[key] : void 0;
190
+ },
191
+ set(_, key, value) {
192
+ if (typeof key !== "string") return true;
193
+ if (booleanKeys.includes(key)) process.env[key] = value ? "1" : "";
194
+ else process.env[key] = value;
195
+ return true;
196
+ }
197
+ });
198
+ }
199
+
200
+ export { createThreadsRpcOptions as a, createForksRpcOptions as c, execute as e, teardown as t, unwrapSerializableConfig as u };
package/dist/cli.js CHANGED
@@ -1,27 +1,29 @@
1
- import { c as createCLI } from './chunks/cac.D3EzDDZd.js';
2
- import '@vitest/utils';
1
+ import { c as createCLI } from './chunks/cac.elvK37c9.js';
2
+ import '@vitest/utils/helpers';
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.BwBttQPf.js';
8
8
  import 'node:fs';
9
9
  import 'node:fs/promises';
10
- import './chunks/typechecker.CVytUJuF.js';
10
+ import './chunks/typechecker.gXq-5P3n.js';
11
11
  import 'node:os';
12
12
  import 'node:perf_hooks';
13
- import '@vitest/utils/source-map';
14
13
  import 'tinyexec';
15
14
  import './path.js';
16
15
  import 'node:path';
17
16
  import 'node:url';
18
17
  import '@vitest/runner/utils';
19
18
  import 'vite';
19
+ import '@vitest/utils/source-map';
20
20
  import './chunks/env.D4Lgay0q.js';
21
21
  import 'std-env';
22
22
  import 'node:util';
23
23
  import 'node:console';
24
24
  import 'node:stream';
25
+ import '@vitest/utils/display';
26
+ import '@vitest/utils/offset';
25
27
  import 'node:module';
26
28
 
27
29
  createCLI().parse();
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.CVzhsTvK.js';
4
+ export { a as TestProjectConfiguration, g as TestProjectInlineConfiguration, f as TestUserConfig, W as WatcherTriggerPattern } from './chunks/reporters.d.CVzhsTvK.js';
5
+ import { V as VitestPluginContext } from './chunks/plugin.d.C5phQR6o.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.Dx7DO_Ce.js';
14
+ import './chunks/worker.d.B_Fd9M_w.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.CVzhsTvK.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.Dx7DO_Ce.js';
10
+ import './chunks/worker.d.B_Fd9M_w.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.CG6Uhorw.js';
2
2
  import 'node:fs';
3
3
  import 'node:path';
4
+ import '@vitest/utils/helpers';
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,15 @@ 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.gXq-5P3n.js';
29
28
  import 'node:perf_hooks';
30
- import '@vitest/utils/source-map';
31
29
  import 'tinyexec';
32
30
  import './path.js';
33
31
  import '@vitest/runner/utils';
34
32
  import 'node:worker_threads';
35
- import './chunks/coverage.DVF1vEu8.js';
33
+ import './chunks/coverage.D_JHT54q.js';