vitest 4.0.0-beta.4 → 4.0.0-beta.5
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/dist/browser.d.ts +8 -9
- package/dist/browser.js +3 -2
- package/dist/chunks/base.DMfOuRWD.js +48 -0
- package/dist/chunks/{benchmark.CYdenmiT.js → benchmark.CtuRzf-i.js} +4 -1
- package/dist/chunks/{browser.d.BRP8scJf.d.ts → browser.d.Cawq_X_N.d.ts} +1 -1
- package/dist/chunks/{cac.CY0IAxC4.js → cac.CKnbxhn2.js} +8 -9
- package/dist/chunks/{cli-api.B8xRY9Zt.js → cli-api.COn58yrl.js} +540 -342
- package/dist/chunks/{config.d.DZo8c7fw.d.ts → config.d.CKNVOKm0.d.ts} +3 -8
- package/dist/chunks/{console.DoJHFxmj.js → console.Duv2dVIC.js} +1 -1
- package/dist/chunks/{constants.CXzqaLmq.js → constants.D_Q9UYh-.js} +1 -6
- package/dist/chunks/{coverage.C84l9G-M.js → coverage.B6cReEn1.js} +232 -133
- package/dist/chunks/{coverage.DVF1vEu8.js → coverage.D_JHT54q.js} +2 -2
- package/dist/chunks/{coverage.d.CNYjU4GF.d.ts → coverage.d.BZtK59WP.d.ts} +7 -5
- package/dist/chunks/{creator.yfA2ExGt.js → creator.DUVZ6rfm.js} +1 -1
- package/dist/chunks/{environment.d.Bhm9oc0v.d.ts → environment.d.2fYMoz3o.d.ts} +26 -4
- package/dist/chunks/{global.d.DAhT2emn.d.ts → global.d.K6uBQHzY.d.ts} +1 -1
- package/dist/chunks/{globals.Dgo-vS5G.js → globals.CJQ63oO0.js} +6 -5
- package/dist/chunks/{index.CmSc2RE5.js → index.BRtIe7r8.js} +4 -4
- package/dist/chunks/{index.Bz6b0Ib7.js → index.DQhAfQQU.js} +12 -4
- package/dist/chunks/{index.D3SKT3tv.js → index.DgN0Zk9a.js} +1 -1
- package/dist/chunks/{index.D1_MsKEt.js → index.QZr3S3vQ.js} +4 -2
- package/dist/chunks/{index.CtUvr1c8.js → index.oWRWx-nj.js} +18 -18
- package/dist/chunks/moduleRunner.d.mmOmOGrW.d.ts +202 -0
- package/dist/chunks/moduleTransport.I-bgQy0S.js +19 -0
- package/dist/chunks/{node.fjCdwEIl.js → node.4JV5OXkt.js} +1 -1
- package/dist/chunks/{plugin.d.CLhMcYdD.d.ts → plugin.d.CvOlgjxK.d.ts} +1 -1
- package/dist/chunks/{reporters.d.DWg40D2B.d.ts → reporters.d.CYE9sT5z.d.ts} +37 -69
- package/dist/chunks/resolver.D5bG4zy5.js +162 -0
- package/dist/chunks/{rpc.jnQO9F8a.js → rpc.DGoW_Vl-.js} +1 -1
- package/dist/chunks/{runBaseTests.DBVVLMSb.js → runBaseTests.B3KcKqlF.js} +22 -23
- package/dist/chunks/{setup-common.Ebx5x0eP.js → setup-common.lgPs-bYv.js} +11 -10
- package/dist/chunks/{execute.Dt-pCVcL.js → startModuleRunner.C8FtT_BY.js} +381 -312
- package/dist/chunks/{typechecker.CMNPqJOo.js → typechecker.BgoW4nTA.js} +1 -1
- package/dist/chunks/{utils.XdZDrNZV.js → utils.B9FY3b73.js} +7 -8
- package/dist/chunks/{vi.CA0EPI9Y.js → vi.DGAfBY4R.js} +12 -8
- package/dist/chunks/{vm.BUnLJt_P.js → vm.BKfKvaKl.js} +36 -56
- package/dist/chunks/{worker.d.zjyR34Pb.d.ts → worker.d.D9QWnzAe.d.ts} +16 -13
- package/dist/chunks/{worker.d.C-1AbnVe.d.ts → worker.d.Db-UVmXc.d.ts} +1 -1
- package/dist/cli.js +4 -4
- package/dist/config.cjs +3 -9
- package/dist/config.d.ts +10 -12
- package/dist/config.js +1 -1
- package/dist/coverage.d.ts +10 -11
- package/dist/coverage.js +5 -6
- package/dist/environments.d.ts +2 -2
- package/dist/environments.js +1 -1
- package/dist/index.d.ts +10 -9
- package/dist/index.js +5 -4
- package/dist/module-evaluator.d.ts +12 -0
- package/dist/module-evaluator.js +327 -0
- package/dist/module-runner.js +15 -0
- package/dist/node.d.ts +12 -13
- package/dist/node.js +15 -14
- package/dist/reporters.d.ts +7 -8
- package/dist/reporters.js +3 -3
- package/dist/runners.d.ts +3 -3
- package/dist/runners.js +16 -10
- package/dist/snapshot.js +2 -2
- package/dist/suite.js +2 -2
- package/dist/worker.js +84 -31
- package/dist/workers/forks.js +10 -9
- package/dist/workers/runVmTests.js +16 -17
- package/dist/workers/threads.js +10 -9
- package/dist/workers/vmForks.js +9 -8
- package/dist/workers/vmThreads.js +9 -8
- package/dist/workers.d.ts +5 -4
- package/dist/workers.js +14 -13
- package/package.json +21 -16
- package/dist/chunks/base.BaCDDRPG.js +0 -38
- package/dist/execute.d.ts +0 -148
- package/dist/execute.js +0 -13
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
import { Task, CancelReason, TaskMeta, Suite, File, TestAnnotation, ImportDuration, TaskResultPack, TaskEventPack, SequenceSetupFiles, SequenceHooks } from '@vitest/runner';
|
|
2
|
-
import { P as ProvidedContext, U as UserConsoleLog, b as Awaitable$1, c as Arrayable$1, A as AfterSuiteRunMeta, L as LabelColor } from './environment.d.
|
|
2
|
+
import { P as ProvidedContext, U as UserConsoleLog, b as Awaitable$1, c as Arrayable$1, A as AfterSuiteRunMeta, L as LabelColor } from './environment.d.2fYMoz3o.js';
|
|
3
3
|
import { ParsedStack, Awaitable, TestError, SerializedError, Arrayable } from '@vitest/utils';
|
|
4
4
|
import { Writable } from 'node:stream';
|
|
5
5
|
import { ViteDevServer, ModuleNode, TransformResult as TransformResult$1, DepOptimizationConfig, ServerOptions, UserConfig as UserConfig$1, ConfigEnv, AliasOptions } from 'vite';
|
|
6
6
|
import { Console } from 'node:console';
|
|
7
|
-
import { B as BrowserTesterOptions, S as SerializedTestSpecification } from './browser.d.
|
|
7
|
+
import { B as BrowserTesterOptions, S as SerializedTestSpecification } from './browser.d.Cawq_X_N.js';
|
|
8
8
|
import { MockedModule } from '@vitest/mocker';
|
|
9
9
|
import { StackTraceParserOptions } from '@vitest/utils/source-map';
|
|
10
|
-
import { a as SerializedConfig, F as FakeTimerInstallOpts } from './config.d.
|
|
10
|
+
import { a as SerializedConfig, F as FakeTimerInstallOpts } from './config.d.CKNVOKm0.js';
|
|
11
11
|
import { PrettyFormatOptions } from '@vitest/pretty-format';
|
|
12
12
|
import { SnapshotSummary, SnapshotStateOptions } from '@vitest/snapshot';
|
|
13
13
|
import { SerializedDiffOptions } from '@vitest/utils/diff';
|
|
14
|
-
import { ViteNodeServerOptions } from 'vite-node';
|
|
15
14
|
import * as chai from 'chai';
|
|
16
15
|
import { happyDomTypes, jsdomTypes } from 'vitest/optional-types.js';
|
|
17
16
|
import { B as BenchmarkResult } from './benchmark.d.DAaHLpsq.js';
|
|
18
|
-
import { a as RuntimeCoverageProviderModule } from './coverage.d.
|
|
17
|
+
import { a as RuntimeCoverageProviderModule } from './coverage.d.BZtK59WP.js';
|
|
19
18
|
import { SnapshotManager } from '@vitest/snapshot/manager';
|
|
20
19
|
import { Stats } from 'node:fs';
|
|
21
20
|
|
|
@@ -152,7 +151,7 @@ interface BrowserProviderModule {
|
|
|
152
151
|
}
|
|
153
152
|
interface BrowserProviderOptions {}
|
|
154
153
|
type BrowserBuiltinProvider = "webdriverio" | "playwright" | "preview";
|
|
155
|
-
type UnsupportedProperties = "browser" | "typecheck" | "alias" | "sequence" | "root" | "pool" | "poolOptions" | "runner" | "api" | "deps" | "
|
|
154
|
+
type UnsupportedProperties = "browser" | "typecheck" | "alias" | "sequence" | "root" | "pool" | "poolOptions" | "runner" | "api" | "deps" | "environment" | "environmentOptions" | "server" | "benchmark" | "name";
|
|
156
155
|
interface BrowserInstanceOption extends BrowserProviderOptions, Omit<ProjectConfig, UnsupportedProperties>, Pick<BrowserConfigOptions, "headless" | "locators" | "viewport" | "testerHtmlPath" | "screenshotDirectory" | "screenshotFailures"> {
|
|
157
156
|
/**
|
|
158
157
|
* Name of the browser
|
|
@@ -1194,6 +1193,7 @@ declare class StateManager {
|
|
|
1194
1193
|
processTimeoutCauses: Set<string>;
|
|
1195
1194
|
reportedTasksMap: WeakMap<Task, TestModule | TestCase | TestSuite>;
|
|
1196
1195
|
blobs?: MergedBlobs;
|
|
1196
|
+
transformTime: number;
|
|
1197
1197
|
onUnhandledError?: OnUnhandledErrorCallback;
|
|
1198
1198
|
constructor(options: {
|
|
1199
1199
|
onUnhandledError?: OnUnhandledErrorCallback;
|
|
@@ -2413,31 +2413,11 @@ interface SequenceOptions {
|
|
|
2413
2413
|
type DepsOptimizationOptions = Omit<DepOptimizationConfig, "disabled" | "noDiscovery"> & {
|
|
2414
2414
|
enabled?: boolean;
|
|
2415
2415
|
};
|
|
2416
|
-
interface TransformModePatterns {
|
|
2417
|
-
/**
|
|
2418
|
-
* Use SSR transform pipeline for all modules inside specified tests.
|
|
2419
|
-
* Vite plugins will receive `ssr: true` flag when processing those files.
|
|
2420
|
-
*
|
|
2421
|
-
* @default tests with node or edge environment
|
|
2422
|
-
*/
|
|
2423
|
-
ssr?: string[];
|
|
2424
|
-
/**
|
|
2425
|
-
* First do a normal transform pipeline (targeting browser),
|
|
2426
|
-
* then then do a SSR rewrite to run the code in Node.
|
|
2427
|
-
* Vite plugins will receive `ssr: false` flag when processing those files.
|
|
2428
|
-
*
|
|
2429
|
-
* @default tests with jsdom or happy-dom environment
|
|
2430
|
-
*/
|
|
2431
|
-
web?: string[];
|
|
2432
|
-
}
|
|
2433
2416
|
interface DepsOptions {
|
|
2434
2417
|
/**
|
|
2435
2418
|
* Enable dependency optimization. This can improve the performance of your tests.
|
|
2436
2419
|
*/
|
|
2437
|
-
optimizer?: {
|
|
2438
|
-
web?: DepsOptimizationOptions;
|
|
2439
|
-
ssr?: DepsOptimizationOptions;
|
|
2440
|
-
};
|
|
2420
|
+
optimizer?: Partial<Record<"client" | "ssr" | ({} & string), DepsOptimizationOptions>>;
|
|
2441
2421
|
web?: {
|
|
2442
2422
|
/**
|
|
2443
2423
|
* Should Vitest process assets (.png, .svg, .jpg, etc) files and resolve them like Vite does in the browser.
|
|
@@ -2471,43 +2451,12 @@ interface DepsOptions {
|
|
|
2471
2451
|
transformGlobPattern?: RegExp | RegExp[];
|
|
2472
2452
|
};
|
|
2473
2453
|
/**
|
|
2474
|
-
* Externalize means that Vite will bypass the package to native Node.
|
|
2475
|
-
*
|
|
2476
|
-
* Externalized dependencies will not be applied Vite's transformers and resolvers.
|
|
2477
|
-
* And does not support HMR on reload.
|
|
2478
|
-
*
|
|
2479
|
-
* Typically, packages under `node_modules` are externalized.
|
|
2480
|
-
*
|
|
2481
|
-
* @deprecated If you rely on vite-node directly, use `server.deps.external` instead. Otherwise, consider using `deps.optimizer.{web,ssr}.exclude`.
|
|
2482
|
-
*/
|
|
2483
|
-
external?: (string | RegExp)[];
|
|
2484
|
-
/**
|
|
2485
|
-
* Vite will process inlined modules.
|
|
2486
|
-
*
|
|
2487
|
-
* This could be helpful to handle packages that ship `.js` in ESM format (that Node can't handle).
|
|
2488
|
-
*
|
|
2489
|
-
* If `true`, every dependency will be inlined
|
|
2490
|
-
*
|
|
2491
|
-
* @deprecated If you rely on vite-node directly, use `server.deps.inline` instead. Otherwise, consider using `deps.optimizer.{web,ssr}.include`.
|
|
2492
|
-
*/
|
|
2493
|
-
inline?: (string | RegExp)[] | true;
|
|
2494
|
-
/**
|
|
2495
2454
|
* Interpret CJS module's default as named exports
|
|
2496
2455
|
*
|
|
2497
2456
|
* @default true
|
|
2498
2457
|
*/
|
|
2499
2458
|
interopDefault?: boolean;
|
|
2500
2459
|
/**
|
|
2501
|
-
* When a dependency is a valid ESM package, try to guess the cjs version based on the path.
|
|
2502
|
-
* This will significantly improve the performance in huge repo, but might potentially
|
|
2503
|
-
* cause some misalignment if a package have different logic in ESM and CJS mode.
|
|
2504
|
-
*
|
|
2505
|
-
* @default false
|
|
2506
|
-
*
|
|
2507
|
-
* @deprecated Use `server.deps.fallbackCJS` instead.
|
|
2508
|
-
*/
|
|
2509
|
-
fallbackCJS?: boolean;
|
|
2510
|
-
/**
|
|
2511
2460
|
* A list of directories relative to the config file that should be treated as module directories.
|
|
2512
2461
|
*
|
|
2513
2462
|
* @default ['node_modules']
|
|
@@ -2554,10 +2503,9 @@ interface InlineConfig {
|
|
|
2554
2503
|
*
|
|
2555
2504
|
*/
|
|
2556
2505
|
deps?: DepsOptions;
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
server?: Omit<ViteNodeServerOptions, "transformMode">;
|
|
2506
|
+
server?: {
|
|
2507
|
+
deps?: ServerDepsOptions;
|
|
2508
|
+
};
|
|
2561
2509
|
/**
|
|
2562
2510
|
* Base directory to scan for the test files
|
|
2563
2511
|
*
|
|
@@ -2694,7 +2642,7 @@ interface InlineConfig {
|
|
|
2694
2642
|
*/
|
|
2695
2643
|
globalSetup?: string | string[];
|
|
2696
2644
|
/**
|
|
2697
|
-
* Glob
|
|
2645
|
+
* Glob pattern of file paths that will trigger the whole suite rerun
|
|
2698
2646
|
*
|
|
2699
2647
|
* Useful if you are testing calling CLI commands
|
|
2700
2648
|
*
|
|
@@ -2773,10 +2721,6 @@ interface InlineConfig {
|
|
|
2773
2721
|
*/
|
|
2774
2722
|
uiBase?: string;
|
|
2775
2723
|
/**
|
|
2776
|
-
* Determine the transform method for all modules imported inside a test that matches the glob pattern.
|
|
2777
|
-
*/
|
|
2778
|
-
testTransformMode?: TransformModePatterns;
|
|
2779
|
-
/**
|
|
2780
2724
|
* Format options for snapshot testing.
|
|
2781
2725
|
*/
|
|
2782
2726
|
snapshotFormat?: Omit<PrettyFormatOptions, "plugins" | "compareKeys"> & {
|
|
@@ -3194,6 +3138,30 @@ interface ResolvedConfig extends Omit<Required<UserConfig>, "project" | "config"
|
|
|
3194
3138
|
minWorkers: number;
|
|
3195
3139
|
}
|
|
3196
3140
|
type NonProjectOptions = "shard" | "watch" | "run" | "cache" | "update" | "reporters" | "outputFile" | "teardownTimeout" | "silent" | "forceRerunTriggers" | "testNamePattern" | "ui" | "open" | "uiBase" | "snapshotFormat" | "resolveSnapshotPath" | "passWithNoTests" | "onConsoleLog" | "onStackTrace" | "dangerouslyIgnoreUnhandledErrors" | "slowTestThreshold" | "inspect" | "inspectBrk" | "coverage" | "maxWorkers" | "minWorkers" | "fileParallelism" | "watchTriggerPatterns";
|
|
3141
|
+
interface ServerDepsOptions {
|
|
3142
|
+
/**
|
|
3143
|
+
* Externalize means that Vite will bpass the package to native Node.
|
|
3144
|
+
*
|
|
3145
|
+
* Externalized dependencies will not be applied Vite's transformers and resolvers.
|
|
3146
|
+
* And does not support HMR on reload.
|
|
3147
|
+
*
|
|
3148
|
+
* Typically, packages under `node_modules` are externalized.
|
|
3149
|
+
*/
|
|
3150
|
+
external?: (string | RegExp)[];
|
|
3151
|
+
/**
|
|
3152
|
+
* Vite will process inlined modules.
|
|
3153
|
+
*
|
|
3154
|
+
* This could be helpful to handle packages that ship `.js` in ESM format (that Node can't handle).
|
|
3155
|
+
*
|
|
3156
|
+
* If `true`, every dependency will be inlined
|
|
3157
|
+
*/
|
|
3158
|
+
inline?: (string | RegExp)[] | true;
|
|
3159
|
+
/**
|
|
3160
|
+
* Try to guess the CJS version of a package when it's invalid ESM
|
|
3161
|
+
* @default false
|
|
3162
|
+
*/
|
|
3163
|
+
fallbackCJS?: boolean;
|
|
3164
|
+
}
|
|
3197
3165
|
type ProjectConfig = Omit<InlineConfig, NonProjectOptions | "sequencer" | "deps" | "poolOptions"> & {
|
|
3198
3166
|
mode?: string;
|
|
3199
3167
|
sequencer?: Omit<SequenceOptions, "sequencer" | "seed">;
|
|
@@ -3221,5 +3189,5 @@ type TestProjectInlineConfiguration = (UserWorkspaceConfig & {
|
|
|
3221
3189
|
});
|
|
3222
3190
|
type TestProjectConfiguration = string | TestProjectInlineConfiguration | Promise<UserWorkspaceConfig> | UserProjectConfigFn;
|
|
3223
3191
|
|
|
3224
|
-
export { CoverageMap as C, TestSuite as E, Logger as L, TestProject as T, Vitest as V, BenchmarkReporter as
|
|
3225
|
-
export type { BrowserOrchestrator as $, ApiConfig as A, TestResultSkipped as B, TestState as D, TestSuiteState as F, TestSequencerConstructor as G, HTMLOptions as H, InlineConfig as I, JsonOptions$1 as J, BenchmarkUserOptions as K, ModuleDiagnostic as M, BrowserBuiltinProvider as N, OnServerRestartHandler as O, ProcessPool as P, BrowserCommand as Q, ResolvedCoverageOptions as R, SerializedTestProject as S, UserWorkspaceConfig as U, WatcherTriggerPattern as W, BrowserCommandContext as X, BrowserConfigOptions as Y, BrowserInstanceOption as Z, BrowserModuleMocker as _, TestProjectConfiguration as a, BrowserProvider as a0, BrowserProviderInitializationOptions as a1, BrowserProviderModule as a2, BrowserProviderOptions as a3, BrowserScript as a4, BrowserServerState as a5, BrowserServerStateSession as a6, CDPSession as a7, ParentProjectBrowser as a8, ProjectBrowser as a9,
|
|
3192
|
+
export { CoverageMap as C, TestSuite as E, Logger as L, TestProject as T, Vitest as V, BenchmarkReporter as aA, BenchmarkReportsMap as aB, DefaultReporter as aC, DotReporter as aD, GithubActionsReporter as aE, HangingProcessReporter as aF, JsonReporter as aG, JUnitReporter as aH, ReportersMap as aI, TapFlatReporter as aJ, TapReporter as aK, VerboseBenchmarkReporter as aL, VerboseReporter as aM, BaseReporter as aN, TestSpecification as l, VitestPackageInstaller as n, getFilePoolName as p, TestCase as s, TestCollection as t, TestModule as v };
|
|
3193
|
+
export type { BrowserOrchestrator as $, ApiConfig as A, TestResultSkipped as B, TestState as D, TestSuiteState as F, TestSequencerConstructor as G, HTMLOptions as H, InlineConfig as I, JsonOptions$1 as J, BenchmarkUserOptions as K, ModuleDiagnostic as M, BrowserBuiltinProvider as N, OnServerRestartHandler as O, ProcessPool as P, BrowserCommand as Q, ResolvedCoverageOptions as R, SerializedTestProject as S, UserWorkspaceConfig as U, WatcherTriggerPattern as W, BrowserCommandContext as X, BrowserConfigOptions as Y, BrowserInstanceOption as Z, BrowserModuleMocker as _, TestProjectConfiguration as a, BrowserProvider as a0, BrowserProviderInitializationOptions as a1, BrowserProviderModule as a2, BrowserProviderOptions as a3, BrowserScript as a4, BrowserServerState as a5, BrowserServerStateSession as a6, CDPSession as a7, ParentProjectBrowser as a8, ProjectBrowser as a9, BenchmarkBuiltinReporters as aO, BuiltinReporterOptions as aP, BuiltinReporters as aQ, JsonAssertionResult as aR, JsonTestResult as aS, JsonTestResults as aT, ResolvedBrowserOptions as aa, ToMatchScreenshotComparators as ab, ToMatchScreenshotOptions as ac, BuiltinEnvironment as ad, CSSModuleScopeStrategy as ae, DepsOptimizationOptions as af, EnvironmentOptions as ag, Pool as ah, PoolOptions as ai, ProjectConfig as aj, ResolvedProjectConfig as ak, ResolveSnapshotPathHandler as al, ResolveSnapshotPathHandlerContext as am, TypecheckConfig as an, VitestEnvironment as ao, BaseCoverageOptions as ap, CoverageIstanbulOptions as aq, CoverageOptions as ar, CoverageProvider as as, CoverageProviderModule as at, CoverageReporter as au, CustomProviderOptions as av, TestRunResult as aw, ReportedHookContext as ax, Reporter as ay, TestRunEndReason as az, ReportContext as b, CoverageV8Options as c, UserProjectConfigFn as d, UserProjectConfigExport as e, UserConfig as f, TestProjectInlineConfiguration as g, ResolvedConfig as h, VitestRunMode as i, VitestOptions as j, TestSequencer as k, OnTestsRerunHandler as m, WorkspaceSpec as o, JUnitOptions as q, TaskOptions as r, TestDiagnostic as u, TestModuleState as w, TestResult as x, TestResultFailed as y, TestResultPassed as z };
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
|
|
3
|
+
const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
4
|
+
function normalizeWindowsPath(input = "") {
|
|
5
|
+
if (!input) return input;
|
|
6
|
+
return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
|
|
7
|
+
}
|
|
8
|
+
const _UNC_REGEX = /^[/\\]{2}/;
|
|
9
|
+
const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
|
|
10
|
+
const _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
|
|
11
|
+
const normalize = function(path) {
|
|
12
|
+
if (path.length === 0) return ".";
|
|
13
|
+
path = normalizeWindowsPath(path);
|
|
14
|
+
const isUNCPath = path.match(_UNC_REGEX);
|
|
15
|
+
const isPathAbsolute = isAbsolute(path);
|
|
16
|
+
const trailingSeparator = path[path.length - 1] === "/";
|
|
17
|
+
path = normalizeString(path, !isPathAbsolute);
|
|
18
|
+
if (path.length === 0) {
|
|
19
|
+
if (isPathAbsolute) return "/";
|
|
20
|
+
return trailingSeparator ? "./" : ".";
|
|
21
|
+
}
|
|
22
|
+
if (trailingSeparator) path += "/";
|
|
23
|
+
if (_DRIVE_LETTER_RE.test(path)) path += "/";
|
|
24
|
+
if (isUNCPath) {
|
|
25
|
+
if (!isPathAbsolute) return `//./${path}`;
|
|
26
|
+
return `//${path}`;
|
|
27
|
+
}
|
|
28
|
+
return isPathAbsolute && !isAbsolute(path) ? `/${path}` : path;
|
|
29
|
+
};
|
|
30
|
+
const join = function(...segments) {
|
|
31
|
+
let path = "";
|
|
32
|
+
for (const seg of segments) {
|
|
33
|
+
if (!seg) continue;
|
|
34
|
+
if (path.length > 0) {
|
|
35
|
+
const pathTrailing = path[path.length - 1] === "/";
|
|
36
|
+
const segLeading = seg[0] === "/";
|
|
37
|
+
const both = pathTrailing && segLeading;
|
|
38
|
+
if (both) path += seg.slice(1);
|
|
39
|
+
else path += pathTrailing || segLeading ? seg : `/${seg}`;
|
|
40
|
+
} else path += seg;
|
|
41
|
+
}
|
|
42
|
+
return normalize(path);
|
|
43
|
+
};
|
|
44
|
+
function normalizeString(path, allowAboveRoot) {
|
|
45
|
+
let res = "";
|
|
46
|
+
let lastSegmentLength = 0;
|
|
47
|
+
let lastSlash = -1;
|
|
48
|
+
let dots = 0;
|
|
49
|
+
let char = null;
|
|
50
|
+
for (let index = 0; index <= path.length; ++index) {
|
|
51
|
+
if (index < path.length) char = path[index];
|
|
52
|
+
else if (char === "/") break;
|
|
53
|
+
else char = "/";
|
|
54
|
+
if (char === "/") {
|
|
55
|
+
if (lastSlash === index - 1 || dots === 1);
|
|
56
|
+
else if (dots === 2) {
|
|
57
|
+
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
|
58
|
+
if (res.length > 2) {
|
|
59
|
+
const lastSlashIndex = res.lastIndexOf("/");
|
|
60
|
+
if (lastSlashIndex === -1) {
|
|
61
|
+
res = "";
|
|
62
|
+
lastSegmentLength = 0;
|
|
63
|
+
} else {
|
|
64
|
+
res = res.slice(0, lastSlashIndex);
|
|
65
|
+
lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
|
|
66
|
+
}
|
|
67
|
+
lastSlash = index;
|
|
68
|
+
dots = 0;
|
|
69
|
+
continue;
|
|
70
|
+
} else if (res.length > 0) {
|
|
71
|
+
res = "";
|
|
72
|
+
lastSegmentLength = 0;
|
|
73
|
+
lastSlash = index;
|
|
74
|
+
dots = 0;
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
if (allowAboveRoot) {
|
|
79
|
+
res += res.length > 0 ? "/.." : "..";
|
|
80
|
+
lastSegmentLength = 2;
|
|
81
|
+
}
|
|
82
|
+
} else {
|
|
83
|
+
if (res.length > 0) res += `/${path.slice(lastSlash + 1, index)}`;
|
|
84
|
+
else res = path.slice(lastSlash + 1, index);
|
|
85
|
+
lastSegmentLength = index - lastSlash - 1;
|
|
86
|
+
}
|
|
87
|
+
lastSlash = index;
|
|
88
|
+
dots = 0;
|
|
89
|
+
} else if (char === "." && dots !== -1) ++dots;
|
|
90
|
+
else dots = -1;
|
|
91
|
+
}
|
|
92
|
+
return res;
|
|
93
|
+
}
|
|
94
|
+
const isAbsolute = function(p) {
|
|
95
|
+
return _IS_ABSOLUTE_RE.test(p);
|
|
96
|
+
};
|
|
97
|
+
const dirname = function(p) {
|
|
98
|
+
const segments = normalizeWindowsPath(p).replace(/\/$/, "").split("/").slice(0, -1);
|
|
99
|
+
if (segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0])) segments[0] += "/";
|
|
100
|
+
return segments.join("/") || (isAbsolute(p) ? "/" : ".");
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
const packageCache = /* @__PURE__ */ new Map();
|
|
104
|
+
function findNearestPackageData(basedir) {
|
|
105
|
+
const originalBasedir = basedir;
|
|
106
|
+
while (basedir) {
|
|
107
|
+
var _tryStatSync;
|
|
108
|
+
const cached = getCachedData(packageCache, basedir, originalBasedir);
|
|
109
|
+
if (cached) return cached;
|
|
110
|
+
const pkgPath = join(basedir, "package.json");
|
|
111
|
+
if ((_tryStatSync = tryStatSync(pkgPath)) === null || _tryStatSync === void 0 ? void 0 : _tryStatSync.isFile()) {
|
|
112
|
+
const pkgData = JSON.parse(stripBomTag(fs.readFileSync(pkgPath, "utf8")));
|
|
113
|
+
if (packageCache) setCacheData(packageCache, pkgData, basedir, originalBasedir);
|
|
114
|
+
return pkgData;
|
|
115
|
+
}
|
|
116
|
+
const nextBasedir = dirname(basedir);
|
|
117
|
+
if (nextBasedir === basedir) break;
|
|
118
|
+
basedir = nextBasedir;
|
|
119
|
+
}
|
|
120
|
+
return {};
|
|
121
|
+
}
|
|
122
|
+
function stripBomTag(content) {
|
|
123
|
+
if (content.charCodeAt(0) === 65279) return content.slice(1);
|
|
124
|
+
return content;
|
|
125
|
+
}
|
|
126
|
+
function tryStatSync(file) {
|
|
127
|
+
try {
|
|
128
|
+
// The "throwIfNoEntry" is a performance optimization for cases where the file does not exist
|
|
129
|
+
return fs.statSync(file, { throwIfNoEntry: false });
|
|
130
|
+
} catch {}
|
|
131
|
+
}
|
|
132
|
+
function getCachedData(cache, basedir, originalBasedir) {
|
|
133
|
+
const pkgData = cache.get(getFnpdCacheKey(basedir));
|
|
134
|
+
if (pkgData) {
|
|
135
|
+
traverseBetweenDirs(originalBasedir, basedir, (dir) => {
|
|
136
|
+
cache.set(getFnpdCacheKey(dir), pkgData);
|
|
137
|
+
});
|
|
138
|
+
return pkgData;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
function setCacheData(cache, data, basedir, originalBasedir) {
|
|
142
|
+
cache.set(getFnpdCacheKey(basedir), data);
|
|
143
|
+
traverseBetweenDirs(originalBasedir, basedir, (dir) => {
|
|
144
|
+
cache.set(getFnpdCacheKey(dir), data);
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
function getFnpdCacheKey(basedir) {
|
|
148
|
+
return `fnpd_${basedir}`;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Traverse between `longerDir` (inclusive) and `shorterDir` (exclusive) and call `cb` for each dir.
|
|
152
|
+
* @param longerDir Longer dir path, e.g. `/User/foo/bar/baz`
|
|
153
|
+
* @param shorterDir Shorter dir path, e.g. `/User/foo`
|
|
154
|
+
*/
|
|
155
|
+
function traverseBetweenDirs(longerDir, shorterDir, cb) {
|
|
156
|
+
while (longerDir !== shorterDir) {
|
|
157
|
+
cb(longerDir);
|
|
158
|
+
longerDir = dirname(longerDir);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export { findNearestPackageData as f };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getSafeTimers } from '@vitest/utils';
|
|
2
2
|
import { c as createBirpc } from './index.Bgo3tNWt.js';
|
|
3
|
-
import { g as getWorkerState } from './utils.
|
|
3
|
+
import { g as getWorkerState } from './utils.B9FY3b73.js';
|
|
4
4
|
|
|
5
5
|
const { get } = Reflect;
|
|
6
6
|
function withSafeTimers(fn) {
|
|
@@ -1,25 +1,23 @@
|
|
|
1
1
|
import { performance } from 'node:perf_hooks';
|
|
2
2
|
import { startTests, collectTests } from '@vitest/runner';
|
|
3
|
-
import { a as resolveSnapshotEnvironment, s as setupChaiConfig, r as resolveTestRunner } from './index.
|
|
4
|
-
import { c as setupCommonEnv, s as startCoverageInsideWorker, a as stopCoverageInsideWorker } from './setup-common.
|
|
5
|
-
import { a as globalExpect, v as vi } from './vi.
|
|
3
|
+
import { a as resolveSnapshotEnvironment, s as setupChaiConfig, r as resolveTestRunner } from './index.oWRWx-nj.js';
|
|
4
|
+
import { c as setupCommonEnv, s as startCoverageInsideWorker, a as stopCoverageInsideWorker } from './setup-common.lgPs-bYv.js';
|
|
5
|
+
import { a as globalExpect, v as vi } from './vi.DGAfBY4R.js';
|
|
6
6
|
import { c as closeInspector } from './inspector.C914Efll.js';
|
|
7
7
|
import { createRequire } from 'node:module';
|
|
8
8
|
import timers from 'node:timers';
|
|
9
9
|
import timersPromises from 'node:timers/promises';
|
|
10
10
|
import util from 'node:util';
|
|
11
|
-
import { getSafeTimers } from '@vitest/utils';
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import { V as VitestIndex } from './index.D1_MsKEt.js';
|
|
15
|
-
import { g as getWorkerState, r as resetModules } from './utils.XdZDrNZV.js';
|
|
11
|
+
import { KNOWN_ASSET_TYPES, getSafeTimers } from '@vitest/utils';
|
|
12
|
+
import { V as VitestIndex } from './index.QZr3S3vQ.js';
|
|
13
|
+
import { g as getWorkerState, r as resetModules } from './utils.B9FY3b73.js';
|
|
16
14
|
import 'chai';
|
|
17
15
|
import 'node:path';
|
|
18
16
|
import '../path.js';
|
|
19
17
|
import 'node:url';
|
|
20
|
-
import './rpc.
|
|
18
|
+
import './rpc.DGoW_Vl-.js';
|
|
21
19
|
import './index.Bgo3tNWt.js';
|
|
22
|
-
import './coverage.
|
|
20
|
+
import './coverage.D_JHT54q.js';
|
|
23
21
|
import '@vitest/snapshot';
|
|
24
22
|
import '@vitest/expect';
|
|
25
23
|
import '@vitest/runner/utils';
|
|
@@ -28,22 +26,24 @@ import '@vitest/utils/error';
|
|
|
28
26
|
import '@vitest/spy';
|
|
29
27
|
import '@vitest/utils/source-map';
|
|
30
28
|
import './date.Bq6ZW5rf.js';
|
|
31
|
-
import './benchmark.
|
|
29
|
+
import './benchmark.CtuRzf-i.js';
|
|
32
30
|
import 'expect-type';
|
|
31
|
+
import 'vite/module-runner';
|
|
33
32
|
|
|
34
33
|
// this should only be used in Node
|
|
35
34
|
let globalSetup = false;
|
|
36
|
-
async function setupGlobalEnv(config, { environment },
|
|
35
|
+
async function setupGlobalEnv(config, { environment }, moduleRunner) {
|
|
37
36
|
await setupCommonEnv(config);
|
|
38
37
|
Object.defineProperty(globalThis, "__vitest_index__", {
|
|
39
38
|
value: VitestIndex,
|
|
40
39
|
enumerable: false
|
|
41
40
|
});
|
|
42
41
|
const state = getWorkerState();
|
|
43
|
-
if (!state.config.snapshotOptions.snapshotEnvironment) state.config.snapshotOptions.snapshotEnvironment = await resolveSnapshotEnvironment(config,
|
|
42
|
+
if (!state.config.snapshotOptions.snapshotEnvironment) state.config.snapshotOptions.snapshotEnvironment = await resolveSnapshotEnvironment(config, moduleRunner);
|
|
44
43
|
if (globalSetup) return;
|
|
45
44
|
globalSetup = true;
|
|
46
|
-
|
|
45
|
+
const viteEnvironment = environment.viteEnvironment || environment.name;
|
|
46
|
+
if (viteEnvironment === "client") {
|
|
47
47
|
const _require = createRequire(import.meta.url);
|
|
48
48
|
// always mock "required" `css` files, because we cannot process them
|
|
49
49
|
_require.extensions[".css"] = resolveCss;
|
|
@@ -62,7 +62,6 @@ async function setupGlobalEnv(config, { environment }, executor) {
|
|
|
62
62
|
timers,
|
|
63
63
|
timersPromises
|
|
64
64
|
};
|
|
65
|
-
installSourcemapsSupport({ getSourceMap: (source) => state.moduleCache.getSourceMap(source) });
|
|
66
65
|
if (!config.disableConsoleIntercept) await setupConsoleLogSpy();
|
|
67
66
|
}
|
|
68
67
|
function resolveCss(mod) {
|
|
@@ -72,7 +71,7 @@ function resolveAsset(mod, url) {
|
|
|
72
71
|
mod.exports = url;
|
|
73
72
|
}
|
|
74
73
|
async function setupConsoleLogSpy() {
|
|
75
|
-
const { createCustomConsole } = await import('./console.
|
|
74
|
+
const { createCustomConsole } = await import('./console.Duv2dVIC.js');
|
|
76
75
|
globalThis.console = createCustomConsole();
|
|
77
76
|
}
|
|
78
77
|
async function withEnv({ environment }, options, fn) {
|
|
@@ -91,15 +90,15 @@ async function withEnv({ environment }, options, fn) {
|
|
|
91
90
|
}
|
|
92
91
|
|
|
93
92
|
// browser shouldn't call this!
|
|
94
|
-
async function run(method, files, config, environment,
|
|
93
|
+
async function run(method, files, config, environment, moduleRunner) {
|
|
95
94
|
const workerState = getWorkerState();
|
|
96
95
|
const isIsolatedThreads = config.pool === "threads" && (config.poolOptions?.threads?.isolate ?? true);
|
|
97
96
|
const isIsolatedForks = config.pool === "forks" && (config.poolOptions?.forks?.isolate ?? true);
|
|
98
97
|
const isolate = isIsolatedThreads || isIsolatedForks;
|
|
99
|
-
await setupGlobalEnv(config, environment,
|
|
100
|
-
await startCoverageInsideWorker(config.coverage,
|
|
98
|
+
await setupGlobalEnv(config, environment, moduleRunner);
|
|
99
|
+
await startCoverageInsideWorker(config.coverage, moduleRunner, { isolate });
|
|
101
100
|
if (config.chaiConfig) setupChaiConfig(config.chaiConfig);
|
|
102
|
-
const runner = await resolveTestRunner(config,
|
|
101
|
+
const runner = await resolveTestRunner(config, moduleRunner);
|
|
103
102
|
workerState.onCancel.then((reason) => {
|
|
104
103
|
closeInspector(config);
|
|
105
104
|
runner.cancel?.(reason);
|
|
@@ -110,8 +109,8 @@ async function run(method, files, config, environment, executor) {
|
|
|
110
109
|
workerState.durations.environment = performance.now() - workerState.durations.environment;
|
|
111
110
|
for (const file of files) {
|
|
112
111
|
if (isolate) {
|
|
113
|
-
|
|
114
|
-
resetModules(workerState.
|
|
112
|
+
moduleRunner.mocker.reset();
|
|
113
|
+
resetModules(workerState.evaluatedModules, true);
|
|
115
114
|
}
|
|
116
115
|
workerState.filepath = file.filepath;
|
|
117
116
|
if (method === "run") await startTests([file], runner);
|
|
@@ -121,7 +120,7 @@ async function run(method, files, config, environment, executor) {
|
|
|
121
120
|
// mocks should not affect different files
|
|
122
121
|
vi.restoreAllMocks();
|
|
123
122
|
}
|
|
124
|
-
await stopCoverageInsideWorker(config.coverage,
|
|
123
|
+
await stopCoverageInsideWorker(config.coverage, moduleRunner, { isolate });
|
|
125
124
|
});
|
|
126
125
|
workerState.environmentTeardownRun = true;
|
|
127
126
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { r as resolveCoverageProviderModule } from './coverage.
|
|
1
|
+
import { r as resolveCoverageProviderModule } from './coverage.D_JHT54q.js';
|
|
2
2
|
import { addSerializer } from '@vitest/snapshot';
|
|
3
3
|
import { setSafeTimers } from '@vitest/utils';
|
|
4
|
+
import { g as getWorkerState } from './utils.B9FY3b73.js';
|
|
4
5
|
|
|
5
6
|
async function startCoverageInsideWorker(options, loader, runtimeOptions) {
|
|
6
7
|
const coverageModule = await resolveCoverageProviderModule(options, loader);
|
|
@@ -25,30 +26,30 @@ async function setupCommonEnv(config) {
|
|
|
25
26
|
if (globalSetup) return;
|
|
26
27
|
globalSetup = true;
|
|
27
28
|
setSafeTimers();
|
|
28
|
-
if (config.globals) (await import('./globals.
|
|
29
|
+
if (config.globals) (await import('./globals.CJQ63oO0.js')).registerApiGlobally();
|
|
29
30
|
}
|
|
30
31
|
function setupDefines(defines) {
|
|
31
32
|
for (const key in defines) globalThis[key] = defines[key];
|
|
32
33
|
}
|
|
33
34
|
function setupEnv(env) {
|
|
34
|
-
|
|
35
|
+
const state = getWorkerState();
|
|
35
36
|
// same boolean-to-string assignment as VitestPlugin.configResolved
|
|
36
37
|
const { PROD, DEV,...restEnvs } = env;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
for (const key in restEnvs)
|
|
38
|
+
state.metaEnv.PROD = PROD;
|
|
39
|
+
state.metaEnv.DEV = DEV;
|
|
40
|
+
for (const key in restEnvs) state.metaEnv[key] = env[key];
|
|
40
41
|
}
|
|
41
|
-
async function loadDiffConfig(config,
|
|
42
|
+
async function loadDiffConfig(config, moduleRunner) {
|
|
42
43
|
if (typeof config.diff === "object") return config.diff;
|
|
43
44
|
if (typeof config.diff !== "string") return;
|
|
44
|
-
const diffModule = await
|
|
45
|
+
const diffModule = await moduleRunner.import(config.diff);
|
|
45
46
|
if (diffModule && typeof diffModule.default === "object" && diffModule.default != null) return diffModule.default;
|
|
46
47
|
else throw new Error(`invalid diff config file ${config.diff}. Must have a default export with config object`);
|
|
47
48
|
}
|
|
48
|
-
async function loadSnapshotSerializers(config,
|
|
49
|
+
async function loadSnapshotSerializers(config, moduleRunner) {
|
|
49
50
|
const files = config.snapshotSerializers;
|
|
50
51
|
const snapshotSerializers = await Promise.all(files.map(async (file) => {
|
|
51
|
-
const mo = await
|
|
52
|
+
const mo = await moduleRunner.import(file);
|
|
52
53
|
if (!mo || typeof mo.default !== "object" || mo.default === null) throw new Error(`invalid snapshot serializer file ${file}. Must export a default object`);
|
|
53
54
|
const config = mo.default;
|
|
54
55
|
if (typeof config.test !== "function" || typeof config.serialize !== "function" && typeof config.print !== "function") throw new TypeError(`invalid snapshot serializer in ${file}. Must have a 'test' method along with either a 'serialize' or 'print' method.`);
|