vitest 4.0.6 → 4.0.8
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.
- package/LICENSE.md +1 -1
- package/dist/browser.d.ts +2 -2
- package/dist/browser.js +2 -2
- package/dist/chunks/base.BgTO2qAg.js +156 -0
- package/dist/chunks/{benchmark.DHKMYAts.js → benchmark.B3N2zMcH.js} +9 -4
- package/dist/chunks/{browser.d.ScGeWTou.d.ts → browser.d.DTTM2PTh.d.ts} +1 -1
- package/dist/chunks/{cac.BBqWH4nd.js → cac.CfkWq8Qy.js} +117 -43
- package/dist/chunks/{cli-api.UL3SwFUb.js → cli-api.BQ-bjcRi.js} +1870 -847
- package/dist/chunks/console.Cf-YriPC.js +146 -0
- package/dist/chunks/{coverage.DuCn_Tmx.js → coverage.NVjCOln1.js} +281 -103
- package/dist/chunks/{creator.cqqifzG7.js → creator.fzVyoMf3.js} +74 -30
- package/dist/chunks/{date.-jtEtIeV.js → date.Bq6ZW5rf.js} +17 -6
- package/dist/chunks/{git.BFNcloKD.js → git.Bm2pzPAa.js} +3 -3
- package/dist/chunks/{global.d.DdOkMiVb.d.ts → global.d.DVdCfKp5.d.ts} +1 -1
- package/dist/chunks/{globals.BGT_RUsD.js → globals.DOh96BiR.js} +5 -5
- package/dist/chunks/{resolveSnapshotEnvironment.BZzLjzkh.js → index.BY4-tcno.js} +42 -25
- package/dist/chunks/{index.Bgo3tNWt.js → index.DAL392Ss.js} +40 -15
- package/dist/chunks/{index.RwjEGCQ0.js → index.DIFZf73e.js} +2 -2
- package/dist/chunks/{index.DV0mQLEO.js → index.DfKyPFVi.js} +195 -64
- package/dist/chunks/{index.BL8Hg4Uk.js → index.kotH7DY7.js} +837 -380
- package/dist/chunks/{index.CpdwpN7L.js → index.op2Re5rn.js} +22 -12
- package/dist/chunks/{init-forks.CSGFj9zN.js → init-forks.2hx7cf78.js} +16 -5
- package/dist/chunks/{init-threads.CIJLeFO8.js → init-threads.Cm4OCIWA.js} +3 -2
- package/dist/chunks/{init.DUeOfNO9.js → init.DMDG-idf.js} +124 -54
- package/dist/chunks/{inspector.DLZxSeU3.js → inspector.CvyFGlXm.js} +25 -10
- package/dist/chunks/{moduleRunner.d.TP-w6tIQ.d.ts → moduleRunner.d.CzOZ_4wC.d.ts} +1 -1
- package/dist/chunks/{node.BwAWWjHZ.js → node.Ce0vMQM7.js} +1 -1
- package/dist/chunks/{plugin.d.lctzD3Wk.d.ts → plugin.d.D4RrtywJ.d.ts} +1 -1
- package/dist/chunks/{reporters.d.PEs0tXod.d.ts → reporters.d.Da1D1VbQ.d.ts} +19 -9
- package/dist/chunks/rpc.BUV7uWKJ.js +76 -0
- package/dist/chunks/{setup-common.DR1sucx6.js → setup-common.LGjNSzXp.js} +20 -8
- package/dist/chunks/{startModuleRunner.Di-EZqh0.js → startModuleRunner.BOmUtLIO.js} +228 -105
- package/dist/chunks/{test.CnspO-X4.js → test.ClrAtjMv.js} +48 -22
- package/dist/chunks/{utils.CG9h5ccR.js → utils.DvEY5TfP.js} +14 -5
- package/dist/chunks/{vi.BZvkKVkM.js → vi.Bgcdy3bQ.js} +261 -111
- package/dist/chunks/{vm.Co_lR2NL.js → vm.BIkCDs68.js} +177 -70
- package/dist/chunks/{worker.d.B4Hthdvt.d.ts → worker.d.DadbA89M.d.ts} +52 -6
- package/dist/cli.js +2 -2
- package/dist/config.d.ts +5 -5
- package/dist/coverage.d.ts +3 -3
- package/dist/coverage.js +1 -1
- package/dist/environments.js +2 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +5 -5
- package/dist/module-evaluator.d.ts +2 -2
- package/dist/module-evaluator.js +85 -35
- package/dist/module-runner.js +2 -2
- package/dist/node.d.ts +7 -7
- package/dist/node.js +16 -12
- package/dist/reporters.d.ts +3 -3
- package/dist/reporters.js +2 -2
- package/dist/runners.js +7 -7
- package/dist/snapshot.js +2 -2
- package/dist/suite.js +2 -2
- package/dist/worker.d.ts +2 -1
- package/dist/worker.js +27 -27
- package/dist/workers/forks.js +34 -31
- package/dist/workers/runVmTests.js +41 -22
- package/dist/workers/threads.js +34 -31
- package/dist/workers/vmForks.js +14 -14
- package/dist/workers/vmThreads.js +14 -14
- package/package.json +20 -20
- package/dist/chunks/base.BAf_bYeI.js +0 -128
- package/dist/chunks/console.CTJL2nuH.js +0 -115
- package/dist/chunks/rpc.Dv1Jt3i2.js +0 -66
|
@@ -43,7 +43,8 @@ type LabelColor = "black" | "red" | "green" | "yellow" | "blue" | "magenta" | "c
|
|
|
43
43
|
type ArgumentsType<T> = T extends (...args: infer A) => any ? A : never;
|
|
44
44
|
type ReturnType<T> = T extends (...args: any) => infer R ? R : never;
|
|
45
45
|
type PromisifyFn<T> = ReturnType<T> extends Promise<any> ? T : (...args: ArgumentsType<T>) => Promise<Awaited<ReturnType<T>>>;
|
|
46
|
-
type
|
|
46
|
+
type Thenable<T> = T | PromiseLike<T>;
|
|
47
|
+
type BirpcResolver = (name: string, resolved: (...args: unknown[]) => unknown) => Thenable<((...args: unknown[]) => unknown) | undefined>;
|
|
47
48
|
interface ChannelOptions {
|
|
48
49
|
/**
|
|
49
50
|
* Function to post raw message
|
|
@@ -91,6 +92,14 @@ interface EventOptions<Remote> {
|
|
|
91
92
|
* For advanced use cases only
|
|
92
93
|
*/
|
|
93
94
|
resolver?: BirpcResolver;
|
|
95
|
+
/**
|
|
96
|
+
* Hook triggered before an event is sent to the remote
|
|
97
|
+
*
|
|
98
|
+
* @param req - Request parameters
|
|
99
|
+
* @param next - Function to continue the request
|
|
100
|
+
* @param resolve - Function to resolve the response directly
|
|
101
|
+
*/
|
|
102
|
+
onRequest?: (req: Request, next: (req?: Request) => Promise<any>, resolve: (res: any) => void) => void | Promise<void>;
|
|
94
103
|
/**
|
|
95
104
|
* Custom error handler
|
|
96
105
|
*
|
|
@@ -121,7 +130,7 @@ type BirpcFn<T> = PromisifyFn<T> & {
|
|
|
121
130
|
/**
|
|
122
131
|
* Send event without asking for response
|
|
123
132
|
*/
|
|
124
|
-
asEvent: (...args: ArgumentsType<T>) => void
|
|
133
|
+
asEvent: (...args: ArgumentsType<T>) => Promise<void>;
|
|
125
134
|
};
|
|
126
135
|
type BirpcReturn<RemoteFunctions, LocalFunctions = Record<string, never>> = {
|
|
127
136
|
[K in keyof RemoteFunctions]: BirpcFn<RemoteFunctions[K]>;
|
|
@@ -138,6 +147,25 @@ interface PromiseEntry {
|
|
|
138
147
|
method: string;
|
|
139
148
|
timeoutId?: ReturnType<typeof setTimeout>;
|
|
140
149
|
}
|
|
150
|
+
declare const TYPE_REQUEST: "q";
|
|
151
|
+
interface Request {
|
|
152
|
+
/**
|
|
153
|
+
* Type
|
|
154
|
+
*/
|
|
155
|
+
t: typeof TYPE_REQUEST;
|
|
156
|
+
/**
|
|
157
|
+
* ID
|
|
158
|
+
*/
|
|
159
|
+
i?: string;
|
|
160
|
+
/**
|
|
161
|
+
* Method
|
|
162
|
+
*/
|
|
163
|
+
m: string;
|
|
164
|
+
/**
|
|
165
|
+
* Arguments
|
|
166
|
+
*/
|
|
167
|
+
a: any[];
|
|
168
|
+
}
|
|
141
169
|
declare const setTimeout: typeof globalThis.setTimeout;
|
|
142
170
|
|
|
143
171
|
interface RuntimeRPC {
|
|
@@ -167,18 +195,37 @@ interface ContextTestEnvironment {
|
|
|
167
195
|
name: string;
|
|
168
196
|
options: Record<string, any> | null;
|
|
169
197
|
}
|
|
198
|
+
interface WorkerTestEnvironment {
|
|
199
|
+
name: string;
|
|
200
|
+
options: Record<string, any> | null;
|
|
201
|
+
}
|
|
170
202
|
type TestExecutionMethod = "run" | "collect";
|
|
203
|
+
interface WorkerExecuteContext {
|
|
204
|
+
files: FileSpecification[];
|
|
205
|
+
providedContext: Record<string, any>;
|
|
206
|
+
invalidates?: string[];
|
|
207
|
+
/** Exposed to test runner as `VITEST_WORKER_ID`. Value is unique per each isolated worker. */
|
|
208
|
+
workerId: number;
|
|
209
|
+
}
|
|
171
210
|
interface ContextRPC {
|
|
172
211
|
pool: string;
|
|
173
212
|
config: SerializedConfig;
|
|
174
213
|
projectName: string;
|
|
214
|
+
environment: WorkerTestEnvironment;
|
|
215
|
+
rpc: WorkerRPC;
|
|
175
216
|
files: FileSpecification[];
|
|
176
|
-
environment: ContextTestEnvironment;
|
|
177
217
|
providedContext: Record<string, any>;
|
|
178
218
|
invalidates?: string[];
|
|
179
219
|
/** Exposed to test runner as `VITEST_WORKER_ID`. Value is unique per each isolated worker. */
|
|
180
220
|
workerId: number;
|
|
181
221
|
}
|
|
222
|
+
interface WorkerSetupContext {
|
|
223
|
+
environment: WorkerTestEnvironment;
|
|
224
|
+
pool: string;
|
|
225
|
+
config: SerializedConfig;
|
|
226
|
+
projectName: string;
|
|
227
|
+
rpc: WorkerRPC;
|
|
228
|
+
}
|
|
182
229
|
interface WorkerGlobalState {
|
|
183
230
|
ctx: ContextRPC;
|
|
184
231
|
config: SerializedConfig;
|
|
@@ -194,11 +241,10 @@ interface WorkerGlobalState {
|
|
|
194
241
|
SSR: boolean;
|
|
195
242
|
};
|
|
196
243
|
environment: Environment;
|
|
197
|
-
environmentTeardownRun?: boolean;
|
|
198
|
-
onCancel: Promise<CancelReason>;
|
|
199
244
|
evaluatedModules: EvaluatedModules;
|
|
200
245
|
resolvingModules: Set<string>;
|
|
201
246
|
moduleExecutionInfo: Map<string, any>;
|
|
247
|
+
onCancel: (listener: (reason: CancelReason) => unknown) => void;
|
|
202
248
|
onCleanup: (listener: () => unknown) => void;
|
|
203
249
|
providedContext: Record<string, any>;
|
|
204
250
|
durations: {
|
|
@@ -208,4 +254,4 @@ interface WorkerGlobalState {
|
|
|
208
254
|
onFilterStackTrace?: (trace: string) => string;
|
|
209
255
|
}
|
|
210
256
|
|
|
211
|
-
export type { AfterSuiteRunMeta as A, BirpcOptions as B, ContextRPC as C, LabelColor as L, ModuleGraphData as M, ProvidedContext as P, RuntimeRPC as R, TestExecutionMethod as T, UserConsoleLog as U, WorkerGlobalState as W,
|
|
257
|
+
export type { AfterSuiteRunMeta as A, BirpcOptions as B, ContextRPC as C, LabelColor as L, ModuleGraphData as M, ProvidedContext as P, RuntimeRPC as R, TestExecutionMethod as T, UserConsoleLog as U, WorkerGlobalState as W, WorkerSetupContext as a, BirpcReturn as b, RunnerRPC as c, ContextTestEnvironment as d, ResolveFunctionResult as e, WorkerTestEnvironment as f, WorkerExecuteContext as g };
|
package/dist/cli.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { c as createCLI } from './chunks/cac.
|
|
1
|
+
import { c as createCLI } from './chunks/cac.CfkWq8Qy.js';
|
|
2
2
|
import '@vitest/utils/helpers';
|
|
3
3
|
import 'events';
|
|
4
4
|
import 'pathe';
|
|
5
5
|
import 'tinyrainbow';
|
|
6
6
|
import './chunks/constants.D_Q9UYh-.js';
|
|
7
|
-
import './chunks/index.
|
|
7
|
+
import './chunks/index.kotH7DY7.js';
|
|
8
8
|
import 'node:fs';
|
|
9
9
|
import 'node:fs/promises';
|
|
10
10
|
import 'node:perf_hooks';
|
package/dist/config.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
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.
|
|
4
|
-
export { a as TestProjectConfiguration, g as TestProjectInlineConfiguration, f as TestUserConfig, W as WatcherTriggerPattern } from './chunks/reporters.d.
|
|
5
|
-
import { V as VitestPluginContext } from './chunks/plugin.d.
|
|
3
|
+
import { I as InlineConfig, c as CoverageV8Options, R as ResolvedCoverageOptions, U as UserWorkspaceConfig, d as UserProjectConfigFn, e as UserProjectConfigExport } from './chunks/reporters.d.Da1D1VbQ.js';
|
|
4
|
+
export { a as TestProjectConfiguration, g as TestProjectInlineConfiguration, f as TestUserConfig, W as WatcherTriggerPattern } from './chunks/reporters.d.Da1D1VbQ.js';
|
|
5
|
+
import { V as VitestPluginContext } from './chunks/plugin.d.D4RrtywJ.js';
|
|
6
6
|
import { F as FakeTimerInstallOpts } from './chunks/config.d.BTfZNUu9.js';
|
|
7
7
|
import '@vitest/runner';
|
|
8
8
|
import '@vitest/utils';
|
|
9
|
-
import './chunks/worker.d.
|
|
9
|
+
import './chunks/worker.d.DadbA89M.js';
|
|
10
10
|
import 'vite/module-runner';
|
|
11
11
|
import './chunks/environment.d.CrsxCzP1.js';
|
|
12
12
|
import '@vitest/snapshot';
|
|
@@ -14,7 +14,7 @@ import 'node:stream';
|
|
|
14
14
|
import '@vitest/mocker';
|
|
15
15
|
import '@vitest/utils/source-map';
|
|
16
16
|
import 'vitest/browser';
|
|
17
|
-
import './chunks/browser.d.
|
|
17
|
+
import './chunks/browser.d.DTTM2PTh.js';
|
|
18
18
|
import '@vitest/pretty-format';
|
|
19
19
|
import '@vitest/utils/diff';
|
|
20
20
|
import '@vitest/expect';
|
package/dist/coverage.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { R as ResolvedCoverageOptions, V as Vitest, C as CoverageMap, b as ReportContext } from './chunks/reporters.d.
|
|
1
|
+
import { R as ResolvedCoverageOptions, V as Vitest, C as CoverageMap, b as ReportContext } from './chunks/reporters.d.Da1D1VbQ.js';
|
|
2
2
|
import { TransformResult } from 'vite';
|
|
3
|
-
import { A as AfterSuiteRunMeta } from './chunks/worker.d.
|
|
3
|
+
import { A as AfterSuiteRunMeta } from './chunks/worker.d.DadbA89M.js';
|
|
4
4
|
import '@vitest/runner';
|
|
5
5
|
import '@vitest/utils';
|
|
6
6
|
import 'node:stream';
|
|
@@ -11,7 +11,7 @@ import './chunks/config.d.BTfZNUu9.js';
|
|
|
11
11
|
import '@vitest/pretty-format';
|
|
12
12
|
import '@vitest/snapshot';
|
|
13
13
|
import '@vitest/utils/diff';
|
|
14
|
-
import './chunks/browser.d.
|
|
14
|
+
import './chunks/browser.d.DTTM2PTh.js';
|
|
15
15
|
import '@vitest/expect';
|
|
16
16
|
import 'vitest/optional-types.js';
|
|
17
17
|
import './chunks/benchmark.d.DAaHLpsq.js';
|
package/dist/coverage.js
CHANGED
package/dist/environments.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { S as SerializedTestSpecification } from './chunks/browser.d.
|
|
2
|
-
export { B as BrowserTesterOptions } from './chunks/browser.d.
|
|
3
|
-
import './chunks/global.d.
|
|
1
|
+
import { S as SerializedTestSpecification } from './chunks/browser.d.DTTM2PTh.js';
|
|
2
|
+
export { B as BrowserTesterOptions } from './chunks/browser.d.DTTM2PTh.js';
|
|
3
|
+
import './chunks/global.d.DVdCfKp5.js';
|
|
4
4
|
import { File, TestAnnotation, TaskResultPack, TaskEventPack, TaskPopulated } from '@vitest/runner';
|
|
5
5
|
export { CancelReason, ImportDuration, OnTestFailedHandler, OnTestFinishedHandler, RunMode, Task as RunnerTask, TaskBase as RunnerTaskBase, TaskEventPack as RunnerTaskEventPack, TaskResult as RunnerTaskResult, TaskResultPack as RunnerTaskResultPack, Test as RunnerTestCase, File as RunnerTestFile, Suite as RunnerTestSuite, SuiteAPI, SuiteCollector, SuiteFactory, TaskCustomOptions, TaskMeta, TaskState, TestAPI, TestAnnotation, TestContext, TestFunction, TestOptions, afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, onTestFinished, suite, test } from '@vitest/runner';
|
|
6
6
|
import { Awaitable } from '@vitest/utils';
|
|
7
7
|
export { ParsedStack, SerializedError, TestError } from '@vitest/utils';
|
|
8
|
-
import { U as UserConsoleLog, L as LabelColor, M as ModuleGraphData,
|
|
9
|
-
export { A as AfterSuiteRunMeta, C as ContextRPC,
|
|
8
|
+
import { U as UserConsoleLog, L as LabelColor, M as ModuleGraphData, b as BirpcReturn, P as ProvidedContext } from './chunks/worker.d.DadbA89M.js';
|
|
9
|
+
export { A as AfterSuiteRunMeta, C as ContextRPC, d as ContextTestEnvironment, c as RunnerRPC, R as RuntimeRPC, T as TestExecutionMethod, W as WorkerGlobalState } from './chunks/worker.d.DadbA89M.js';
|
|
10
10
|
import { S as SerializedConfig, F as FakeTimerInstallOpts, R as RuntimeOptions } from './chunks/config.d.BTfZNUu9.js';
|
|
11
11
|
export { b as RuntimeConfig, a as SerializedCoverageConfig } from './chunks/config.d.BTfZNUu9.js';
|
|
12
12
|
import { ExpectStatic } from '@vitest/expect';
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export { b as assert, c as createExpect, g as expect, i as inject, s as should, v as vi, d as vitest } from './chunks/vi.
|
|
2
|
-
export { b as bench } from './chunks/benchmark.
|
|
1
|
+
export { b as assert, c as createExpect, g as expect, i as inject, s as should, v as vi, d as vitest } from './chunks/vi.Bgcdy3bQ.js';
|
|
2
|
+
export { b as bench } from './chunks/benchmark.B3N2zMcH.js';
|
|
3
3
|
export { V as EvaluatedModules } from './chunks/evaluatedModules.Dg1zASAC.js';
|
|
4
|
-
export { a as assertType } from './chunks/index.
|
|
4
|
+
export { a as assertType } from './chunks/index.DIFZf73e.js';
|
|
5
5
|
export { expectTypeOf } from 'expect-type';
|
|
6
6
|
export { afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, onTestFinished, suite, test } from '@vitest/runner';
|
|
7
7
|
export { chai } from '@vitest/expect';
|
|
8
8
|
import '@vitest/runner/utils';
|
|
9
|
-
import './chunks/utils.
|
|
9
|
+
import './chunks/utils.DvEY5TfP.js';
|
|
10
10
|
import '@vitest/utils/timers';
|
|
11
11
|
import '@vitest/snapshot';
|
|
12
12
|
import '@vitest/utils/error';
|
|
@@ -15,6 +15,6 @@ import '@vitest/spy';
|
|
|
15
15
|
import '@vitest/utils/offset';
|
|
16
16
|
import '@vitest/utils/source-map';
|
|
17
17
|
import './chunks/_commonjsHelpers.BFTU3MAI.js';
|
|
18
|
-
import './chunks/date
|
|
18
|
+
import './chunks/date.Bq6ZW5rf.js';
|
|
19
19
|
import 'pathe';
|
|
20
20
|
import 'vite/module-runner';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import 'vite/module-runner';
|
|
2
|
-
export { b as VitestModuleEvaluator, a as VitestModuleEvaluatorOptions, c as createImportMetaEnvProxy, g as getDefaultRequestStubs, i as isPrimitive, u as unwrapId, w as wrapId } from './chunks/moduleRunner.d.
|
|
2
|
+
export { b as VitestModuleEvaluator, a as VitestModuleEvaluatorOptions, c as createImportMetaEnvProxy, g as getDefaultRequestStubs, i as isPrimitive, u as unwrapId, w as wrapId } from './chunks/moduleRunner.d.CzOZ_4wC.js';
|
|
3
3
|
import 'node:vm';
|
|
4
4
|
import '@vitest/spy';
|
|
5
|
-
import './chunks/worker.d.
|
|
5
|
+
import './chunks/worker.d.DadbA89M.js';
|
|
6
6
|
import '@vitest/runner';
|
|
7
7
|
import './chunks/config.d.BTfZNUu9.js';
|
|
8
8
|
import '@vitest/pretty-format';
|
package/dist/module-evaluator.js
CHANGED
|
@@ -9,12 +9,14 @@ class ModuleDebug {
|
|
|
9
9
|
executionStack = [];
|
|
10
10
|
startCalculateModuleExecutionInfo(filename, startOffset) {
|
|
11
11
|
const startTime = performanceNow();
|
|
12
|
-
|
|
12
|
+
this.executionStack.push({
|
|
13
13
|
filename,
|
|
14
14
|
startTime,
|
|
15
15
|
subImportTime: 0
|
|
16
|
-
})
|
|
17
|
-
|
|
16
|
+
});
|
|
17
|
+
return () => {
|
|
18
|
+
const duration = performanceNow() - startTime;
|
|
19
|
+
const currentExecution = this.executionStack.pop();
|
|
18
20
|
if (currentExecution == null) throw new Error("Execution stack is empty, this should never happen");
|
|
19
21
|
const selfTime = duration - currentExecution.subImportTime;
|
|
20
22
|
if (this.executionStack.length > 0) this.executionStack.at(-1).subImportTime += duration;
|
|
@@ -37,7 +39,10 @@ class VitestModuleEvaluator {
|
|
|
37
39
|
primitives;
|
|
38
40
|
debug = new ModuleDebug();
|
|
39
41
|
constructor(vmOptions, options = {}) {
|
|
40
|
-
|
|
42
|
+
this.options = options;
|
|
43
|
+
this.vm = vmOptions;
|
|
44
|
+
this.stubs = getDefaultRequestStubs(vmOptions?.context);
|
|
45
|
+
if (options.compiledFunctionArgumentsNames) this.compiledFunctionArgumentsNames = options.compiledFunctionArgumentsNames;
|
|
41
46
|
if (options.compiledFunctionArgumentsValues) this.compiledFunctionArgumentsValues = options.compiledFunctionArgumentsValues;
|
|
42
47
|
if (vmOptions) this.primitives = vm.runInContext("({ Object, Proxy, Reflect })", vmOptions.context);
|
|
43
48
|
else this.primitives = {
|
|
@@ -52,19 +57,24 @@ class VitestModuleEvaluator {
|
|
|
52
57
|
// https://github.com/vitejs/vite/pull/20449
|
|
53
58
|
if (!isWindows || isBuiltin(id) || /^(?:node:|data:|http:|https:|file:)/.test(id)) return id;
|
|
54
59
|
const [filepath, query] = id.split("?");
|
|
55
|
-
|
|
60
|
+
if (query) return `${pathToFileURL(filepath).toString()}?${query}`;
|
|
61
|
+
return pathToFileURL(filepath).toString();
|
|
56
62
|
}
|
|
57
63
|
async runExternalModule(id) {
|
|
58
64
|
if (id in this.stubs) return this.stubs[id];
|
|
59
|
-
const file = this.convertIdToImportUrl(id)
|
|
65
|
+
const file = this.convertIdToImportUrl(id);
|
|
66
|
+
const namespace = this.vm ? await this.vm.externalModulesExecutor.import(file) : await import(file);
|
|
60
67
|
if (!this.shouldInterop(file, namespace)) return namespace;
|
|
61
|
-
const { mod, defaultExport } = interopModule(namespace)
|
|
68
|
+
const { mod, defaultExport } = interopModule(namespace);
|
|
69
|
+
const { Proxy, Reflect } = this.primitives;
|
|
62
70
|
return new Proxy(mod, {
|
|
63
71
|
get(mod, prop) {
|
|
64
|
-
|
|
72
|
+
if (prop === "default") return defaultExport;
|
|
73
|
+
return mod[prop] ?? defaultExport?.[prop];
|
|
65
74
|
},
|
|
66
75
|
has(mod, prop) {
|
|
67
|
-
|
|
76
|
+
if (prop === "default") return defaultExport !== void 0;
|
|
77
|
+
return prop in mod || defaultExport && prop in defaultExport;
|
|
68
78
|
},
|
|
69
79
|
getOwnPropertyDescriptor(mod, prop) {
|
|
70
80
|
const descriptor = Reflect.getOwnPropertyDescriptor(mod, prop);
|
|
@@ -79,40 +89,57 @@ class VitestModuleEvaluator {
|
|
|
79
89
|
}
|
|
80
90
|
async runInlinedModule(context, code, module) {
|
|
81
91
|
context.__vite_ssr_import_meta__.env = this.env;
|
|
82
|
-
const { Reflect, Proxy, Object } = this.primitives
|
|
92
|
+
const { Reflect, Proxy, Object } = this.primitives;
|
|
93
|
+
const exportsObject = context[ssrModuleExportsKey];
|
|
94
|
+
const SYMBOL_NOT_DEFINED = Symbol("not defined");
|
|
83
95
|
let moduleExports = SYMBOL_NOT_DEFINED;
|
|
84
96
|
// this proxy is triggered only on exports.{name} and module.exports access
|
|
85
97
|
// inside the module itself. imported module is always "exports"
|
|
86
98
|
const cjsExports = new Proxy(exportsObject, {
|
|
87
99
|
get: (target, p, receiver) => {
|
|
88
|
-
|
|
100
|
+
if (Reflect.has(target, p)) return Reflect.get(target, p, receiver);
|
|
101
|
+
return Reflect.get(Object.prototype, p, receiver);
|
|
89
102
|
},
|
|
90
103
|
getPrototypeOf: () => Object.prototype,
|
|
91
104
|
set: (_, p, value) => {
|
|
92
105
|
// treat "module.exports =" the same as "exports.default =" to not have nested "default.default",
|
|
93
106
|
// so "exports.default" becomes the actual module
|
|
94
|
-
if (p === "default" && this.shouldInterop(module.file, { default: value }) && cjsExports !== value)
|
|
107
|
+
if (p === "default" && this.shouldInterop(module.file, { default: value }) && cjsExports !== value) {
|
|
108
|
+
exportAll(cjsExports, value);
|
|
109
|
+
exportsObject.default = value;
|
|
110
|
+
return true;
|
|
111
|
+
}
|
|
95
112
|
if (!Reflect.has(exportsObject, "default")) exportsObject.default = {};
|
|
96
113
|
// returns undefined, when accessing named exports, if default is not an object
|
|
97
114
|
// but is still present inside hasOwnKeys, this is Node behaviour for CJS
|
|
98
|
-
if (moduleExports !== SYMBOL_NOT_DEFINED && isPrimitive(moduleExports))
|
|
115
|
+
if (moduleExports !== SYMBOL_NOT_DEFINED && isPrimitive(moduleExports)) {
|
|
116
|
+
defineExport(exportsObject, p, () => void 0);
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
99
119
|
if (!isPrimitive(exportsObject.default)) exportsObject.default[p] = value;
|
|
100
120
|
if (p !== "default") defineExport(exportsObject, p, () => value);
|
|
101
121
|
return true;
|
|
102
122
|
}
|
|
103
|
-
})
|
|
123
|
+
});
|
|
124
|
+
const moduleProxy = {
|
|
104
125
|
set exports(value) {
|
|
105
|
-
exportAll(cjsExports, value)
|
|
126
|
+
exportAll(cjsExports, value);
|
|
127
|
+
exportsObject.default = value;
|
|
128
|
+
moduleExports = value;
|
|
106
129
|
},
|
|
107
130
|
get exports() {
|
|
108
131
|
return cjsExports;
|
|
109
132
|
}
|
|
110
|
-
}
|
|
133
|
+
};
|
|
134
|
+
const meta = context[ssrImportMetaKey];
|
|
111
135
|
if (this.options.getCurrentTestFilepath?.() === module.file) {
|
|
112
136
|
const globalNamespace = this.vm?.context || globalThis;
|
|
113
137
|
Object.defineProperty(meta, "vitest", { get: () => globalNamespace.__vitest_index__ });
|
|
114
138
|
}
|
|
115
|
-
const filename = meta.filename
|
|
139
|
+
const filename = meta.filename;
|
|
140
|
+
const dirname = meta.dirname;
|
|
141
|
+
const require = this.createRequire(filename);
|
|
142
|
+
const argumentsList = [
|
|
116
143
|
ssrModuleExportsKey,
|
|
117
144
|
ssrImportMetaKey,
|
|
118
145
|
ssrImportKey,
|
|
@@ -127,19 +154,28 @@ class VitestModuleEvaluator {
|
|
|
127
154
|
];
|
|
128
155
|
if (this.compiledFunctionArgumentsNames) argumentsList.push(...this.compiledFunctionArgumentsNames);
|
|
129
156
|
// add 'use strict' since ESM enables it by default
|
|
130
|
-
const codeDefinition = `'use strict';async (${argumentsList.join(",")})=>{{
|
|
157
|
+
const codeDefinition = `'use strict';async (${argumentsList.join(",")})=>{{`;
|
|
158
|
+
const wrappedCode = `${codeDefinition}${code}\n}}`;
|
|
159
|
+
const options = {
|
|
131
160
|
filename: module.id,
|
|
132
161
|
lineOffset: 0,
|
|
133
162
|
columnOffset: -codeDefinition.length
|
|
134
|
-
}
|
|
163
|
+
};
|
|
164
|
+
const finishModuleExecutionInfo = this.debug.startCalculateModuleExecutionInfo(options.filename, codeDefinition.length);
|
|
135
165
|
try {
|
|
136
|
-
|
|
166
|
+
const initModule = this.vm ? vm.runInContext(wrappedCode, this.vm.context, options) : vm.runInThisContext(wrappedCode, options);
|
|
167
|
+
const dynamicRequest = async (dep, options) => {
|
|
168
|
+
dep = String(dep);
|
|
169
|
+
// TODO: support more edge cases?
|
|
170
|
+
// vite doesn't support dynamic modules by design, but we have to
|
|
171
|
+
if (dep[0] === "#") return context[ssrDynamicImportKey](wrapId(dep), options);
|
|
172
|
+
return context[ssrDynamicImportKey](dep, options);
|
|
173
|
+
};
|
|
174
|
+
await initModule(
|
|
137
175
|
context[ssrModuleExportsKey],
|
|
138
176
|
context[ssrImportMetaKey],
|
|
139
177
|
context[ssrImportKey],
|
|
140
|
-
|
|
141
|
-
return dep = String(dep), dep[0] === "#" ? context[ssrDynamicImportKey](wrapId(dep), options) : context[ssrDynamicImportKey](dep, options);
|
|
142
|
-
},
|
|
178
|
+
dynamicRequest,
|
|
143
179
|
context[ssrExportAllKey],
|
|
144
180
|
// vite 7 support, remove when vite 7+ is supported
|
|
145
181
|
context.__vite_ssr_exportName__ || ((name, getter) => Object.defineProperty(exportsObject, name, {
|
|
@@ -161,12 +197,16 @@ class VitestModuleEvaluator {
|
|
|
161
197
|
}
|
|
162
198
|
}
|
|
163
199
|
createRequire(filename) {
|
|
164
|
-
|
|
200
|
+
// \x00 is a rollup convention for virtual files,
|
|
201
|
+
// it is not allowed in actual file names
|
|
202
|
+
if (filename[0] === "\0" || !isAbsolute(filename)) return () => ({});
|
|
203
|
+
return this.vm ? this.vm.externalModulesExecutor.createRequire(filename) : createRequire(filename);
|
|
165
204
|
}
|
|
166
205
|
shouldInterop(path, mod) {
|
|
206
|
+
if (this.options.interopDefault === false) return false;
|
|
167
207
|
// never interop ESM modules
|
|
168
208
|
// TODO: should also skip for `.js` with `type="module"`
|
|
169
|
-
return
|
|
209
|
+
return !path.endsWith(".mjs") && "default" in mod;
|
|
170
210
|
}
|
|
171
211
|
}
|
|
172
212
|
function createImportMetaEnvProxy() {
|
|
@@ -178,7 +218,9 @@ function createImportMetaEnvProxy() {
|
|
|
178
218
|
];
|
|
179
219
|
return new Proxy(process.env, {
|
|
180
220
|
get(_, key) {
|
|
181
|
-
if (typeof key
|
|
221
|
+
if (typeof key !== "string") return;
|
|
222
|
+
if (booleanKeys.includes(key)) return !!process.env[key];
|
|
223
|
+
return process.env[key];
|
|
182
224
|
},
|
|
183
225
|
set(_, key, value) {
|
|
184
226
|
if (typeof key !== "string") return true;
|
|
@@ -195,8 +237,12 @@ function updateStyle(id, css) {
|
|
|
195
237
|
element.textContent = css;
|
|
196
238
|
return;
|
|
197
239
|
}
|
|
198
|
-
const head = document.querySelector("head")
|
|
199
|
-
style
|
|
240
|
+
const head = document.querySelector("head");
|
|
241
|
+
const style = document.createElement("style");
|
|
242
|
+
style.setAttribute("type", "text/css");
|
|
243
|
+
style.setAttribute("data-vite-dev-id", id);
|
|
244
|
+
style.textContent = css;
|
|
245
|
+
head?.appendChild(style);
|
|
200
246
|
}
|
|
201
247
|
function removeStyle(id) {
|
|
202
248
|
if (typeof document === "undefined") return;
|
|
@@ -232,11 +278,13 @@ function getDefaultRequestStubs(context) {
|
|
|
232
278
|
return { "/@vite/client": clientStub };
|
|
233
279
|
}
|
|
234
280
|
function exportAll(exports, sourceModule) {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
281
|
+
// #1120 when a module exports itself it causes
|
|
282
|
+
// call stack error
|
|
283
|
+
if (exports === sourceModule) return;
|
|
284
|
+
if (isPrimitive(sourceModule) || Array.isArray(sourceModule) || sourceModule instanceof Promise) return;
|
|
285
|
+
for (const key in sourceModule) if (key !== "default" && !(key in exports)) try {
|
|
286
|
+
defineExport(exports, key, () => sourceModule[key]);
|
|
287
|
+
} catch {}
|
|
240
288
|
}
|
|
241
289
|
// keep consistency with Vite on how exports are defined
|
|
242
290
|
function defineExport(exports, key, value) {
|
|
@@ -256,14 +304,16 @@ function interopModule(mod) {
|
|
|
256
304
|
};
|
|
257
305
|
let defaultExport = "default" in mod ? mod.default : mod;
|
|
258
306
|
if (!isPrimitive(defaultExport) && "__esModule" in defaultExport) {
|
|
259
|
-
|
|
307
|
+
mod = defaultExport;
|
|
308
|
+
if ("default" in defaultExport) defaultExport = defaultExport.default;
|
|
260
309
|
}
|
|
261
310
|
return {
|
|
262
311
|
mod,
|
|
263
312
|
defaultExport
|
|
264
313
|
};
|
|
265
314
|
}
|
|
266
|
-
const VALID_ID_PREFIX = `/@id
|
|
315
|
+
const VALID_ID_PREFIX = `/@id/`;
|
|
316
|
+
const NULL_BYTE_PLACEHOLDER = `__x00__`;
|
|
267
317
|
function wrapId(id) {
|
|
268
318
|
return id.startsWith(VALID_ID_PREFIX) ? id : VALID_ID_PREFIX + id.replace("\0", NULL_BYTE_PLACEHOLDER);
|
|
269
319
|
}
|
package/dist/module-runner.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { VitestModuleEvaluator } from './module-evaluator.js';
|
|
2
|
-
export { a as VITEST_VM_CONTEXT_SYMBOL, V as VitestModuleRunner, s as startVitestModuleRunner } from './chunks/startModuleRunner.
|
|
3
|
-
export { g as getWorkerState } from './chunks/utils.
|
|
2
|
+
export { a as VITEST_VM_CONTEXT_SYMBOL, V as VitestModuleRunner, s as startVitestModuleRunner } from './chunks/startModuleRunner.BOmUtLIO.js';
|
|
3
|
+
export { g as getWorkerState } from './chunks/utils.DvEY5TfP.js';
|
|
4
4
|
import 'node:module';
|
|
5
5
|
import 'node:url';
|
|
6
6
|
import 'node:vm';
|
package/dist/node.d.ts
CHANGED
|
@@ -3,23 +3,23 @@ import { InlineConfig, UserConfig as UserConfig$1, Plugin, ResolvedConfig as Res
|
|
|
3
3
|
export { vite as Vite };
|
|
4
4
|
export { esbuildVersion, isCSSRequest, isFileServingAllowed, parseAst, parseAstAsync, rollupVersion, version as viteVersion } from 'vite';
|
|
5
5
|
import { IncomingMessage } from 'node:http';
|
|
6
|
-
import { h as ResolvedConfig, f as UserConfig, i as VitestRunMode, j as VitestOptions, V as Vitest, A as ApiConfig, k as TestSpecification, T as TestProject, P as PoolWorker, l as PoolOptions, m as WorkerRequest, n as TestSequencer, L as Logger } from './chunks/reporters.d.
|
|
7
|
-
export { at as BaseCoverageOptions, Y as BenchmarkUserOptions, Z as BrowserBuiltinProvider, $ as BrowserCommand, a0 as BrowserCommandContext, a1 as BrowserConfigOptions, a2 as BrowserInstanceOption, a3 as BrowserModuleMocker, a4 as BrowserOrchestrator, a5 as BrowserProvider, a6 as BrowserProviderOption, a7 as BrowserScript, a8 as BrowserServerFactory, a9 as BrowserServerOptions, aa as BrowserServerState, ab as BrowserServerStateSession, ai as BuiltinEnvironment, ac as CDPSession, aj as CSSModuleScopeStrategy, au as CoverageIstanbulOptions, av as CoverageOptions, aw as CoverageProvider, ax as CoverageProviderModule, ay as CoverageReporter, c as CoverageV8Options, az as CustomProviderOptions, ak as DepsOptimizationOptions, al as EnvironmentOptions, H as HTMLOptions, I as InlineConfig, t as JUnitOptions, J as JsonOptions, M as ModuleDiagnostic, O as OnServerRestartHandler, o as OnTestsRerunHandler, ad as ParentProjectBrowser, am as Pool, q as PoolRunnerInitializer, r as PoolTask, ae as ProjectBrowser, an as ProjectConfig, b as ReportContext, aB as ReportedHookContext, aC as Reporter, ap as ResolveSnapshotPathHandler, aq as ResolveSnapshotPathHandlerContext, af as ResolvedBrowserOptions, R as ResolvedCoverageOptions, ao as ResolvedProjectConfig, S as SerializedTestProject, u as TaskOptions, v as TestCase, w as TestCollection, x as TestDiagnostic, y as TestModule, z as TestModuleState, B as TestResult, D as TestResultFailed, E as TestResultPassed, F as TestResultSkipped, aD as TestRunEndReason, aA as TestRunResult, X as TestSequencerConstructor, G as TestState, K as TestSuite, N as TestSuiteState, ag as ToMatchScreenshotComparators, ah as ToMatchScreenshotOptions, ar as TypecheckConfig, U as UserWorkspaceConfig, as as VitestEnvironment, p as VitestPackageInstaller, W as WatcherTriggerPattern, s as WorkerResponse, _ as _BrowserNames, Q as experimental_getRunnerTask } from './chunks/reporters.d.
|
|
6
|
+
import { h as ResolvedConfig, f as UserConfig, i as VitestRunMode, j as VitestOptions, V as Vitest, A as ApiConfig, k as TestSpecification, T as TestProject, P as PoolWorker, l as PoolOptions, m as WorkerRequest, n as TestSequencer, L as Logger } from './chunks/reporters.d.Da1D1VbQ.js';
|
|
7
|
+
export { at as BaseCoverageOptions, Y as BenchmarkUserOptions, Z as BrowserBuiltinProvider, $ as BrowserCommand, a0 as BrowserCommandContext, a1 as BrowserConfigOptions, a2 as BrowserInstanceOption, a3 as BrowserModuleMocker, a4 as BrowserOrchestrator, a5 as BrowserProvider, a6 as BrowserProviderOption, a7 as BrowserScript, a8 as BrowserServerFactory, a9 as BrowserServerOptions, aa as BrowserServerState, ab as BrowserServerStateSession, ai as BuiltinEnvironment, ac as CDPSession, aj as CSSModuleScopeStrategy, au as CoverageIstanbulOptions, av as CoverageOptions, aw as CoverageProvider, ax as CoverageProviderModule, ay as CoverageReporter, c as CoverageV8Options, az as CustomProviderOptions, ak as DepsOptimizationOptions, al as EnvironmentOptions, H as HTMLOptions, I as InlineConfig, t as JUnitOptions, J as JsonOptions, M as ModuleDiagnostic, O as OnServerRestartHandler, o as OnTestsRerunHandler, ad as ParentProjectBrowser, am as Pool, q as PoolRunnerInitializer, r as PoolTask, ae as ProjectBrowser, an as ProjectConfig, b as ReportContext, aB as ReportedHookContext, aC as Reporter, ap as ResolveSnapshotPathHandler, aq as ResolveSnapshotPathHandlerContext, af as ResolvedBrowserOptions, R as ResolvedCoverageOptions, ao as ResolvedProjectConfig, S as SerializedTestProject, u as TaskOptions, v as TestCase, w as TestCollection, x as TestDiagnostic, y as TestModule, z as TestModuleState, B as TestResult, D as TestResultFailed, E as TestResultPassed, F as TestResultSkipped, aD as TestRunEndReason, aA as TestRunResult, X as TestSequencerConstructor, G as TestState, K as TestSuite, N as TestSuiteState, ag as ToMatchScreenshotComparators, ah as ToMatchScreenshotOptions, ar as TypecheckConfig, U as UserWorkspaceConfig, as as VitestEnvironment, p as VitestPackageInstaller, W as WatcherTriggerPattern, s as WorkerResponse, _ as _BrowserNames, Q as experimental_getRunnerTask } from './chunks/reporters.d.Da1D1VbQ.js';
|
|
8
8
|
import { Awaitable } from '@vitest/utils';
|
|
9
9
|
export { SerializedError } from '@vitest/utils';
|
|
10
|
-
import { R as RuntimeRPC, C as ContextRPC } from './chunks/worker.d.
|
|
11
|
-
export { T as TestExecutionType } from './chunks/worker.d.
|
|
10
|
+
import { R as RuntimeRPC, C as ContextRPC } from './chunks/worker.d.DadbA89M.js';
|
|
11
|
+
export { T as TestExecutionType } from './chunks/worker.d.DadbA89M.js';
|
|
12
12
|
import { Writable } from 'node:stream';
|
|
13
|
-
export { V as VitestPluginContext } from './chunks/plugin.d.
|
|
13
|
+
export { V as VitestPluginContext } from './chunks/plugin.d.D4RrtywJ.js';
|
|
14
14
|
import { Debugger } from 'debug';
|
|
15
|
-
import './chunks/global.d.
|
|
15
|
+
import './chunks/global.d.DVdCfKp5.js';
|
|
16
16
|
export { Task as RunnerTask, TaskResult as RunnerTaskResult, TaskResultPack as RunnerTaskResultPack, Test as RunnerTestCase, File as RunnerTestFile, Suite as RunnerTestSuite, SequenceHooks, SequenceSetupFiles } from '@vitest/runner';
|
|
17
17
|
export { b as RuntimeConfig } from './chunks/config.d.BTfZNUu9.js';
|
|
18
18
|
export { generateFileHash } from '@vitest/runner/utils';
|
|
19
19
|
import '@vitest/mocker';
|
|
20
20
|
import '@vitest/utils/source-map';
|
|
21
21
|
import 'vitest/browser';
|
|
22
|
-
import './chunks/browser.d.
|
|
22
|
+
import './chunks/browser.d.DTTM2PTh.js';
|
|
23
23
|
import '@vitest/pretty-format';
|
|
24
24
|
import '@vitest/snapshot';
|
|
25
25
|
import '@vitest/utils/diff';
|
package/dist/node.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as vite from 'vite';
|
|
2
2
|
import { resolveConfig as resolveConfig$1, mergeConfig } from 'vite';
|
|
3
3
|
export { esbuildVersion, isCSSRequest, isFileServingAllowed, parseAst, parseAstAsync, rollupVersion, version as viteVersion } from 'vite';
|
|
4
|
-
import { V as Vitest, a as VitestPlugin } from './chunks/cli-api.
|
|
5
|
-
export { f as ForksPoolWorker, G as GitNotFoundError, F as TestsNotFoundError, T as ThreadsPoolWorker, h as TypecheckPoolWorker, b as VitestPackageInstaller, j as VmForksPoolWorker, k as VmThreadsPoolWorker, o as createDebugger, d as createMethodsRPC, n as createViteLogger, c as createVitest, e as escapeTestName, l as experimental_getRunnerTask, g as getFilePoolName, i as isValidApiRequest, m as registerConsoleShortcuts, r as resolveFsAllow, s as startVitest } from './chunks/cli-api.
|
|
6
|
-
export { p as parseCLI } from './chunks/cac.
|
|
7
|
-
import { r as resolveConfig$2 } from './chunks/coverage.
|
|
8
|
-
export { b as BaseSequencer, a as resolveApiServerConfig } from './chunks/coverage.
|
|
4
|
+
import { V as Vitest, a as VitestPlugin } from './chunks/cli-api.BQ-bjcRi.js';
|
|
5
|
+
export { f as ForksPoolWorker, G as GitNotFoundError, F as TestsNotFoundError, T as ThreadsPoolWorker, h as TypecheckPoolWorker, b as VitestPackageInstaller, j as VmForksPoolWorker, k as VmThreadsPoolWorker, o as createDebugger, d as createMethodsRPC, n as createViteLogger, c as createVitest, e as escapeTestName, l as experimental_getRunnerTask, g as getFilePoolName, i as isValidApiRequest, m as registerConsoleShortcuts, r as resolveFsAllow, s as startVitest } from './chunks/cli-api.BQ-bjcRi.js';
|
|
6
|
+
export { p as parseCLI } from './chunks/cac.CfkWq8Qy.js';
|
|
7
|
+
import { r as resolveConfig$2 } from './chunks/coverage.NVjCOln1.js';
|
|
8
|
+
export { b as BaseSequencer, a as resolveApiServerConfig } from './chunks/coverage.NVjCOln1.js';
|
|
9
9
|
import { slash, deepClone } from '@vitest/utils/helpers';
|
|
10
10
|
import { a as any } from './chunks/index.Dc3xnDvT.js';
|
|
11
11
|
import { resolve } from 'pathe';
|
|
@@ -17,8 +17,8 @@ import './chunks/coverage.D_JHT54q.js';
|
|
|
17
17
|
import 'node:path';
|
|
18
18
|
import 'node:os';
|
|
19
19
|
import '@vitest/snapshot/manager';
|
|
20
|
-
import './chunks/index.
|
|
21
|
-
import './chunks/index.
|
|
20
|
+
import './chunks/index.DAL392Ss.js';
|
|
21
|
+
import './chunks/index.kotH7DY7.js';
|
|
22
22
|
import 'node:fs/promises';
|
|
23
23
|
import 'node:perf_hooks';
|
|
24
24
|
import '@vitest/utils/source-map';
|
|
@@ -62,7 +62,7 @@ import './chunks/defaults.BOqNVLsY.js';
|
|
|
62
62
|
import '@vitest/utils/constants';
|
|
63
63
|
import '@vitest/utils/resolver';
|
|
64
64
|
import 'es-module-lexer';
|
|
65
|
-
import './chunks/index.
|
|
65
|
+
import './chunks/index.op2Re5rn.js';
|
|
66
66
|
import 'node:assert';
|
|
67
67
|
import '@vitest/utils/serialize';
|
|
68
68
|
import 'node:readline';
|
|
@@ -71,14 +71,18 @@ import 'readline';
|
|
|
71
71
|
|
|
72
72
|
// this is only exported as a public function and not used inside vitest
|
|
73
73
|
async function resolveConfig(options = {}, viteOverrides = {}) {
|
|
74
|
-
const root = slash(resolve(options.root || process.cwd()))
|
|
74
|
+
const root = slash(resolve(options.root || process.cwd()));
|
|
75
|
+
const configPath = options.config === false ? false : options.config ? resolve(root, options.config) : any(configFiles, { cwd: root });
|
|
75
76
|
options.config = configPath;
|
|
76
|
-
const vitest = new Vitest("test", deepClone(options))
|
|
77
|
+
const vitest = new Vitest("test", deepClone(options));
|
|
78
|
+
const config = await resolveConfig$1(mergeConfig({
|
|
77
79
|
configFile: configPath,
|
|
78
80
|
mode: options.mode || "test",
|
|
79
81
|
plugins: [await VitestPlugin(options, vitest)]
|
|
80
|
-
}, mergeConfig(viteOverrides, { root: options.root })), "serve")
|
|
81
|
-
|
|
82
|
+
}, mergeConfig(viteOverrides, { root: options.root })), "serve");
|
|
83
|
+
const vitestConfig = resolveConfig$2(vitest, Reflect.get(config, "_vitest"), config);
|
|
84
|
+
await vitest.close();
|
|
85
|
+
return {
|
|
82
86
|
viteConfig: config,
|
|
83
87
|
vitestConfig
|
|
84
88
|
};
|
package/dist/reporters.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { aR as BaseReporter, aS as BenchmarkBuiltinReporters, aE as BenchmarkReporter, aF as BenchmarkReportsMap, aT as BuiltinReporterOptions, aU as BuiltinReporters, aG as DefaultReporter, aH as DotReporter, aI as GithubActionsReporter, aJ as HangingProcessReporter, aL as JUnitReporter, aV as JsonAssertionResult, aK as JsonReporter, aW as JsonTestResult, aX as JsonTestResults, aB as ReportedHookContext, aC as Reporter, aM as ReportersMap, aN as TapFlatReporter, aO as TapReporter, aD as TestRunEndReason, aP as VerboseBenchmarkReporter, aQ as VerboseReporter } from './chunks/reporters.d.
|
|
1
|
+
export { aR as BaseReporter, aS as BenchmarkBuiltinReporters, aE as BenchmarkReporter, aF as BenchmarkReportsMap, aT as BuiltinReporterOptions, aU as BuiltinReporters, aG as DefaultReporter, aH as DotReporter, aI as GithubActionsReporter, aJ as HangingProcessReporter, aL as JUnitReporter, aV as JsonAssertionResult, aK as JsonReporter, aW as JsonTestResult, aX as JsonTestResults, aB as ReportedHookContext, aC as Reporter, aM as ReportersMap, aN as TapFlatReporter, aO as TapReporter, aD as TestRunEndReason, aP as VerboseBenchmarkReporter, aQ as VerboseReporter } from './chunks/reporters.d.Da1D1VbQ.js';
|
|
2
2
|
import '@vitest/runner';
|
|
3
3
|
import '@vitest/utils';
|
|
4
|
-
import './chunks/worker.d.
|
|
4
|
+
import './chunks/worker.d.DadbA89M.js';
|
|
5
5
|
import 'vite/module-runner';
|
|
6
6
|
import './chunks/config.d.BTfZNUu9.js';
|
|
7
7
|
import '@vitest/pretty-format';
|
|
@@ -13,7 +13,7 @@ import 'vite';
|
|
|
13
13
|
import '@vitest/mocker';
|
|
14
14
|
import '@vitest/utils/source-map';
|
|
15
15
|
import 'vitest/browser';
|
|
16
|
-
import './chunks/browser.d.
|
|
16
|
+
import './chunks/browser.d.DTTM2PTh.js';
|
|
17
17
|
import '@vitest/expect';
|
|
18
18
|
import 'vitest/optional-types.js';
|
|
19
19
|
import './chunks/benchmark.d.DAaHLpsq.js';
|
package/dist/reporters.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { D as DefaultReporter, a as DotReporter, G as GithubActionsReporter, H as HangingProcessReporter, b as JUnitReporter, J as JsonReporter, R as ReportersMap, T as TapFlatReporter, c as TapReporter, V as VerboseReporter } from './chunks/index.
|
|
2
|
-
export { B as BenchmarkReporter, a as BenchmarkReportsMap, V as VerboseBenchmarkReporter } from './chunks/index.
|
|
1
|
+
export { D as DefaultReporter, a as DotReporter, G as GithubActionsReporter, H as HangingProcessReporter, b as JUnitReporter, J as JsonReporter, R as ReportersMap, T as TapFlatReporter, c as TapReporter, V as VerboseReporter } from './chunks/index.kotH7DY7.js';
|
|
2
|
+
export { B as BenchmarkReporter, a as BenchmarkReportsMap, V as VerboseBenchmarkReporter } from './chunks/index.op2Re5rn.js';
|
|
3
3
|
import 'node:fs';
|
|
4
4
|
import 'node:fs/promises';
|
|
5
5
|
import 'pathe';
|