vitest 3.2.0-beta.1 → 3.2.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +0 -232
- package/dist/browser.d.ts +5 -3
- package/dist/browser.js +3 -4
- package/dist/chunks/{base.SfTiRNZf.js → base.D4119yLM.js} +4 -3
- package/dist/chunks/{benchmark.BoF7jW0Q.js → benchmark.Cf_PACH1.js} +1 -1
- package/dist/chunks/{cac.TfX2-DVH.js → cac.DWaWHIIE.js} +21 -16
- package/dist/chunks/{cli-api.2970Nj9J.js → cli-api.CnmEXkxs.js} +292 -59
- package/dist/chunks/{config.d.UqE-KR0o.d.ts → config.d.D2ROskhv.d.ts} +2 -0
- package/dist/chunks/{console.K1NMVOSc.js → console.Cwr-MFPV.js} +3 -2
- package/dist/chunks/{constants.BZZyIeIE.js → constants.DnKduX2e.js} +1 -0
- package/dist/chunks/{coverage.z0LVMxgb.js → coverage.C73DaDgS.js} +241 -4226
- package/dist/chunks/{creator.CuL7xDWI.js → creator.C8WKy2eW.js} +26 -44
- package/dist/chunks/{date.CDOsz-HY.js → date.ByMsSlOr.js} +25 -0
- package/dist/chunks/{defaults.DSxsTG0h.js → defaults.DpVH7vbg.js} +1 -0
- package/dist/chunks/{environment.d.D8YDy2v5.d.ts → environment.d.cL3nLXbE.d.ts} +1 -0
- package/dist/chunks/{execute.BpmIjFTD.js → execute.B3q-2LPV.js} +28 -5
- package/dist/chunks/{global.d.BCOHQEpR.d.ts → global.d.BNLIi6yo.d.ts} +13 -11
- package/dist/chunks/{globals.Cg4NtV4P.js → globals.CI21aWXF.js} +7 -7
- package/dist/chunks/{index.DFXFpH3w.js → index.2jgTs_Q5.js} +19 -1
- package/dist/chunks/{index.CUacZlWG.js → index.Bter3jj9.js} +954 -954
- package/dist/chunks/{index.DbWBPwtH.js → index.CbT4iuwc.js} +7 -4
- package/dist/chunks/index.D3XRDfWc.js +213 -0
- package/dist/chunks/{index.BPc7M5ni.js → index.DNgLEKsQ.js} +5 -15
- package/dist/chunks/index.JOzufsrU.js +276 -0
- package/dist/chunks/{index.DBIGubLC.js → index.X0nbfr6-.js} +7 -7
- package/dist/chunks/{inspector.DbDkSkFn.js → inspector.BFsh5KO0.js} +3 -0
- package/dist/chunks/{node.3xsWotC9.js → node.Be-ntJnD.js} +1 -1
- package/dist/chunks/{reporters.d.DGm4k1Wx.d.ts → reporters.d.Bt4IGtsa.d.ts} +41 -6
- package/dist/chunks/{rpc.D9_013TY.js → rpc.BKExFSRG.js} +2 -1
- package/dist/chunks/{runBaseTests.CguliJB5.js → runBaseTests.B_M1TTsK.js} +19 -11
- package/dist/chunks/{setup-common.BP6KrF_Z.js → setup-common.CF-O-dZX.js} +2 -3
- package/dist/chunks/typechecker.BgzF-6iO.js +954 -0
- package/dist/chunks/{utils.CgTj3MsC.js → utils.BlI4TC7Y.js} +1 -0
- package/dist/chunks/{utils.BfxieIyZ.js → utils.DPCq3gzW.js} +3 -0
- package/dist/chunks/{vi.BFR5YIgu.js → vi.pkoYCV6A.js} +25 -2
- package/dist/chunks/{vite.d.DjP_ALCZ.d.ts → vite.d.B-Kx3KCF.d.ts} +3 -1
- package/dist/chunks/{vm.CuLHT1BG.js → vm.DPYem2so.js} +72 -4
- package/dist/chunks/{worker.d.CoCI7hzP.d.ts → worker.d.BKbBp2ga.d.ts} +2 -2
- package/dist/chunks/{worker.d.D5Xdi-Zr.d.ts → worker.d.Bl1O4kuf.d.ts} +1 -1
- package/dist/cli.js +21 -2
- package/dist/config.cjs +2 -0
- package/dist/config.d.ts +7 -6
- package/dist/config.js +2 -2
- package/dist/coverage.d.ts +4 -4
- package/dist/coverage.js +7 -10
- package/dist/environments.d.ts +6 -2
- package/dist/environments.js +1 -1
- package/dist/execute.d.ts +9 -3
- package/dist/execute.js +1 -1
- package/dist/index.d.ts +25 -35
- package/dist/index.js +5 -6
- package/dist/node.d.ts +18 -10
- package/dist/node.js +22 -22
- package/dist/reporters.d.ts +4 -4
- package/dist/reporters.js +14 -14
- package/dist/runners.d.ts +1 -1
- package/dist/runners.js +13 -5
- package/dist/snapshot.js +2 -2
- package/dist/suite.js +2 -2
- package/dist/worker.js +9 -5
- package/dist/workers/forks.js +6 -4
- package/dist/workers/runVmTests.js +14 -10
- package/dist/workers/threads.js +4 -4
- package/dist/workers/vmForks.js +6 -6
- package/dist/workers/vmThreads.js +6 -6
- package/dist/workers.d.ts +4 -4
- package/dist/workers.js +10 -10
- package/package.json +22 -26
- package/dist/chunks/index.Bw6JxgX8.js +0 -143
- package/dist/chunks/run-once.Dimr7O9f.js +0 -47
- package/dist/chunks/typechecker.DYQbn8uK.js +0 -956
- package/dist/chunks/utils.8gfOgtry.js +0 -207
- package/dist/utils.d.ts +0 -3
- package/dist/utils.js +0 -2
package/dist/execute.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { ViteNodeRunnerOptions } from 'vite-node';
|
|
2
2
|
import { ViteNodeRunner, ModuleExecutionInfo } from 'vite-node/client';
|
|
3
|
-
import { R as RuntimeRPC, W as WorkerGlobalState } from './chunks/worker.d.
|
|
3
|
+
import { R as RuntimeRPC, W as WorkerGlobalState } from './chunks/worker.d.BKbBp2ga.js';
|
|
4
4
|
import vm from 'node:vm';
|
|
5
5
|
import { MockedModule, MockedModuleType } from '@vitest/mocker';
|
|
6
6
|
import { P as PendingSuiteMock, b as MockFactory, a as MockOptions } from './chunks/mocker.d.BE_2ls6u.js';
|
|
7
7
|
import '@vitest/runner';
|
|
8
|
-
import './chunks/config.d.
|
|
8
|
+
import './chunks/config.d.D2ROskhv.js';
|
|
9
9
|
import '@vitest/pretty-format';
|
|
10
10
|
import '@vitest/snapshot';
|
|
11
11
|
import '@vitest/snapshot/environment';
|
|
12
12
|
import '@vitest/utils/diff';
|
|
13
|
-
import './chunks/environment.d.
|
|
13
|
+
import './chunks/environment.d.cL3nLXbE.js';
|
|
14
14
|
import 'vitest/optional-types.js';
|
|
15
15
|
|
|
16
16
|
declare class FileMap {
|
|
@@ -21,6 +21,8 @@ declare class FileMap {
|
|
|
21
21
|
readBuffer(path: string): Buffer;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
// need to copy paste types for vm
|
|
25
|
+
// because they require latest @types/node which we don't bundle
|
|
24
26
|
interface ModuleEvaluateOptions {
|
|
25
27
|
timeout?: vm.RunningScriptOptions["timeout"] | undefined;
|
|
26
28
|
breakOnSigint?: vm.RunningScriptOptions["breakOnSigint"] | undefined;
|
|
@@ -48,6 +50,7 @@ interface ExternalModulesExecutorOptions {
|
|
|
48
50
|
interopDefault?: boolean;
|
|
49
51
|
viteClientModule: Record<string, unknown>;
|
|
50
52
|
}
|
|
53
|
+
// TODO: improve Node.js strict mode support in #2854
|
|
51
54
|
declare class ExternalModulesExecutor {
|
|
52
55
|
#private;
|
|
53
56
|
private options;
|
|
@@ -61,6 +64,7 @@ declare class ExternalModulesExecutor {
|
|
|
61
64
|
import(identifier: string): Promise<object>;
|
|
62
65
|
require(identifier: string): any;
|
|
63
66
|
createRequire(identifier: string): NodeJS.Require;
|
|
67
|
+
// dynamic import can be used in both ESM and CJS, so we have it in the executor
|
|
64
68
|
importModuleDynamically: (specifier: string, referencer: VMModule) => Promise<VMModule>;
|
|
65
69
|
resolveModule: (specifier: string, referencer: string) => Promise<VMModule>;
|
|
66
70
|
resolve(specifier: string, parent: string): string;
|
|
@@ -98,7 +102,9 @@ declare class VitestMocker {
|
|
|
98
102
|
private resolvePath;
|
|
99
103
|
resolveMocks(): Promise<void>;
|
|
100
104
|
private callFunctionMock;
|
|
105
|
+
// public method to avoid circular dependency
|
|
101
106
|
getMockContext(): MockContext;
|
|
107
|
+
// path used to store mocked dependencies
|
|
102
108
|
getMockPath(dep: string): string;
|
|
103
109
|
getDependencyMock(id: string): MockedModule | undefined;
|
|
104
110
|
normalizePath(path: string): string;
|
package/dist/execute.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { File as File$1, TaskResultPack as TaskResultPack$1, TaskEventPack, TaskPopulated, Suite as Suite$1, Test as Test$1, Custom as Custom$1, Task as Task$1, TaskBase as TaskBase$1, TaskResult as TaskResult$1, DoneCallback as DoneCallback$1, RuntimeContext as RuntimeContext$1, SuiteHooks as SuiteHooks$1, SequenceHooks as SequenceHooks$1, SequenceSetupFiles as SequenceSetupFiles$1 } from '@vitest/runner';
|
|
2
2
|
export { CancelReason, ExtendedContext, HookCleanupCallback, HookListener, OnTestFailedHandler, OnTestFinishedHandler, RunMode, Custom as RunnerCustomCase, 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, TaskContext, TaskCustomOptions, TaskMeta, TaskState, TestAPI, TestContext, TestFunction, TestOptions, afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, onTestFinished, suite, test } from '@vitest/runner';
|
|
3
|
-
import { S as SerializedTestSpecification, h as CoverageProvider$1, a as ReportContext$1, i as CoverageProviderModule$1, j as CoverageReporter$1, k as CoverageProviderName, l as CoverageOptions$1, R as ResolvedCoverageOptions$1, B as BaseCoverageOptions$1, m as CoverageIstanbulOptions$1, c as CoverageV8Options$1, n as CustomProviderOptions$1, o as Reporter$1, V as Vitest$1, p as BrowserScript$1, q as BrowserConfigOptions$1, r as BuiltinEnvironment$1, s as VitestEnvironment$1, P as Pool$1, t as PoolOptions$1, u as CSSModuleScopeStrategy$1, A as ApiConfig$1, v as VitestRunMode$1, D as DepsOptimizationOptions$1, w as TransformModePatterns$1, I as InlineConfig$1, x as TypecheckConfig$1, y as UserConfig$1, z as ResolvedConfig$1, E as ProjectConfig$1, U as UserWorkspaceConfig$1, F as BenchmarkUserOptions$1 } from './chunks/reporters.d.
|
|
4
|
-
export { G as BrowserTesterOptions } from './chunks/reporters.d.
|
|
5
|
-
import { W as WorkerContext$1 } from './chunks/worker.d.
|
|
6
|
-
import { R as RawErrsMap$1, T as TscErrorInfo$1, C as CollectLineNumbers$1, a as CollectLines$1, b as RootAndTarget$1, c as Context$1 } from './chunks/global.d.
|
|
7
|
-
import { b as Awaitable$1, U as UserConsoleLog, L as LabelColor, M as ModuleGraphData, P as ProvidedContext, N as Nullable$1, c as Arrayable$1, d as ArgumentsType$1, e as MutableArray$1, C as Constructable$1, a as EnvironmentReturn$1, V as VmEnvironmentReturn$1, E as Environment$1, R as ResolvedTestEnvironment$1, J as JSDOMOptions$1, H as HappyDOMOptions$1, f as EnvironmentOptions$1 } from './chunks/environment.d.
|
|
8
|
-
export { A as AfterSuiteRunMeta, g as ModuleCache } from './chunks/environment.d.
|
|
9
|
-
import { a as BirpcReturn, b as WorkerRPC$1 } from './chunks/worker.d.
|
|
10
|
-
export { C as ContextRPC, d as ContextTestEnvironment, e as ResolveIdFunction, c as RunnerRPC, R as RuntimeRPC, T as TestExecutionMethod, W as WorkerGlobalState } from './chunks/worker.d.
|
|
11
|
-
import './chunks/vite.d.
|
|
12
|
-
import { a as SerializedConfig, F as FakeTimerInstallOpts, R as RuntimeOptions } from './chunks/config.d.
|
|
13
|
-
export { b as RuntimeConfig, S as SerializedCoverageConfig } from './chunks/config.d.
|
|
3
|
+
import { S as SerializedTestSpecification, h as CoverageProvider$1, a as ReportContext$1, i as CoverageProviderModule$1, j as CoverageReporter$1, k as CoverageProviderName, l as CoverageOptions$1, R as ResolvedCoverageOptions$1, B as BaseCoverageOptions$1, m as CoverageIstanbulOptions$1, c as CoverageV8Options$1, n as CustomProviderOptions$1, o as Reporter$1, V as Vitest$1, p as BrowserScript$1, q as BrowserConfigOptions$1, r as BuiltinEnvironment$1, s as VitestEnvironment$1, P as Pool$1, t as PoolOptions$1, u as CSSModuleScopeStrategy$1, A as ApiConfig$1, v as VitestRunMode$1, D as DepsOptimizationOptions$1, w as TransformModePatterns$1, I as InlineConfig$1, x as TypecheckConfig$1, y as UserConfig$1, z as ResolvedConfig$1, E as ProjectConfig$1, U as UserWorkspaceConfig$1, F as BenchmarkUserOptions$1 } from './chunks/reporters.d.Bt4IGtsa.js';
|
|
4
|
+
export { G as BrowserTesterOptions } from './chunks/reporters.d.Bt4IGtsa.js';
|
|
5
|
+
import { W as WorkerContext$1 } from './chunks/worker.d.Bl1O4kuf.js';
|
|
6
|
+
import { R as RawErrsMap$1, T as TscErrorInfo$1, C as CollectLineNumbers$1, a as CollectLines$1, b as RootAndTarget$1, c as Context$1 } from './chunks/global.d.BNLIi6yo.js';
|
|
7
|
+
import { b as Awaitable$1, U as UserConsoleLog, L as LabelColor, M as ModuleGraphData, P as ProvidedContext, N as Nullable$1, c as Arrayable$1, d as ArgumentsType$1, e as MutableArray$1, C as Constructable$1, a as EnvironmentReturn$1, V as VmEnvironmentReturn$1, E as Environment$1, R as ResolvedTestEnvironment$1, J as JSDOMOptions$1, H as HappyDOMOptions$1, f as EnvironmentOptions$1 } from './chunks/environment.d.cL3nLXbE.js';
|
|
8
|
+
export { A as AfterSuiteRunMeta, g as ModuleCache } from './chunks/environment.d.cL3nLXbE.js';
|
|
9
|
+
import { a as BirpcReturn, b as WorkerRPC$1 } from './chunks/worker.d.BKbBp2ga.js';
|
|
10
|
+
export { C as ContextRPC, d as ContextTestEnvironment, e as ResolveIdFunction, c as RunnerRPC, R as RuntimeRPC, T as TestExecutionMethod, W as WorkerGlobalState } from './chunks/worker.d.BKbBp2ga.js';
|
|
11
|
+
import './chunks/vite.d.B-Kx3KCF.js';
|
|
12
|
+
import { a as SerializedConfig, F as FakeTimerInstallOpts, R as RuntimeOptions } from './chunks/config.d.D2ROskhv.js';
|
|
13
|
+
export { b as RuntimeConfig, S as SerializedCoverageConfig } from './chunks/config.d.D2ROskhv.js';
|
|
14
14
|
import { ExpectStatic } from '@vitest/expect';
|
|
15
|
-
export { Assertion, AsymmetricMatchersContaining, ExpectPollOptions, ExpectStatic, JestAssertion } from '@vitest/expect';
|
|
15
|
+
export { Assertion, AsymmetricMatchersContaining, ExpectPollOptions, ExpectStatic, JestAssertion, Matchers } from '@vitest/expect';
|
|
16
16
|
import { spyOn, fn, MaybeMockedDeep, MaybeMocked, MaybePartiallyMocked, MaybePartiallyMockedDeep, MockInstance } from '@vitest/spy';
|
|
17
17
|
export { Mock, MockContext, MockInstance, Mocked, MockedClass, MockedFunction, MockedObject } from '@vitest/spy';
|
|
18
18
|
import { M as MockFactoryWithHelper, a as MockOptions } from './chunks/mocker.d.BE_2ls6u.js';
|
|
@@ -68,6 +68,7 @@ interface WebSocketHandlers {
|
|
|
68
68
|
getTestFiles: () => Promise<SerializedTestSpecification[]>;
|
|
69
69
|
getPaths: () => string[];
|
|
70
70
|
getConfig: () => SerializedConfig;
|
|
71
|
+
// TODO: Remove in v4
|
|
71
72
|
/** @deprecated -- Use `getResolvedProjectLabels` instead */
|
|
72
73
|
getResolvedProjectNames: () => string[];
|
|
73
74
|
getResolvedProjectLabels: () => {
|
|
@@ -94,6 +95,8 @@ interface WebSocketEvents {
|
|
|
94
95
|
}
|
|
95
96
|
type WebSocketRPC = BirpcReturn<WebSocketEvents, WebSocketHandlers>;
|
|
96
97
|
|
|
98
|
+
// CI fails only for this file, but it works locally
|
|
99
|
+
|
|
97
100
|
declare function createExpect(test?: TaskPopulated): ExpectStatic;
|
|
98
101
|
declare const globalExpect: ExpectStatic;
|
|
99
102
|
|
|
@@ -103,28 +106,7 @@ declare const globalExpect: ExpectStatic;
|
|
|
103
106
|
*/
|
|
104
107
|
declare function inject<T extends keyof ProvidedContext & string>(key: T): ProvidedContext[T];
|
|
105
108
|
|
|
106
|
-
|
|
107
|
-
* This utils allows computational intensive tasks to only be ran once
|
|
108
|
-
* across test reruns to improve the watch mode performance.
|
|
109
|
-
*
|
|
110
|
-
* Currently only works with `poolOptions.<pool>.isolate: false`
|
|
111
|
-
*
|
|
112
|
-
* @experimental
|
|
113
|
-
*/
|
|
114
|
-
declare function runOnce<T>(fn: () => T, key?: string): T;
|
|
115
|
-
/**
|
|
116
|
-
* Get a boolean indicates whether the task is running in the first time.
|
|
117
|
-
* Could only be `false` in watch mode.
|
|
118
|
-
*
|
|
119
|
-
* Currently only works with `isolate: false`
|
|
120
|
-
*
|
|
121
|
-
* @experimental
|
|
122
|
-
*/
|
|
123
|
-
declare function isFirstRun(): boolean;
|
|
124
|
-
|
|
125
|
-
declare function getRunningMode(): "watch" | "run";
|
|
126
|
-
declare function isWatchMode(): boolean;
|
|
127
|
-
|
|
109
|
+
// The waitFor function was inspired by https://github.com/testing-library/web-testing-library/pull/2
|
|
128
110
|
type WaitForCallback<T> = () => T | Promise<T>;
|
|
129
111
|
interface WaitForOptions {
|
|
130
112
|
/**
|
|
@@ -317,7 +299,9 @@ interface VitestUtils {
|
|
|
317
299
|
* @param path Path to the module. Can be aliased, if your Vitest config supports it
|
|
318
300
|
* @param factory Mocked module factory. The result of this function will be an exports object
|
|
319
301
|
*/
|
|
302
|
+
// eslint-disable-next-line ts/method-signature-style
|
|
320
303
|
mock(path: string, factory?: MockFactoryWithHelper | MockOptions): void;
|
|
304
|
+
// eslint-disable-next-line ts/method-signature-style
|
|
321
305
|
mock<T>(module: Promise<T>, factory?: MockFactoryWithHelper<T> | MockOptions): void;
|
|
322
306
|
/**
|
|
323
307
|
* Removes module from mocked registry. All calls to import will return the original module even if it was mocked before.
|
|
@@ -325,7 +309,9 @@ interface VitestUtils {
|
|
|
325
309
|
* This call is hoisted to the top of the file, so it will only unmock modules that were defined in `setupFiles`, for example.
|
|
326
310
|
* @param path Path to the module. Can be aliased, if your Vitest config supports it
|
|
327
311
|
*/
|
|
312
|
+
// eslint-disable-next-line ts/method-signature-style
|
|
328
313
|
unmock(path: string): void;
|
|
314
|
+
// eslint-disable-next-line ts/method-signature-style
|
|
329
315
|
unmock(module: Promise<unknown>): void;
|
|
330
316
|
/**
|
|
331
317
|
* Mocks every subsequent [dynamic import](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import) call.
|
|
@@ -336,7 +322,9 @@ interface VitestUtils {
|
|
|
336
322
|
* @param path Path to the module. Can be aliased, if your Vitest config supports it
|
|
337
323
|
* @param factory Mocked module factory. The result of this function will be an exports object
|
|
338
324
|
*/
|
|
325
|
+
// eslint-disable-next-line ts/method-signature-style
|
|
339
326
|
doMock(path: string, factory?: MockFactoryWithHelper | MockOptions): void;
|
|
327
|
+
// eslint-disable-next-line ts/method-signature-style
|
|
340
328
|
doMock<T>(module: Promise<T>, factory?: MockFactoryWithHelper<T> | MockOptions): void;
|
|
341
329
|
/**
|
|
342
330
|
* Removes module from mocked registry. All subsequent calls to import will return original module.
|
|
@@ -344,7 +332,9 @@ interface VitestUtils {
|
|
|
344
332
|
* Unlike [`vi.unmock`](https://vitest.dev/api/vi#vi-unmock), this method is not hoisted to the top of the file.
|
|
345
333
|
* @param path Path to the module. Can be aliased, if your Vitest config supports it
|
|
346
334
|
*/
|
|
335
|
+
// eslint-disable-next-line ts/method-signature-style
|
|
347
336
|
doUnmock(path: string): void;
|
|
337
|
+
// eslint-disable-next-line ts/method-signature-style
|
|
348
338
|
doUnmock(module: Promise<unknown>): void;
|
|
349
339
|
/**
|
|
350
340
|
* Imports module, bypassing all checks if it should be mocked.
|
|
@@ -656,5 +646,5 @@ type SerializableSpec = SerializedTestSpecification;
|
|
|
656
646
|
/** @deprecated import from `vitest/node` instead */
|
|
657
647
|
type BenchmarkUserOptions = BenchmarkUserOptions$1;
|
|
658
648
|
|
|
659
|
-
export { LabelColor, ModuleGraphData, ProvidedContext, SerializedConfig, SerializedTestSpecification, UserConsoleLog, assertType, createExpect, globalExpect as expect,
|
|
649
|
+
export { LabelColor, ModuleGraphData, ProvidedContext, SerializedConfig, SerializedTestSpecification, UserConsoleLog, assertType, createExpect, globalExpect as expect, inject, vi, vitest };
|
|
660
650
|
export type { ApiConfig, ArgumentsType, Arrayable, AssertType, Awaitable, BaseCoverageOptions, BenchmarkUserOptions, BrowserConfigOptions, BrowserScript, BrowserUI, BuiltinEnvironment, CSSModuleScopeStrategy, CollectLineNumbers, CollectLines, Constructable, Context, CoverageIstanbulOptions, CoverageOptions, CoverageProvider, CoverageProviderModule, CoverageReporter, CoverageV8Options, Custom, CustomProviderOptions, DepsOptimizationOptions, DoneCallback, Environment, EnvironmentOptions, EnvironmentReturn, File, HappyDOMOptions, InlineConfig, JSDOMOptions, MutableArray, Nullable, Pool, PoolOptions, ProjectConfig, RawErrsMap, ReportContext, Reporter, ResolvedConfig, ResolvedCoverageOptions, ResolvedTestEnvironment, RootAndTarget, RuntimeContext, SequenceHooks, SequenceSetupFiles, SerializableSpec, Suite, SuiteHooks, Task, TaskBase, TaskResult, TaskResultPack, Test, TransformModePatterns, TransformResultWithSource, TscErrorInfo, TypecheckConfig, UserConfig, UserWorkspaceConfig, Vitest, VitestEnvironment, VitestRunMode, VitestUtils, VmEnvironmentReturn, WebSocketEvents, WebSocketHandlers, WebSocketRPC, WorkerContext, WorkerRPC };
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
export { c as createExpect, a as expect, i as inject, v as vi, b as vitest } from './chunks/vi.
|
|
2
|
-
export {
|
|
3
|
-
export { a as assertType
|
|
4
|
-
export { b as bench } from './chunks/benchmark.BoF7jW0Q.js';
|
|
1
|
+
export { c as createExpect, a as expect, i as inject, v as vi, b as vitest } from './chunks/vi.pkoYCV6A.js';
|
|
2
|
+
export { b as bench } from './chunks/benchmark.Cf_PACH1.js';
|
|
3
|
+
export { a as assertType } from './chunks/index.DNgLEKsQ.js';
|
|
5
4
|
export { expectTypeOf } from 'expect-type';
|
|
6
5
|
export { afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, onTestFinished, suite, test } from '@vitest/runner';
|
|
7
6
|
import * as chai from 'chai';
|
|
@@ -9,11 +8,11 @@ export { chai };
|
|
|
9
8
|
export { assert, should } from 'chai';
|
|
10
9
|
import '@vitest/expect';
|
|
11
10
|
import '@vitest/runner/utils';
|
|
12
|
-
import './chunks/utils.
|
|
11
|
+
import './chunks/utils.BlI4TC7Y.js';
|
|
13
12
|
import '@vitest/utils';
|
|
14
13
|
import './chunks/_commonjsHelpers.BFTU3MAI.js';
|
|
15
14
|
import '@vitest/snapshot';
|
|
16
15
|
import '@vitest/utils/error';
|
|
17
16
|
import '@vitest/spy';
|
|
18
17
|
import '@vitest/utils/source-map';
|
|
19
|
-
import './chunks/date.
|
|
18
|
+
import './chunks/date.ByMsSlOr.js';
|
package/dist/node.d.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { z as ResolvedConfig, y as UserConfig, v as VitestRunMode, H as VitestOptions, V as Vitest, A as ApiConfig, T as TestProject, J as TestSequencer, K as TestSpecification, L as Logger, M as TestModule, N as ModuleDiagnostic } from './chunks/reporters.d.
|
|
2
|
-
export { B as BaseCoverageOptions, F as BenchmarkUserOptions, ag as BrowserBuiltinProvider, ah as BrowserCommand, ai as BrowserCommandContext, q as BrowserConfigOptions, aj as BrowserInstanceOption, ak as BrowserModuleMocker, al as BrowserOrchestrator, am as BrowserProvider, an as BrowserProviderInitializationOptions, ao as BrowserProviderModule, ap as BrowserProviderOptions, p as BrowserScript, aq as BrowserServerState, ar as BrowserServerStateSession, r as BuiltinEnvironment, as as CDPSession, u as CSSModuleScopeStrategy, m as CoverageIstanbulOptions, l as CoverageOptions, h as CoverageProvider, i as CoverageProviderModule, j as CoverageReporter, c as CoverageV8Options, n as CustomProviderOptions, D as DepsOptimizationOptions, a0 as HTMLOptions, I as InlineConfig, a2 as JUnitOptions, a1 as JsonOptions, O as OnServerRestartHandler, Q as OnTestsRerunHandler, at as ParentProjectBrowser, P as Pool, t as PoolOptions, Y as ProcessPool, au as ProjectBrowser, E as ProjectConfig, a as ReportContext, aA as ReportedHookContext, o as Reporter, ax as ResolveSnapshotPathHandler, ay as ResolveSnapshotPathHandlerContext, av as ResolvedBrowserOptions, R as ResolvedCoverageOptions, aw as ResolvedProjectConfig, $ as SerializedTestProject, a3 as TaskOptions, a4 as TestCase, a5 as TestCollection, a6 as TestDiagnostic, a7 as TestModuleState, a8 as TestResult, a9 as TestResultFailed, aa as TestResultPassed, ab as TestResultSkipped, aB as TestRunEndReason, az as TestRunResult, af as TestSequencerConstructor, ac as TestState, ad as TestSuite, ae as TestSuiteState, w as TransformModePatterns, x as TypecheckConfig, U as UserWorkspaceConfig, s as VitestEnvironment, X as VitestPackageInstaller, g as WatcherTriggerPattern, Z as WorkspaceSpec, _ as getFilePoolName } from './chunks/reporters.d.
|
|
1
|
+
import { z as ResolvedConfig, y as UserConfig, v as VitestRunMode, H as VitestOptions, V as Vitest, A as ApiConfig, T as TestProject, J as TestSequencer, K as TestSpecification, L as Logger, M as TestModule, N as ModuleDiagnostic } from './chunks/reporters.d.Bt4IGtsa.js';
|
|
2
|
+
export { B as BaseCoverageOptions, F as BenchmarkUserOptions, ag as BrowserBuiltinProvider, ah as BrowserCommand, ai as BrowserCommandContext, q as BrowserConfigOptions, aj as BrowserInstanceOption, ak as BrowserModuleMocker, al as BrowserOrchestrator, am as BrowserProvider, an as BrowserProviderInitializationOptions, ao as BrowserProviderModule, ap as BrowserProviderOptions, p as BrowserScript, aq as BrowserServerState, ar as BrowserServerStateSession, r as BuiltinEnvironment, as as CDPSession, u as CSSModuleScopeStrategy, m as CoverageIstanbulOptions, l as CoverageOptions, h as CoverageProvider, i as CoverageProviderModule, j as CoverageReporter, c as CoverageV8Options, n as CustomProviderOptions, D as DepsOptimizationOptions, a0 as HTMLOptions, I as InlineConfig, a2 as JUnitOptions, a1 as JsonOptions, O as OnServerRestartHandler, Q as OnTestsRerunHandler, at as ParentProjectBrowser, P as Pool, t as PoolOptions, Y as ProcessPool, au as ProjectBrowser, E as ProjectConfig, a as ReportContext, aA as ReportedHookContext, o as Reporter, ax as ResolveSnapshotPathHandler, ay as ResolveSnapshotPathHandlerContext, av as ResolvedBrowserOptions, R as ResolvedCoverageOptions, aw as ResolvedProjectConfig, $ as SerializedTestProject, a3 as TaskOptions, a4 as TestCase, a5 as TestCollection, a6 as TestDiagnostic, a7 as TestModuleState, a8 as TestResult, a9 as TestResultFailed, aa as TestResultPassed, ab as TestResultSkipped, aB as TestRunEndReason, az as TestRunResult, af as TestSequencerConstructor, ac as TestState, ad as TestSuite, ae as TestSuiteState, w as TransformModePatterns, x as TypecheckConfig, U as UserWorkspaceConfig, s as VitestEnvironment, X as VitestPackageInstaller, g as WatcherTriggerPattern, Z as WorkspaceSpec, _ as getFilePoolName } from './chunks/reporters.d.Bt4IGtsa.js';
|
|
3
3
|
import { InlineConfig, UserConfig as UserConfig$1, Plugin, ResolvedConfig as ResolvedConfig$1, LogLevel, LoggerOptions, Logger as Logger$1, createServer as createServer$1 } from 'vite';
|
|
4
4
|
import * as vite from 'vite';
|
|
5
5
|
export { vite as Vite };
|
|
6
6
|
export { esbuildVersion, isFileServingAllowed, parseAst, parseAstAsync, rollupVersion, version as viteVersion } from 'vite';
|
|
7
7
|
import { IncomingMessage } from 'node:http';
|
|
8
|
-
import { R as RuntimeRPC } from './chunks/worker.d.
|
|
9
|
-
export { T as TestExecutionType } from './chunks/worker.d.
|
|
8
|
+
import { R as RuntimeRPC } from './chunks/worker.d.BKbBp2ga.js';
|
|
9
|
+
export { T as TestExecutionType } from './chunks/worker.d.BKbBp2ga.js';
|
|
10
10
|
import { Writable } from 'node:stream';
|
|
11
|
-
export { V as VitestPluginContext } from './chunks/vite.d.
|
|
12
|
-
export { W as WorkerContext } from './chunks/worker.d.
|
|
13
|
-
export { C as TypeCheckCollectLineNumbers, a as TypeCheckCollectLines, c as TypeCheckContext, T as TypeCheckErrorInfo, R as TypeCheckRawErrorsMap, b as TypeCheckRootAndTarget } from './chunks/global.d.
|
|
11
|
+
export { V as VitestPluginContext } from './chunks/vite.d.B-Kx3KCF.js';
|
|
12
|
+
export { W as WorkerContext } from './chunks/worker.d.Bl1O4kuf.js';
|
|
13
|
+
export { C as TypeCheckCollectLineNumbers, a as TypeCheckCollectLines, c as TypeCheckContext, T as TypeCheckErrorInfo, R as TypeCheckRawErrorsMap, b as TypeCheckRootAndTarget } from './chunks/global.d.BNLIi6yo.js';
|
|
14
14
|
import { Debugger } from 'debug';
|
|
15
15
|
export { Task as RunnerTask, TaskResult as RunnerTaskResult, TaskResultPack as RunnerTaskResultPack, Test as RunnerTestCase, File as RunnerTestFile, Suite as RunnerTestSuite, SequenceHooks, SequenceSetupFiles } from '@vitest/runner';
|
|
16
|
-
export { f as EnvironmentOptions, H as HappyDOMOptions, J as JSDOMOptions } from './chunks/environment.d.
|
|
16
|
+
export { f as EnvironmentOptions, H as HappyDOMOptions, J as JSDOMOptions } from './chunks/environment.d.cL3nLXbE.js';
|
|
17
17
|
export { SerializedError } from '@vitest/utils';
|
|
18
|
-
export { b as RuntimeConfig } from './chunks/config.d.
|
|
18
|
+
export { b as RuntimeConfig } from './chunks/config.d.D2ROskhv.js';
|
|
19
19
|
export { generateFileHash } from '@vitest/runner/utils';
|
|
20
20
|
import 'node:console';
|
|
21
21
|
import '@vitest/mocker';
|
|
@@ -96,8 +96,9 @@ declare class GitNotFoundError extends Error {
|
|
|
96
96
|
/** @deprecated use `TestProject` instead */
|
|
97
97
|
type GlobalSetupContext = TestProject;
|
|
98
98
|
|
|
99
|
-
declare function VitestPlugin(options?: UserConfig,
|
|
99
|
+
declare function VitestPlugin(options?: UserConfig, vitest?: Vitest): Promise<Plugin[]>;
|
|
100
100
|
|
|
101
|
+
// this is only exported as a public function and not used inside vitest
|
|
101
102
|
declare function resolveConfig(options?: UserConfig, viteOverrides?: UserConfig$1): Promise<{
|
|
102
103
|
vitestConfig: ResolvedConfig
|
|
103
104
|
viteConfig: ResolvedConfig$1
|
|
@@ -107,6 +108,7 @@ declare function resolveFsAllow(projectRoot: string, rootConfigFile: string | fa
|
|
|
107
108
|
|
|
108
109
|
interface MethodsOptions {
|
|
109
110
|
cacheFs?: boolean;
|
|
111
|
+
// do not report files
|
|
110
112
|
collect?: boolean;
|
|
111
113
|
}
|
|
112
114
|
declare function createMethodsRPC(project: TestProject, options?: MethodsOptions): RuntimeRPC;
|
|
@@ -114,12 +116,18 @@ declare function createMethodsRPC(project: TestProject, options?: MethodsOptions
|
|
|
114
116
|
declare class BaseSequencer implements TestSequencer {
|
|
115
117
|
protected ctx: Vitest;
|
|
116
118
|
constructor(ctx: Vitest);
|
|
119
|
+
// async so it can be extended by other sequelizers
|
|
117
120
|
shard(files: TestSpecification[]): Promise<TestSpecification[]>;
|
|
121
|
+
// async so it can be extended by other sequelizers
|
|
118
122
|
sort(files: TestSpecification[]): Promise<TestSpecification[]>;
|
|
119
123
|
}
|
|
120
124
|
|
|
121
125
|
declare function registerConsoleShortcuts(ctx: Vitest, stdin: NodeJS.ReadStream | undefined, stdout: NodeJS.WriteStream | Writable): () => void;
|
|
122
126
|
|
|
127
|
+
// This is copy-pasted and needs to be synced from time to time. Ideally, Vite's `createLogger` should accept a custom `console`
|
|
128
|
+
// https://github.com/vitejs/vite/blob/main/packages/vite/src/node/logger.ts?rgh-link-date=2024-10-16T23%3A29%3A19Z
|
|
129
|
+
// When Vitest supports only Vite 6 and above, we can use Vite's `createLogger({ console })`
|
|
130
|
+
// https://github.com/vitejs/vite/pull/18379
|
|
123
131
|
declare function createViteLogger(console: Logger, level?: LogLevel, options?: LoggerOptions): Logger$1;
|
|
124
132
|
|
|
125
133
|
declare const rootDir: string;
|
package/dist/node.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { resolveConfig as resolveConfig$1, mergeConfig, createServer as createServer$1 } from 'vite';
|
|
2
2
|
export { esbuildVersion, isFileServingAllowed, parseAst, parseAstAsync, rollupVersion, version as viteVersion } from 'vite';
|
|
3
|
-
import { V as Vitest, a as VitestPlugin, T as TestModule } from './chunks/cli-api.
|
|
4
|
-
export { G as GitNotFoundError, F as TestsNotFoundError, b as VitestPackageInstaller, e as createViteLogger, c as createVitest, i as isValidApiRequest, d as registerConsoleShortcuts, r as resolveFsAllow, s as startVitest } from './chunks/cli-api.
|
|
5
|
-
export { p as parseCLI } from './chunks/cac.
|
|
6
|
-
import { r as resolveConfig$2 } from './chunks/coverage.
|
|
7
|
-
export { b as BaseSequencer, c as createMethodsRPC, g as getFilePoolName, a as resolveApiServerConfig } from './chunks/coverage.
|
|
8
|
-
import { slash } from '@vitest/utils';
|
|
9
|
-
import { f as findUp } from './chunks/index.
|
|
3
|
+
import { V as Vitest, a as VitestPlugin, T as TestModule } from './chunks/cli-api.CnmEXkxs.js';
|
|
4
|
+
export { G as GitNotFoundError, F as TestsNotFoundError, b as VitestPackageInstaller, e as createViteLogger, c as createVitest, i as isValidApiRequest, d as registerConsoleShortcuts, r as resolveFsAllow, s as startVitest } from './chunks/cli-api.CnmEXkxs.js';
|
|
5
|
+
export { p as parseCLI } from './chunks/cac.DWaWHIIE.js';
|
|
6
|
+
import { r as resolveConfig$2 } from './chunks/coverage.C73DaDgS.js';
|
|
7
|
+
export { b as BaseSequencer, c as createMethodsRPC, g as getFilePoolName, a as resolveApiServerConfig } from './chunks/coverage.C73DaDgS.js';
|
|
8
|
+
import { slash, deepClone } from '@vitest/utils';
|
|
9
|
+
import { f as findUp } from './chunks/index.X0nbfr6-.js';
|
|
10
10
|
import { resolve } from 'pathe';
|
|
11
|
-
import { c as configFiles } from './chunks/constants.
|
|
11
|
+
import { c as configFiles } from './chunks/constants.DnKduX2e.js';
|
|
12
12
|
export { distDir, rootDir } from './path.js';
|
|
13
13
|
import createDebug from 'debug';
|
|
14
14
|
export { generateFileHash } from '@vitest/runner/utils';
|
|
@@ -19,23 +19,20 @@ import '@vitest/snapshot/manager';
|
|
|
19
19
|
import 'vite-node/client';
|
|
20
20
|
import 'vite-node/server';
|
|
21
21
|
import './chunks/index.CJ0plNrh.js';
|
|
22
|
-
import './chunks/index.
|
|
23
|
-
import 'tinyrainbow';
|
|
24
|
-
import './chunks/utils.8gfOgtry.js';
|
|
25
|
-
import 'node:util';
|
|
22
|
+
import './chunks/index.Bter3jj9.js';
|
|
26
23
|
import 'node:perf_hooks';
|
|
27
24
|
import '@vitest/utils/source-map';
|
|
25
|
+
import 'tinyrainbow';
|
|
28
26
|
import './chunks/env.Dq0hM4Xv.js';
|
|
29
27
|
import 'std-env';
|
|
30
|
-
import './chunks/typechecker.
|
|
31
|
-
import 'node:fs/promises';
|
|
32
|
-
import 'tinyexec';
|
|
28
|
+
import './chunks/typechecker.BgzF-6iO.js';
|
|
33
29
|
import 'node:os';
|
|
34
|
-
import '
|
|
35
|
-
import 'node:
|
|
36
|
-
import 'fs';
|
|
30
|
+
import 'tinyexec';
|
|
31
|
+
import 'node:util';
|
|
32
|
+
import 'node:fs/promises';
|
|
37
33
|
import 'node:console';
|
|
38
34
|
import 'node:stream';
|
|
35
|
+
import 'node:module';
|
|
39
36
|
import 'events';
|
|
40
37
|
import 'https';
|
|
41
38
|
import 'http';
|
|
@@ -48,16 +45,17 @@ import 'zlib';
|
|
|
48
45
|
import 'buffer';
|
|
49
46
|
import './chunks/_commonjsHelpers.BFTU3MAI.js';
|
|
50
47
|
import 'node:crypto';
|
|
48
|
+
import 'node:url';
|
|
49
|
+
import 'picomatch';
|
|
51
50
|
import 'tinyglobby';
|
|
52
51
|
import 'vite-node/utils';
|
|
53
52
|
import '@vitest/mocker/node';
|
|
54
|
-
import './chunks/defaults.
|
|
53
|
+
import './chunks/defaults.DpVH7vbg.js';
|
|
55
54
|
import 'magic-string';
|
|
55
|
+
import './chunks/index.JOzufsrU.js';
|
|
56
56
|
import 'node:assert';
|
|
57
57
|
import '@vitest/utils/error';
|
|
58
58
|
import 'node:readline';
|
|
59
|
-
import 'util';
|
|
60
|
-
import 'path';
|
|
61
59
|
import 'node:process';
|
|
62
60
|
import 'node:v8';
|
|
63
61
|
import 'node:tty';
|
|
@@ -66,16 +64,18 @@ import 'tinypool';
|
|
|
66
64
|
import 'node:worker_threads';
|
|
67
65
|
import 'readline';
|
|
68
66
|
|
|
67
|
+
// this is only exported as a public function and not used inside vitest
|
|
69
68
|
async function resolveConfig(options = {}, viteOverrides = {}) {
|
|
70
69
|
const root = slash(resolve(options.root || process.cwd()));
|
|
71
70
|
const configPath = options.config === false ? false : options.config ? resolve(root, options.config) : await findUp(configFiles, { cwd: root });
|
|
72
71
|
options.config = configPath;
|
|
73
|
-
const vitest = new Vitest("test");
|
|
72
|
+
const vitest = new Vitest("test", deepClone(options));
|
|
74
73
|
const config = await resolveConfig$1(mergeConfig({
|
|
75
74
|
configFile: configPath,
|
|
76
75
|
mode: options.mode || "test",
|
|
77
76
|
plugins: [await VitestPlugin(options, vitest)]
|
|
78
77
|
}, mergeConfig(viteOverrides, { root: options.root })), "serve");
|
|
78
|
+
// Reflect just to avoid type error
|
|
79
79
|
const updatedOptions = Reflect.get(config, "_vitest");
|
|
80
80
|
const vitestConfig = resolveConfig$2(vitest, updatedOptions, config);
|
|
81
81
|
await vitest.close();
|
package/dist/reporters.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { aQ as BaseReporter, aC as BasicReporter, aR as BenchmarkBuiltinReporters, aD as BenchmarkReporter, aE as BenchmarkReportsMap, aS as BuiltinReporterOptions, aT as BuiltinReporters, aF as DefaultReporter, aG as DotReporter, aH as GithubActionsReporter, aI as HangingProcessReporter, aK as JUnitReporter, aU as JsonAssertionResult, aJ as JsonReporter, aV as JsonTestResult, aW as JsonTestResults, aA as ReportedHookContext, o as Reporter, aL as ReportersMap, aM as TapFlatReporter, aN as TapReporter, aB as TestRunEndReason, aO as VerboseBenchmarkReporter, aP as VerboseReporter } from './chunks/reporters.d.
|
|
1
|
+
export { aQ as BaseReporter, aC as BasicReporter, aR as BenchmarkBuiltinReporters, aD as BenchmarkReporter, aE as BenchmarkReportsMap, aS as BuiltinReporterOptions, aT as BuiltinReporters, aF as DefaultReporter, aG as DotReporter, aH as GithubActionsReporter, aI as HangingProcessReporter, aK as JUnitReporter, aU as JsonAssertionResult, aJ as JsonReporter, aV as JsonTestResult, aW as JsonTestResults, aA as ReportedHookContext, o as Reporter, aL as ReportersMap, aM as TapFlatReporter, aN as TapReporter, aB as TestRunEndReason, aO as VerboseBenchmarkReporter, aP as VerboseReporter } from './chunks/reporters.d.Bt4IGtsa.js';
|
|
2
2
|
import '@vitest/runner';
|
|
3
|
-
import './chunks/environment.d.
|
|
3
|
+
import './chunks/environment.d.cL3nLXbE.js';
|
|
4
4
|
import 'vitest/optional-types.js';
|
|
5
5
|
import '@vitest/utils';
|
|
6
6
|
import 'node:stream';
|
|
@@ -8,9 +8,9 @@ import 'vite';
|
|
|
8
8
|
import 'node:console';
|
|
9
9
|
import '@vitest/mocker';
|
|
10
10
|
import '@vitest/utils/source-map';
|
|
11
|
-
import './chunks/worker.d.
|
|
11
|
+
import './chunks/worker.d.BKbBp2ga.js';
|
|
12
12
|
import 'vite-node';
|
|
13
|
-
import './chunks/config.d.
|
|
13
|
+
import './chunks/config.d.D2ROskhv.js';
|
|
14
14
|
import '@vitest/pretty-format';
|
|
15
15
|
import '@vitest/snapshot';
|
|
16
16
|
import '@vitest/snapshot/environment';
|
package/dist/reporters.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
export { B as BasicReporter,
|
|
2
|
-
|
|
1
|
+
export { B as BasicReporter, 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.Bter3jj9.js';
|
|
2
|
+
export { B as BenchmarkReporter, a as BenchmarkReportsMap, V as VerboseBenchmarkReporter } from './chunks/index.JOzufsrU.js';
|
|
3
|
+
import 'node:perf_hooks';
|
|
3
4
|
import '@vitest/runner/utils';
|
|
4
|
-
import 'pathe';
|
|
5
|
-
import 'tinyrainbow';
|
|
6
|
-
import './chunks/utils.8gfOgtry.js';
|
|
7
|
-
import 'node:util';
|
|
8
5
|
import '@vitest/utils';
|
|
9
|
-
import 'node:perf_hooks';
|
|
10
6
|
import '@vitest/utils/source-map';
|
|
7
|
+
import 'pathe';
|
|
8
|
+
import 'tinyrainbow';
|
|
11
9
|
import './chunks/env.Dq0hM4Xv.js';
|
|
12
10
|
import 'std-env';
|
|
13
|
-
import './chunks/typechecker.
|
|
14
|
-
import 'node:fs/promises';
|
|
15
|
-
import 'tinyexec';
|
|
16
|
-
import 'vite';
|
|
11
|
+
import './chunks/typechecker.BgzF-6iO.js';
|
|
17
12
|
import 'node:os';
|
|
18
|
-
import '
|
|
13
|
+
import 'tinyexec';
|
|
14
|
+
import './path.js';
|
|
19
15
|
import 'node:path';
|
|
20
|
-
import 'node:
|
|
21
|
-
import '
|
|
16
|
+
import 'node:url';
|
|
17
|
+
import 'vite';
|
|
18
|
+
import 'node:util';
|
|
19
|
+
import 'node:fs';
|
|
20
|
+
import 'node:fs/promises';
|
|
22
21
|
import 'node:console';
|
|
23
22
|
import 'node:stream';
|
|
23
|
+
import 'node:module';
|
package/dist/runners.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as tinybench from 'tinybench';
|
|
2
2
|
import { VitestRunner, VitestRunnerImportSource, Suite, File, Task, CancelReason, TestContext } from '@vitest/runner';
|
|
3
3
|
export { VitestRunner } from '@vitest/runner';
|
|
4
|
-
import { a as SerializedConfig } from './chunks/config.d.
|
|
4
|
+
import { a as SerializedConfig } from './chunks/config.d.D2ROskhv.js';
|
|
5
5
|
import '@vitest/pretty-format';
|
|
6
6
|
import '@vitest/snapshot';
|
|
7
7
|
import '@vitest/snapshot/environment';
|
package/dist/runners.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { updateTask } from '@vitest/runner';
|
|
2
2
|
import { createDefer, getSafeTimers } from '@vitest/utils';
|
|
3
|
-
import { a as getBenchOptions, g as getBenchFn } from './chunks/benchmark.
|
|
4
|
-
import { g as getWorkerState } from './chunks/utils.
|
|
3
|
+
import { a as getBenchOptions, g as getBenchFn } from './chunks/benchmark.Cf_PACH1.js';
|
|
4
|
+
import { g as getWorkerState } from './chunks/utils.BlI4TC7Y.js';
|
|
5
5
|
import { setState, GLOBAL_EXPECT, getState } from '@vitest/expect';
|
|
6
6
|
import { getTests, getNames, getTestName } from '@vitest/runner/utils';
|
|
7
|
-
import { g as getSnapshotClient, i as inject, c as createExpect, v as vi } from './chunks/vi.
|
|
8
|
-
import { r as rpc } from './chunks/rpc.
|
|
7
|
+
import { g as getSnapshotClient, i as inject, c as createExpect, v as vi } from './chunks/vi.pkoYCV6A.js';
|
|
8
|
+
import { r as rpc } from './chunks/rpc.BKExFSRG.js';
|
|
9
9
|
import 'chai';
|
|
10
10
|
import './chunks/_commonjsHelpers.BFTU3MAI.js';
|
|
11
11
|
import '@vitest/snapshot';
|
|
12
12
|
import '@vitest/utils/error';
|
|
13
13
|
import '@vitest/spy';
|
|
14
14
|
import '@vitest/utils/source-map';
|
|
15
|
-
import './chunks/date.
|
|
15
|
+
import './chunks/date.ByMsSlOr.js';
|
|
16
16
|
import './chunks/index.CJ0plNrh.js';
|
|
17
17
|
|
|
18
18
|
function createBenchmarkResult(name) {
|
|
@@ -39,6 +39,7 @@ async function runBenchmarkSuite(suite, runner) {
|
|
|
39
39
|
benchmarkSuiteGroup.push(task);
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
|
+
// run sub suites sequentially
|
|
42
43
|
for (const subSuite of benchmarkSuiteGroup) {
|
|
43
44
|
await runBenchmarkSuite(subSuite, runner);
|
|
44
45
|
}
|
|
@@ -57,6 +58,7 @@ async function runBenchmarkSuite(suite, runner) {
|
|
|
57
58
|
const result = benchmark.result.benchmark;
|
|
58
59
|
benchmark.result.state = "pass";
|
|
59
60
|
Object.assign(result, taskRes);
|
|
61
|
+
// compute extra stats and free raw samples as early as possible
|
|
60
62
|
const samples = result.samples;
|
|
61
63
|
result.sampleCount = samples.length;
|
|
62
64
|
result.median = samples.length % 2 ? samples[Math.floor(samples.length / 2)] : (samples[samples.length / 2] + samples[samples.length / 2 - 1]) / 2;
|
|
@@ -153,6 +155,7 @@ class VitestTestRunner {
|
|
|
153
155
|
suite.result.heap = process.memoryUsage().heapUsed;
|
|
154
156
|
}
|
|
155
157
|
if (suite.mode !== "skip" && "filepath" in suite) {
|
|
158
|
+
// mark snapshots in skipped tests as not obsolete
|
|
156
159
|
for (const test of getTests(suite)) {
|
|
157
160
|
if (test.mode === "skip") {
|
|
158
161
|
const name = getNames(test).slice(1).join(" > ");
|
|
@@ -174,6 +177,8 @@ class VitestTestRunner {
|
|
|
174
177
|
this.cancelRun = true;
|
|
175
178
|
}
|
|
176
179
|
injectValue(key) {
|
|
180
|
+
// inject has a very limiting type controlled by ProvidedContext
|
|
181
|
+
// some tests override it which causes the build to fail
|
|
177
182
|
return inject(key);
|
|
178
183
|
}
|
|
179
184
|
async onBeforeRunTask(test) {
|
|
@@ -189,6 +194,7 @@ class VitestTestRunner {
|
|
|
189
194
|
if (this.cancelRun) {
|
|
190
195
|
suite.mode = "skip";
|
|
191
196
|
}
|
|
197
|
+
// initialize snapshot state before running file suite
|
|
192
198
|
if (suite.mode !== "skip" && "filepath" in suite) {
|
|
193
199
|
await this.snapshotClient.setup(suite.file.filepath, this.workerState.config.snapshotOptions);
|
|
194
200
|
}
|
|
@@ -220,6 +226,7 @@ class VitestTestRunner {
|
|
|
220
226
|
}
|
|
221
227
|
}
|
|
222
228
|
extendTaskContext(context) {
|
|
229
|
+
// create error during the test initialization so we have a nice stack trace
|
|
223
230
|
if (this.config.expect.requireAssertions) {
|
|
224
231
|
this.assertionsErrors.set(context.task, new Error("expected any number of assertion, but got none"));
|
|
225
232
|
}
|
|
@@ -238,6 +245,7 @@ class VitestTestRunner {
|
|
|
238
245
|
}
|
|
239
246
|
function clearModuleMocks(config) {
|
|
240
247
|
const { clearMocks, mockReset, restoreMocks, unstubEnvs, unstubGlobals } = config;
|
|
248
|
+
// since each function calls another, we can just call one
|
|
241
249
|
if (restoreMocks) {
|
|
242
250
|
vi.restoreAllMocks();
|
|
243
251
|
} else if (mockReset) {
|
package/dist/snapshot.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { VitestNodeSnapshotEnvironment as VitestSnapshotEnvironment } from './chunks/node.
|
|
1
|
+
export { VitestNodeSnapshotEnvironment as VitestSnapshotEnvironment } from './chunks/node.Be-ntJnD.js';
|
|
2
2
|
import '@vitest/snapshot/environment';
|
|
3
|
-
import './chunks/utils.
|
|
3
|
+
import './chunks/utils.BlI4TC7Y.js';
|
|
4
4
|
import '@vitest/utils';
|
package/dist/suite.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { g as getBenchFn, a as getBenchOptions } from './chunks/benchmark.
|
|
1
|
+
export { g as getBenchFn, a as getBenchOptions } from './chunks/benchmark.Cf_PACH1.js';
|
|
2
2
|
export { createTaskCollector, getCurrentSuite, getCurrentTest, getFn, getHooks, setFn, setHooks } from '@vitest/runner';
|
|
3
3
|
export { createChainable } from '@vitest/runner/utils';
|
|
4
4
|
import '@vitest/utils';
|
|
5
|
-
import './chunks/utils.
|
|
5
|
+
import './chunks/utils.BlI4TC7Y.js';
|
package/dist/worker.js
CHANGED
|
@@ -4,11 +4,11 @@ import { workerId } from 'tinypool';
|
|
|
4
4
|
import { ViteNodeRunner, ModuleCacheMap } from 'vite-node/client';
|
|
5
5
|
import { readFileSync } from 'node:fs';
|
|
6
6
|
import { resolve, normalize } from 'pathe';
|
|
7
|
-
import { e as environments } from './chunks/index.
|
|
8
|
-
import { s as setupInspect } from './chunks/inspector.
|
|
9
|
-
import { c as createRuntimeRpc, a as rpcDone } from './chunks/rpc.
|
|
10
|
-
import { i as isChildProcess, s as setProcessTitle } from './chunks/utils.
|
|
11
|
-
import { d as disposeInternalListeners } from './chunks/utils.
|
|
7
|
+
import { e as environments } from './chunks/index.2jgTs_Q5.js';
|
|
8
|
+
import { s as setupInspect } from './chunks/inspector.BFsh5KO0.js';
|
|
9
|
+
import { c as createRuntimeRpc, a as rpcDone } from './chunks/rpc.BKExFSRG.js';
|
|
10
|
+
import { i as isChildProcess, s as setProcessTitle } from './chunks/utils.BlI4TC7Y.js';
|
|
11
|
+
import { d as disposeInternalListeners } from './chunks/utils.DPCq3gzW.js';
|
|
12
12
|
import 'node:console';
|
|
13
13
|
import 'node:module';
|
|
14
14
|
import '@vitest/utils';
|
|
@@ -59,11 +59,13 @@ if (isChildProcess()) {
|
|
|
59
59
|
setProcessTitle(`vitest ${workerId}`);
|
|
60
60
|
const isProfiling = process.execArgv.some((execArg) => execArg.startsWith("--prof") || execArg.startsWith("--cpu-prof") || execArg.startsWith("--heap-prof") || execArg.startsWith("--diagnostic-dir"));
|
|
61
61
|
if (isProfiling) {
|
|
62
|
+
// Work-around for nodejs/node#55094
|
|
62
63
|
process.on("SIGTERM", () => {
|
|
63
64
|
process.exit();
|
|
64
65
|
});
|
|
65
66
|
}
|
|
66
67
|
}
|
|
68
|
+
// this is what every pool executes when running tests
|
|
67
69
|
async function execute(method, ctx) {
|
|
68
70
|
disposeInternalListeners();
|
|
69
71
|
const prepareStart = performance.now();
|
|
@@ -71,6 +73,7 @@ async function execute(method, ctx) {
|
|
|
71
73
|
process.env.VITEST_WORKER_ID = String(ctx.workerId);
|
|
72
74
|
process.env.VITEST_POOL_ID = String(workerId);
|
|
73
75
|
try {
|
|
76
|
+
// worker is a filepath or URL to a file that exposes a default export with "getRpcOptions" and "runTests" methods
|
|
74
77
|
if (ctx.worker[0] === ".") {
|
|
75
78
|
throw new Error(`Path to the test runner cannot be relative, received "${ctx.worker}"`);
|
|
76
79
|
}
|
|
@@ -83,6 +86,7 @@ async function execute(method, ctx) {
|
|
|
83
86
|
if (!worker.getRpcOptions || typeof worker.getRpcOptions !== "function") {
|
|
84
87
|
throw new TypeError(`Test worker should expose "getRpcOptions" method. Received "${typeof worker.getRpcOptions}".`);
|
|
85
88
|
}
|
|
89
|
+
// RPC is used to communicate between worker (be it a thread worker or child process or a custom implementation) and the main thread
|
|
86
90
|
const { rpc, onCancel } = createRuntimeRpc(worker.getRpcOptions(ctx));
|
|
87
91
|
const beforeEnvironmentTime = performance.now();
|
|
88
92
|
const environment = await loadEnvironment(ctx, rpc);
|
package/dist/workers/forks.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import v8 from 'node:v8';
|
|
2
|
-
import { r as runBaseTests } from '../chunks/base.
|
|
3
|
-
import { c as createForksRpcOptions, u as unwrapSerializableConfig } from '../chunks/utils.
|
|
2
|
+
import { r as runBaseTests } from '../chunks/base.D4119yLM.js';
|
|
3
|
+
import { c as createForksRpcOptions, u as unwrapSerializableConfig } from '../chunks/utils.DPCq3gzW.js';
|
|
4
4
|
import 'vite-node/client';
|
|
5
|
-
import '../chunks/execute.
|
|
5
|
+
import '../chunks/execute.B3q-2LPV.js';
|
|
6
6
|
import 'node:fs';
|
|
7
7
|
import 'node:url';
|
|
8
8
|
import 'node:vm';
|
|
@@ -14,13 +14,15 @@ import 'node:path';
|
|
|
14
14
|
import '@vitest/mocker';
|
|
15
15
|
import 'node:module';
|
|
16
16
|
import '@vitest/utils';
|
|
17
|
-
import '../chunks/utils.
|
|
17
|
+
import '../chunks/utils.BlI4TC7Y.js';
|
|
18
18
|
|
|
19
19
|
class ForksBaseWorker {
|
|
20
20
|
getRpcOptions() {
|
|
21
21
|
return createForksRpcOptions(v8);
|
|
22
22
|
}
|
|
23
23
|
async executeTests(method, state) {
|
|
24
|
+
// TODO: don't rely on reassigning process.exit
|
|
25
|
+
// https://github.com/vitest-dev/vitest/pull/4441#discussion_r1443771486
|
|
24
26
|
const exit = process.exit;
|
|
25
27
|
state.ctx.config = unwrapSerializableConfig(state.ctx.config);
|
|
26
28
|
try {
|