vitest 1.2.2 → 1.3.0
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 +29 -0
- package/dist/browser.d.ts +3 -2
- package/dist/browser.js +2 -1
- package/dist/chunks/{api-setup.srzH0bDf.js → api-setup.Xh60JpeM.js} +27 -64
- package/dist/chunks/{integrations-globals.J_6tnlri.js → integrations-globals.FlQVNhQx.js} +6 -6
- package/dist/chunks/{runtime-runBaseTests.QReNMrJA.js → runtime-runBaseTests.0UwIvo_U.js} +9 -9
- package/dist/cli-wrapper.js +1 -1
- package/dist/cli.js +1314 -69
- package/dist/config.cjs +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/coverage.d.ts +3 -3
- package/dist/environments.d.ts +1 -1
- package/dist/environments.js +1 -1
- package/dist/execute.d.ts +1 -1
- package/dist/execute.js +2 -2
- package/dist/index.d.ts +74 -78
- package/dist/index.js +7 -7
- package/dist/node.d.ts +3 -3
- package/dist/node.js +21 -21
- package/dist/{reporters-1evA5lom.d.ts → reporters-QGe8gs4b.d.ts} +146 -55
- package/dist/reporters.d.ts +1 -1
- package/dist/reporters.js +20 -6
- package/dist/runners.d.ts +6 -6
- package/dist/runners.js +10 -10
- package/dist/{suite-ghspeorC.d.ts → suite-xGC-mxBC.d.ts} +1 -1
- package/dist/suite.d.ts +2 -2
- package/dist/suite.js +2 -2
- package/dist/vendor/{base.Rmxiv35Y.js → base.RpormaJz.js} +2 -2
- package/dist/vendor/{base.QYERqzkH.js → base.knFzp7G3.js} +1 -1
- package/dist/vendor/{benchmark.IlKmJkUU.js → benchmark.eeqk2rd8.js} +1 -1
- package/dist/vendor/{node.Zme77R4t.js → cli-api.RIYLcWhB.js} +1510 -3639
- package/dist/vendor/{constants.i1PoEnhr.js → constants.K-Wf1PUy.js} +3 -1
- package/dist/vendor/{execute.TxmaEFIQ.js → execute.aFSzc0Da.js} +23 -12
- package/dist/vendor/{index.cAUulNDf.js → index.8bPxjt7g.js} +6 -1
- package/dist/vendor/{index.RDKo8czB.js → index.CKbXK54q.js} +7 -3
- package/dist/vendor/{environments.sU0TD7wX.js → index.GVFv9dZ0.js} +3 -0
- package/dist/vendor/index.QcWmThJv.js +4927 -0
- package/dist/vendor/{index.rJjbcrrp.js → index.ir9i0ywP.js} +1 -1
- package/dist/vendor/{index.LgG0iblq.js → index.n-Ib4UWN.js} +4 -3
- package/dist/vendor/{rpc.w4v8oCkK.js → rpc.joBhAkyK.js} +10 -1
- package/dist/vendor/setup-common.NSpEdAQm.js +45 -0
- package/dist/vendor/{vi.PPwhENHF.js → vi.-Nr_x6dl.js} +2 -1
- package/dist/vendor/{vm.jVxKtN5R.js → vm.UmCkcXp-.js} +25 -8
- package/dist/worker.js +5 -10
- package/dist/workers/forks.js +3 -3
- package/dist/workers/runVmTests.js +13 -9
- package/dist/workers/threads.js +3 -3
- package/dist/workers/vmForks.js +4 -4
- package/dist/workers/vmThreads.js +4 -4
- package/dist/workers.d.ts +3 -3
- package/dist/workers.js +8 -8
- package/globals.d.ts +2 -0
- package/jsdom.d.ts +6 -0
- package/package.json +24 -21
- package/dist/vendor/reporters.cA9x-5v-.js +0 -2664
- package/dist/vendor/setup-common.C2iBd0K0.js +0 -29
package/dist/config.cjs
CHANGED
package/dist/config.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { ConfigEnv, UserConfig, mergeConfig } from 'vite';
|
|
2
|
-
export { aw as UserConfigExport, av as UserConfigFn, at as UserConfigFnObject, au as UserConfigFnPromise, ay as UserProjectConfigExport, ax as UserProjectConfigFn, a0 as UserWorkspaceConfig, aC as configDefaults, aF as coverageConfigDefaults, aE as defaultExclude, aD as defaultInclude, az as defineConfig, aA as defineProject, aB as defineWorkspace, aG as extraInlineDeps } from './reporters-
|
|
2
|
+
export { aw as UserConfigExport, av as UserConfigFn, at as UserConfigFnObject, au as UserConfigFnPromise, ay as UserProjectConfigExport, ax as UserProjectConfigFn, a0 as UserWorkspaceConfig, aC as configDefaults, aF as coverageConfigDefaults, aE as defaultExclude, aD as defaultInclude, az as defineConfig, aA as defineProject, aB as defineWorkspace, aG as extraInlineDeps } from './reporters-QGe8gs4b.js';
|
|
3
3
|
import '@vitest/runner';
|
|
4
4
|
import 'vite-node';
|
|
5
5
|
import '@vitest/snapshot';
|
package/dist/coverage.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as BaseCoverageOptions, a as ResolvedCoverageOptions } from './reporters-
|
|
1
|
+
import { B as BaseCoverageOptions, a as ResolvedCoverageOptions } from './reporters-QGe8gs4b.js';
|
|
2
2
|
import 'vite';
|
|
3
3
|
import '@vitest/runner';
|
|
4
4
|
import 'vite-node';
|
|
@@ -132,8 +132,8 @@ declare class BaseCoverageProvider {
|
|
|
132
132
|
thresholds: ResolvedThreshold[];
|
|
133
133
|
perFile?: boolean;
|
|
134
134
|
configurationFile: {
|
|
135
|
-
read()
|
|
136
|
-
write()
|
|
135
|
+
read: () => unknown;
|
|
136
|
+
write: () => void;
|
|
137
137
|
};
|
|
138
138
|
}): void;
|
|
139
139
|
/**
|
package/dist/environments.d.ts
CHANGED
package/dist/environments.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { e as builtinEnvironments, p as populateGlobal } from './vendor/
|
|
1
|
+
export { e as builtinEnvironments, p as populateGlobal } from './vendor/index.GVFv9dZ0.js';
|
|
2
2
|
import 'node:console';
|
package/dist/execute.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import vm from 'node:vm';
|
|
2
2
|
import { ViteNodeRunner } from 'vite-node/client';
|
|
3
3
|
import { ViteNodeRunnerOptions } from 'vite-node';
|
|
4
|
-
import { aq as PendingSuiteMock, ar as MockFactory, f as RuntimeRPC, p as WorkerGlobalState, as as MockMap } from './reporters-
|
|
4
|
+
import { aq as PendingSuiteMock, ar as MockFactory, f as RuntimeRPC, p as WorkerGlobalState, as as MockMap } from './reporters-QGe8gs4b.js';
|
|
5
5
|
import 'vite';
|
|
6
6
|
import '@vitest/runner';
|
|
7
7
|
import '@vitest/snapshot';
|
package/dist/execute.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { V as VitestExecutor } from './vendor/execute.
|
|
1
|
+
export { V as VitestExecutor } from './vendor/execute.aFSzc0Da.js';
|
|
2
2
|
import 'node:vm';
|
|
3
3
|
import 'node:url';
|
|
4
4
|
import 'vite-node/client';
|
|
@@ -8,4 +8,4 @@ import '@vitest/utils/error';
|
|
|
8
8
|
import './path.js';
|
|
9
9
|
import 'node:fs';
|
|
10
10
|
import '@vitest/utils';
|
|
11
|
-
import './vendor/base.
|
|
11
|
+
import './vendor/base.knFzp7G3.js';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { TaskPopulated, File, TaskResultPack, CancelReason } from '@vitest/runner';
|
|
2
|
-
export { Custom, DoneCallback, ExtendedContext, File, HookCleanupCallback, HookListener, OnTestFailedHandler, RunMode, RuntimeContext, SequenceHooks, SequenceSetupFiles, Suite, SuiteAPI, SuiteCollector, SuiteFactory, SuiteHooks, Task, TaskBase, TaskContext, TaskCustomOptions, TaskMeta, TaskResult, TaskResultPack, TaskState, Test, TestAPI, TestContext, TestFunction, TestOptions, afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, suite, test } from '@vitest/runner';
|
|
3
|
-
export { b as bench } from './suite-
|
|
2
|
+
export { Custom, DoneCallback, ExtendedContext, File, HookCleanupCallback, HookListener, OnTestFailedHandler, RunMode, RuntimeContext, SequenceHooks, SequenceSetupFiles, Suite, SuiteAPI, SuiteCollector, SuiteFactory, SuiteHooks, Task, TaskBase, TaskContext, TaskCustomOptions, TaskMeta, TaskResult, TaskResultPack, TaskState, Test, TestAPI, TestContext, TestFunction, TestOptions, afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, onTestFinished, suite, test } from '@vitest/runner';
|
|
3
|
+
export { b as bench } from './suite-xGC-mxBC.js';
|
|
4
4
|
import { ExpectStatic } from '@vitest/expect';
|
|
5
5
|
export { Assertion, AsymmetricMatchersContaining, ExpectStatic, JestAssertion } from '@vitest/expect';
|
|
6
|
-
import { F as FakeTimerInstallOpts, M as MockFactoryWithHelper, r as RuntimeConfig, P as ProvidedContext, A as AfterSuiteRunMeta, t as UserConsoleLog, R as ResolvedConfig, u as ModuleGraphData, v as Reporter } from './reporters-
|
|
7
|
-
export { Q as ApiConfig, a9 as ArgumentsType, a8 as Arrayable, a6 as Awaitable, B as BaseCoverageOptions, ao as BenchFunction, am as Benchmark, ap as BenchmarkAPI, an as BenchmarkResult, al as BenchmarkUserOptions, L as BuiltinEnvironment, O as CSSModuleScopeStrategy, y as CollectLineNumbers, z as CollectLines, ab as Constructable, G as Context, o as ContextRPC, a2 as ContextTestEnvironment, ai as CoverageIstanbulOptions, C as CoverageOptions, b as CoverageProvider, c as CoverageProviderModule, ah as CoverageReporter, aj as CoverageV8Options, ak as CustomProviderOptions, X as DepsOptimizationOptions, E as Environment, S as EnvironmentOptions, ad as EnvironmentReturn, K as HappyDOMOptions, Z as InlineConfig, J as JSDOMOptions, ac as ModuleCache, aa as MutableArray, a7 as Nullable, af as OnServerRestartHandler, H as Pool, I as PoolOptions, $ as ProjectConfig, w as RawErrsMap, ag as ReportContext, a4 as ResolveIdFunction, a as ResolvedCoverageOptions, a3 as ResolvedTestEnvironment, D as RootAndTarget, a1 as RunnerRPC, f as RuntimeRPC, Y as TransformModePatterns, x as TscErrorInfo, _ as TypecheckConfig, U as UserConfig, a0 as UserWorkspaceConfig, e as Vitest, N as VitestEnvironment, V as VitestRunMode, ae as VmEnvironmentReturn, q as WorkerContext, p as WorkerGlobalState, a5 as WorkerRPC } from './reporters-
|
|
6
|
+
import { F as FakeTimerInstallOpts, M as MockFactoryWithHelper, r as RuntimeConfig, P as ProvidedContext, A as AfterSuiteRunMeta, t as UserConsoleLog, R as ResolvedConfig, u as ModuleGraphData, v as Reporter } from './reporters-QGe8gs4b.js';
|
|
7
|
+
export { Q as ApiConfig, a9 as ArgumentsType, a8 as Arrayable, a6 as Awaitable, B as BaseCoverageOptions, ao as BenchFunction, am as Benchmark, ap as BenchmarkAPI, an as BenchmarkResult, al as BenchmarkUserOptions, L as BuiltinEnvironment, O as CSSModuleScopeStrategy, y as CollectLineNumbers, z as CollectLines, ab as Constructable, G as Context, o as ContextRPC, a2 as ContextTestEnvironment, ai as CoverageIstanbulOptions, C as CoverageOptions, b as CoverageProvider, c as CoverageProviderModule, ah as CoverageReporter, aj as CoverageV8Options, ak as CustomProviderOptions, X as DepsOptimizationOptions, E as Environment, S as EnvironmentOptions, ad as EnvironmentReturn, K as HappyDOMOptions, Z as InlineConfig, J as JSDOMOptions, ac as ModuleCache, aa as MutableArray, a7 as Nullable, af as OnServerRestartHandler, H as Pool, I as PoolOptions, $ as ProjectConfig, w as RawErrsMap, ag as ReportContext, a4 as ResolveIdFunction, a as ResolvedCoverageOptions, a3 as ResolvedTestEnvironment, D as RootAndTarget, a1 as RunnerRPC, f as RuntimeRPC, Y as TransformModePatterns, x as TscErrorInfo, _ as TypecheckConfig, U as UserConfig, a0 as UserWorkspaceConfig, e as Vitest, N as VitestEnvironment, V as VitestRunMode, ae as VmEnvironmentReturn, q as WorkerContext, p as WorkerGlobalState, a5 as WorkerRPC } from './reporters-QGe8gs4b.js';
|
|
8
8
|
import { spyOn, fn, MaybeMockedDeep, MaybeMocked, MaybePartiallyMocked, MaybePartiallyMockedDeep, MockInstance } from '@vitest/spy';
|
|
9
9
|
export { Mock, MockContext, MockInstance, Mocked, MockedClass, MockedFunction, MockedObject, SpyInstance } from '@vitest/spy';
|
|
10
10
|
export { SnapshotEnvironment } from '@vitest/snapshot/environment';
|
|
11
11
|
import { SnapshotResult } from '@vitest/snapshot';
|
|
12
|
-
export { SnapshotData, SnapshotMatchOptions, SnapshotResult, SnapshotStateOptions, SnapshotSummary, SnapshotUpdateState, UncheckedSnapshot } from '@vitest/snapshot';
|
|
12
|
+
export { SnapshotData, SnapshotMatchOptions, SnapshotResult, SnapshotSerializer, SnapshotStateOptions, SnapshotSummary, SnapshotUpdateState, UncheckedSnapshot } from '@vitest/snapshot';
|
|
13
13
|
export { DiffOptions } from '@vitest/utils/diff';
|
|
14
14
|
import { TransformResult } from 'vite';
|
|
15
15
|
import * as chai from 'chai';
|
|
@@ -358,76 +358,76 @@ interface VitestUtils {
|
|
|
358
358
|
/**
|
|
359
359
|
* Checks if fake timers are enabled.
|
|
360
360
|
*/
|
|
361
|
-
isFakeTimers()
|
|
361
|
+
isFakeTimers: () => boolean;
|
|
362
362
|
/**
|
|
363
363
|
* This method wraps all further calls to timers until [`vi.useRealTimers()`](https://vitest.dev/api/vi#vi-userealtimers) is called.
|
|
364
364
|
*/
|
|
365
|
-
useFakeTimers(config?: FakeTimerInstallOpts)
|
|
365
|
+
useFakeTimers: (config?: FakeTimerInstallOpts) => VitestUtils;
|
|
366
366
|
/**
|
|
367
367
|
* Restores mocked timers to their original implementations. All timers that were scheduled before will be discarded.
|
|
368
368
|
*/
|
|
369
|
-
useRealTimers()
|
|
369
|
+
useRealTimers: () => VitestUtils;
|
|
370
370
|
/**
|
|
371
371
|
* This method will call every timer that was initiated after [`vi.useFakeTimers`](https://vitest.dev/api/vi#vi-usefaketimers) call.
|
|
372
372
|
* It will not fire any timer that was initiated during its call.
|
|
373
373
|
*/
|
|
374
|
-
runOnlyPendingTimers()
|
|
374
|
+
runOnlyPendingTimers: () => VitestUtils;
|
|
375
375
|
/**
|
|
376
376
|
* This method will asynchronously call every timer that was initiated after [`vi.useFakeTimers`](https://vitest.dev/api/vi#vi-usefaketimers) call, even asynchronous ones.
|
|
377
377
|
* It will not fire any timer that was initiated during its call.
|
|
378
378
|
*/
|
|
379
|
-
runOnlyPendingTimersAsync()
|
|
379
|
+
runOnlyPendingTimersAsync: () => Promise<VitestUtils>;
|
|
380
380
|
/**
|
|
381
381
|
* This method will invoke every initiated timer until the timer queue is empty. It means that every timer called during `runAllTimers` will be fired.
|
|
382
382
|
* If you have an infinite interval, it will throw after 10,000 tries (can be configured with [`fakeTimers.loopLimit`](https://vitest.dev/config/#faketimers-looplimit)).
|
|
383
383
|
*/
|
|
384
|
-
runAllTimers()
|
|
384
|
+
runAllTimers: () => VitestUtils;
|
|
385
385
|
/**
|
|
386
386
|
* This method will asynchronously invoke every initiated timer until the timer queue is empty. It means that every timer called during `runAllTimersAsync` will be fired even asynchronous timers.
|
|
387
387
|
* If you have an infinite interval, it will throw after 10 000 tries (can be configured with [`fakeTimers.loopLimit`](https://vitest.dev/config/#faketimers-looplimit)).
|
|
388
388
|
*/
|
|
389
|
-
runAllTimersAsync()
|
|
389
|
+
runAllTimersAsync: () => Promise<VitestUtils>;
|
|
390
390
|
/**
|
|
391
391
|
* Calls every microtask that was queued by `process.nextTick`. This will also run all microtasks scheduled by themselves.
|
|
392
392
|
*/
|
|
393
|
-
runAllTicks()
|
|
393
|
+
runAllTicks: () => VitestUtils;
|
|
394
394
|
/**
|
|
395
395
|
* This method will invoke every initiated timer until the specified number of milliseconds is passed or the queue is empty - whatever comes first.
|
|
396
396
|
*/
|
|
397
|
-
advanceTimersByTime(ms: number)
|
|
397
|
+
advanceTimersByTime: (ms: number) => VitestUtils;
|
|
398
398
|
/**
|
|
399
399
|
* This method will invoke every initiated timer until the specified number of milliseconds is passed or the queue is empty - whatever comes first. This will include and await asynchronously set timers.
|
|
400
400
|
*/
|
|
401
|
-
advanceTimersByTimeAsync(ms: number)
|
|
401
|
+
advanceTimersByTimeAsync: (ms: number) => Promise<VitestUtils>;
|
|
402
402
|
/**
|
|
403
403
|
* Will call next available timer. Useful to make assertions between each timer call. You can chain call it to manage timers by yourself.
|
|
404
404
|
*/
|
|
405
|
-
advanceTimersToNextTimer()
|
|
405
|
+
advanceTimersToNextTimer: () => VitestUtils;
|
|
406
406
|
/**
|
|
407
407
|
* Will call next available timer and wait until it's resolved if it was set asynchronously. Useful to make assertions between each timer call.
|
|
408
408
|
*/
|
|
409
|
-
advanceTimersToNextTimerAsync()
|
|
409
|
+
advanceTimersToNextTimerAsync: () => Promise<VitestUtils>;
|
|
410
410
|
/**
|
|
411
411
|
* Get the number of waiting timers.
|
|
412
412
|
*/
|
|
413
|
-
getTimerCount()
|
|
413
|
+
getTimerCount: () => number;
|
|
414
414
|
/**
|
|
415
415
|
* If fake timers are enabled, this method simulates a user changing the system clock (will affect date related API like `hrtime`, `performance.now` or `new Date()`) - however, it will not fire any timers.
|
|
416
416
|
* If fake timers are not enabled, this method will only mock `Date.*` and `new Date()` calls.
|
|
417
417
|
*/
|
|
418
|
-
setSystemTime(time: number | string | Date)
|
|
418
|
+
setSystemTime: (time: number | string | Date) => VitestUtils;
|
|
419
419
|
/**
|
|
420
420
|
* Returns mocked current date that was set using `setSystemTime`. If date is not mocked the method will return `null`.
|
|
421
421
|
*/
|
|
422
|
-
getMockedSystemTime()
|
|
422
|
+
getMockedSystemTime: () => Date | null;
|
|
423
423
|
/**
|
|
424
424
|
* When using `vi.useFakeTimers`, `Date.now` calls are mocked. If you need to get real time in milliseconds, you can call this function.
|
|
425
425
|
*/
|
|
426
|
-
getRealSystemTime()
|
|
426
|
+
getRealSystemTime: () => number;
|
|
427
427
|
/**
|
|
428
428
|
* Removes all timers that are scheduled to run. These timers will never run in the future.
|
|
429
429
|
*/
|
|
430
|
-
clearAllTimers()
|
|
430
|
+
clearAllTimers: () => VitestUtils;
|
|
431
431
|
/**
|
|
432
432
|
* Creates a spy on a method or getter/setter of an object similar to [`vi.fn()`](https://vitest.dev/api/vi#vi-fn). It returns a [mock function](https://vitest.dev/api/mock).
|
|
433
433
|
*
|
|
@@ -507,7 +507,7 @@ interface VitestUtils {
|
|
|
507
507
|
*
|
|
508
508
|
* If used with [`vi.mock`](https://vitest.dev/api/vi#vi-mock), both will be hoisted in the order they are defined in.
|
|
509
509
|
*/
|
|
510
|
-
hoisted<T>(factory: () => T)
|
|
510
|
+
hoisted: <T>(factory: () => T) => T;
|
|
511
511
|
/**
|
|
512
512
|
* Mocks every import call to the module even if it was already statically imported.
|
|
513
513
|
*
|
|
@@ -518,14 +518,14 @@ interface VitestUtils {
|
|
|
518
518
|
* @param path Path to the module. Can be aliased, if your Vitest config supports it
|
|
519
519
|
* @param factory Mocked module factory. The result of this function will be an exports object
|
|
520
520
|
*/
|
|
521
|
-
mock(path: string, factory?: MockFactoryWithHelper)
|
|
521
|
+
mock: (path: string, factory?: MockFactoryWithHelper) => void;
|
|
522
522
|
/**
|
|
523
523
|
* Removes module from mocked registry. All calls to import will return the original module even if it was mocked before.
|
|
524
524
|
*
|
|
525
525
|
* This call is hoisted to the top of the file, so it will only unmock modules that were defined in `setupFiles`, for example.
|
|
526
526
|
* @param path Path to the module. Can be aliased, if your Vitest config supports it
|
|
527
527
|
*/
|
|
528
|
-
unmock(path: string)
|
|
528
|
+
unmock: (path: string) => void;
|
|
529
529
|
/**
|
|
530
530
|
* Mocks every subsequent [dynamic import](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import) call.
|
|
531
531
|
*
|
|
@@ -535,14 +535,14 @@ interface VitestUtils {
|
|
|
535
535
|
* @param path Path to the module. Can be aliased, if your Vitest config supports it
|
|
536
536
|
* @param factory Mocked module factory. The result of this function will be an exports object
|
|
537
537
|
*/
|
|
538
|
-
doMock(path: string, factory?: MockFactoryWithHelper)
|
|
538
|
+
doMock: (path: string, factory?: MockFactoryWithHelper) => void;
|
|
539
539
|
/**
|
|
540
540
|
* Removes module from mocked registry. All subsequent calls to import will return original module.
|
|
541
541
|
*
|
|
542
542
|
* Unlike [`vi.unmock`](https://vitest.dev/api/vi#vi-unmock), this method is not hoisted to the top of the file.
|
|
543
543
|
* @param path Path to the module. Can be aliased, if your Vitest config supports it
|
|
544
544
|
*/
|
|
545
|
-
doUnmock(path: string)
|
|
545
|
+
doUnmock: (path: string) => void;
|
|
546
546
|
/**
|
|
547
547
|
* Imports module, bypassing all checks if it should be mocked.
|
|
548
548
|
* Can be useful if you want to mock module partially.
|
|
@@ -554,7 +554,7 @@ interface VitestUtils {
|
|
|
554
554
|
* })
|
|
555
555
|
* @param path Path to the module. Can be aliased, if your config supports it
|
|
556
556
|
*/
|
|
557
|
-
importActual<T = ESModuleExports>(path: string)
|
|
557
|
+
importActual: <T = ESModuleExports>(path: string) => Promise<T>;
|
|
558
558
|
/**
|
|
559
559
|
* Imports a module with all of its properties and nested properties mocked.
|
|
560
560
|
*
|
|
@@ -566,7 +566,7 @@ interface VitestUtils {
|
|
|
566
566
|
* @param path Path to the module. Can be aliased, if your config supports it
|
|
567
567
|
* @returns Fully mocked module
|
|
568
568
|
*/
|
|
569
|
-
importMock<T = ESModuleExports>(path: string)
|
|
569
|
+
importMock: <T = ESModuleExports>(path: string) => Promise<MaybeMockedDeep<T>>;
|
|
570
570
|
/**
|
|
571
571
|
* Type helper for TypeScript. Just returns the object that was passed.
|
|
572
572
|
*
|
|
@@ -584,85 +584,79 @@ interface VitestUtils {
|
|
|
584
584
|
* @param deep If the object is deeply mocked
|
|
585
585
|
* @param options If the object is partially or deeply mocked
|
|
586
586
|
*/
|
|
587
|
-
mocked<T>(item: T, deep?: false)
|
|
588
|
-
mocked<T>(item: T, deep: true): MaybeMockedDeep<T>;
|
|
589
|
-
mocked<T>(item: T, options: {
|
|
587
|
+
mocked: (<T>(item: T, deep?: false) => MaybeMocked<T>) & (<T>(item: T, deep: true) => MaybeMockedDeep<T>) & (<T>(item: T, options: {
|
|
590
588
|
partial?: false;
|
|
591
589
|
deep?: false;
|
|
592
|
-
})
|
|
593
|
-
mocked<T>(item: T, options: {
|
|
590
|
+
}) => MaybeMocked<T>) & (<T>(item: T, options: {
|
|
594
591
|
partial?: false;
|
|
595
592
|
deep: true;
|
|
596
|
-
})
|
|
597
|
-
mocked<T>(item: T, options: {
|
|
593
|
+
}) => MaybeMockedDeep<T>) & (<T>(item: T, options: {
|
|
598
594
|
partial: true;
|
|
599
595
|
deep?: false;
|
|
600
|
-
})
|
|
601
|
-
mocked<T>(item: T, options: {
|
|
596
|
+
}) => MaybePartiallyMocked<T>) & (<T>(item: T, options: {
|
|
602
597
|
partial: true;
|
|
603
598
|
deep: true;
|
|
604
|
-
})
|
|
605
|
-
mocked<T>(item: T): MaybeMocked<T>;
|
|
599
|
+
}) => MaybePartiallyMockedDeep<T>) & (<T>(item: T) => MaybeMocked<T>);
|
|
606
600
|
/**
|
|
607
601
|
* Checks that a given parameter is a mock function. If you are using TypeScript, it will also narrow down its type.
|
|
608
602
|
*/
|
|
609
|
-
isMockFunction(fn: any)
|
|
603
|
+
isMockFunction: (fn: any) => fn is MockInstance;
|
|
610
604
|
/**
|
|
611
605
|
* Calls [`.mockClear()`](https://vitest.dev/api/mock#mockclear) on every mocked function. This will only empty `.mock` state, it will not reset implementation.
|
|
612
606
|
*
|
|
613
607
|
* It is useful if you need to clean up mock between different assertions.
|
|
614
608
|
*/
|
|
615
|
-
clearAllMocks()
|
|
609
|
+
clearAllMocks: () => VitestUtils;
|
|
616
610
|
/**
|
|
617
611
|
* Calls [`.mockReset()`](https://vitest.dev/api/mock#mockreset) on every mocked function. This will empty `.mock` state, reset "once" implementations and force the base implementation to return `undefined` when invoked.
|
|
618
612
|
*
|
|
619
613
|
* This is useful when you want to completely reset a mock to the default state.
|
|
620
614
|
*/
|
|
621
|
-
resetAllMocks()
|
|
615
|
+
resetAllMocks: () => VitestUtils;
|
|
622
616
|
/**
|
|
623
617
|
* Calls [`.mockRestore()`](https://vitest.dev/api/mock#mockrestore) on every mocked function. This will restore all original implementations.
|
|
624
618
|
*/
|
|
625
|
-
restoreAllMocks()
|
|
619
|
+
restoreAllMocks: () => VitestUtils;
|
|
626
620
|
/**
|
|
627
621
|
* Makes value available on global namespace.
|
|
628
622
|
* Useful, if you want to have global variables available, like `IntersectionObserver`.
|
|
629
623
|
* You can return it back to original value with `vi.unstubAllGlobals`, or by enabling `unstubGlobals` config option.
|
|
630
624
|
*/
|
|
631
|
-
stubGlobal(name: string | symbol | number, value: unknown)
|
|
625
|
+
stubGlobal: (name: string | symbol | number, value: unknown) => VitestUtils;
|
|
632
626
|
/**
|
|
633
627
|
* Changes the value of `import.meta.env` and `process.env`.
|
|
634
628
|
* You can return it back to original value with `vi.unstubAllEnvs`, or by enabling `unstubEnvs` config option.
|
|
635
629
|
*/
|
|
636
|
-
stubEnv(name: string, value: string)
|
|
630
|
+
stubEnv: (name: string, value: string) => VitestUtils;
|
|
637
631
|
/**
|
|
638
632
|
* Reset the value to original value that was available before first `vi.stubGlobal` was called.
|
|
639
633
|
*/
|
|
640
|
-
unstubAllGlobals()
|
|
634
|
+
unstubAllGlobals: () => VitestUtils;
|
|
641
635
|
/**
|
|
642
636
|
* Reset environmental variables to the ones that were available before first `vi.stubEnv` was called.
|
|
643
637
|
*/
|
|
644
|
-
unstubAllEnvs()
|
|
638
|
+
unstubAllEnvs: () => VitestUtils;
|
|
645
639
|
/**
|
|
646
640
|
* Resets modules registry by clearing the cache of all modules. This allows modules to be reevaluated when reimported.
|
|
647
641
|
* Top-level imports cannot be re-evaluated. Might be useful to isolate modules where local state conflicts between tests.
|
|
648
642
|
*
|
|
649
643
|
* This method does not reset mocks registry. To clear mocks registry, use [`vi.unmock`](https://vitest.dev/api/vi#vi-unmock) or [`vi.doUnmock`](https://vitest.dev/api/vi#vi-dounmock).
|
|
650
644
|
*/
|
|
651
|
-
resetModules()
|
|
645
|
+
resetModules: () => VitestUtils;
|
|
652
646
|
/**
|
|
653
647
|
* Wait for all imports to load. Useful, if you have a synchronous call that starts
|
|
654
648
|
* importing a module that you cannot await otherwise.
|
|
655
649
|
* Will also wait for new imports, started during the wait.
|
|
656
650
|
*/
|
|
657
|
-
dynamicImportSettled()
|
|
651
|
+
dynamicImportSettled: () => Promise<void>;
|
|
658
652
|
/**
|
|
659
653
|
* Updates runtime config. You can only change values that are used when executing tests.
|
|
660
654
|
*/
|
|
661
|
-
setConfig(config: RuntimeConfig)
|
|
655
|
+
setConfig: (config: RuntimeConfig) => void;
|
|
662
656
|
/**
|
|
663
657
|
* If config was changed with `vi.setConfig`, this will reset it to the original state.
|
|
664
658
|
*/
|
|
665
|
-
resetConfig()
|
|
659
|
+
resetConfig: () => void;
|
|
666
660
|
}
|
|
667
661
|
declare const vitest: VitestUtils;
|
|
668
662
|
declare const vi: VitestUtils;
|
|
@@ -680,34 +674,36 @@ interface TransformResultWithSource extends TransformResult {
|
|
|
680
674
|
source?: string;
|
|
681
675
|
}
|
|
682
676
|
interface WebSocketHandlers {
|
|
683
|
-
onUnhandledError(error: unknown, type: string)
|
|
684
|
-
onCollected(files?: File[])
|
|
685
|
-
onTaskUpdate(packs: TaskResultPack[])
|
|
686
|
-
onAfterSuiteRun(meta: AfterSuiteRunMeta)
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
677
|
+
onUnhandledError: (error: unknown, type: string) => Promise<void>;
|
|
678
|
+
onCollected: (files?: File[]) => Promise<void>;
|
|
679
|
+
onTaskUpdate: (packs: TaskResultPack[]) => void;
|
|
680
|
+
onAfterSuiteRun: (meta: AfterSuiteRunMeta) => void;
|
|
681
|
+
onCancel: (reason: CancelReason) => void;
|
|
682
|
+
getCountOfFailedTests: () => number;
|
|
683
|
+
sendLog: (log: UserConsoleLog) => void;
|
|
684
|
+
getFiles: () => File[];
|
|
685
|
+
getPaths: () => string[];
|
|
686
|
+
getConfig: () => ResolvedConfig;
|
|
687
|
+
resolveSnapshotPath: (testPath: string) => string;
|
|
688
|
+
resolveSnapshotRawPath: (testPath: string, rawPath: string) => string;
|
|
689
|
+
getModuleGraph: (id: string) => Promise<ModuleGraphData>;
|
|
690
|
+
getTransformResult: (id: string) => Promise<TransformResultWithSource | undefined>;
|
|
691
|
+
readSnapshotFile: (id: string) => Promise<string | null>;
|
|
692
|
+
readTestFile: (id: string) => Promise<string | null>;
|
|
693
|
+
saveTestFile: (id: string, content: string) => Promise<void>;
|
|
694
|
+
saveSnapshotFile: (id: string, content: string) => Promise<void>;
|
|
695
|
+
removeSnapshotFile: (id: string) => Promise<void>;
|
|
696
|
+
snapshotSaved: (snapshot: SnapshotResult) => void;
|
|
697
|
+
rerun: (files: string[]) => Promise<void>;
|
|
698
|
+
updateSnapshot: (file?: File) => Promise<void>;
|
|
699
|
+
getProvidedContext: () => ProvidedContext;
|
|
700
|
+
getUnhandledErrors: () => unknown[];
|
|
701
|
+
finishBrowserTests: () => void;
|
|
702
|
+
getBrowserFiles: () => string[];
|
|
703
|
+
debug: (...args: string[]) => void;
|
|
708
704
|
}
|
|
709
705
|
interface WebSocketEvents extends Pick<Reporter, 'onCollected' | 'onFinished' | 'onTaskUpdate' | 'onUserConsoleLog' | 'onPathsCollected'> {
|
|
710
|
-
onCancel(reason: CancelReason)
|
|
706
|
+
onCancel: (reason: CancelReason) => void;
|
|
711
707
|
}
|
|
712
708
|
|
|
713
709
|
export { AfterSuiteRunMeta, type AssertType, type ExpectTypeOf, ModuleGraphData, ProvidedContext, Reporter, ResolvedConfig, RuntimeConfig, type TransformResultWithSource, UserConsoleLog, type VitestUtils, type WebSocketEvents, type WebSocketHandlers, assertType, createExpect, globalExpect as expect, expectTypeOf, getRunningMode, inject, isFirstRun, isWatchMode, runOnce, vi, vitest };
|
package/dist/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
export { afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, suite, test } from '@vitest/runner';
|
|
2
|
-
export { b as bench } from './vendor/benchmark.
|
|
1
|
+
export { afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, onTestFinished, suite, test } from '@vitest/runner';
|
|
2
|
+
export { b as bench } from './vendor/benchmark.eeqk2rd8.js';
|
|
3
3
|
export { i as isFirstRun, a as runOnce } from './vendor/run-once.Olz_Zkd8.js';
|
|
4
|
-
export { c as createExpect, a as expect, v as vi, b as vitest } from './vendor/vi.
|
|
5
|
-
import { d as dist } from './vendor/index.
|
|
6
|
-
export { b as assertType, g as getRunningMode, i as inject, a as isWatchMode } from './vendor/index.
|
|
4
|
+
export { c as createExpect, a as expect, v as vi, b as vitest } from './vendor/vi.-Nr_x6dl.js';
|
|
5
|
+
import { d as dist } from './vendor/index.n-Ib4UWN.js';
|
|
6
|
+
export { b as assertType, g as getRunningMode, i as inject, a as isWatchMode } from './vendor/index.n-Ib4UWN.js';
|
|
7
7
|
import * as chai from 'chai';
|
|
8
8
|
export { chai };
|
|
9
9
|
export { assert, should } from 'chai';
|
|
10
10
|
import '@vitest/runner/utils';
|
|
11
11
|
import '@vitest/utils';
|
|
12
|
-
import './vendor/index.
|
|
12
|
+
import './vendor/index.ir9i0ywP.js';
|
|
13
13
|
import 'pathe';
|
|
14
14
|
import 'std-env';
|
|
15
15
|
import './vendor/global.CkGT_TMy.js';
|
|
@@ -19,7 +19,7 @@ import '@vitest/snapshot';
|
|
|
19
19
|
import '@vitest/utils/error';
|
|
20
20
|
import './vendor/tasks.IknbGB2n.js';
|
|
21
21
|
import '@vitest/utils/source-map';
|
|
22
|
-
import './vendor/base.
|
|
22
|
+
import './vendor/base.knFzp7G3.js';
|
|
23
23
|
import './vendor/date.Ns1pGd_X.js';
|
|
24
24
|
import '@vitest/spy';
|
|
25
25
|
|
package/dist/node.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { V as VitestRunMode, U as UserConfig, d as VitestOptions, e as Vitest, R as ResolvedConfig, P as ProvidedContext, W as WorkspaceProject, f as RuntimeRPC, T as TestSequencer, g as WorkspaceSpec } from './reporters-
|
|
2
|
-
export { l as BrowserProvider, k as BrowserProviderInitializationOptions, m as BrowserProviderOptions, h as ProcessPool, j as TestSequencerConstructor, i as VitestPackageInstaller, s as startVitest } from './reporters-
|
|
1
|
+
import { V as VitestRunMode, U as UserConfig, d as VitestOptions, e as Vitest, R as ResolvedConfig, P as ProvidedContext, W as WorkspaceProject, f as RuntimeRPC, T as TestSequencer, g as WorkspaceSpec } from './reporters-QGe8gs4b.js';
|
|
2
|
+
export { l as BrowserProvider, k as BrowserProviderInitializationOptions, m as BrowserProviderOptions, h as ProcessPool, j as TestSequencerConstructor, i as VitestPackageInstaller, s as startVitest } from './reporters-QGe8gs4b.js';
|
|
3
3
|
import { UserConfig as UserConfig$1, Plugin } from 'vite';
|
|
4
4
|
import '@vitest/runner';
|
|
5
5
|
import 'vite-node';
|
|
@@ -23,7 +23,7 @@ declare function registerConsoleShortcuts(ctx: Vitest): () => void;
|
|
|
23
23
|
|
|
24
24
|
interface GlobalSetupContext {
|
|
25
25
|
config: ResolvedConfig;
|
|
26
|
-
provide<T extends keyof ProvidedContext>(key: T, value: ProvidedContext[T])
|
|
26
|
+
provide: <T extends keyof ProvidedContext>(key: T, value: ProvidedContext[T]) => void;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
declare function createMethodsRPC(project: WorkspaceProject): RuntimeRPC;
|
package/dist/node.js
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { b as VitestPackageInstaller, V as VitestPlugin, a as createMethodsRPC, c as createVitest, r as registerConsoleShortcuts, s as startVitest } from './vendor/cli-api.RIYLcWhB.js';
|
|
2
|
+
export { B as BaseSequencer } from './vendor/index.QcWmThJv.js';
|
|
2
3
|
import 'pathe';
|
|
4
|
+
import './vendor/constants.K-Wf1PUy.js';
|
|
5
|
+
import './vendor/coverage.E7sG1b3r.js';
|
|
6
|
+
import './vendor/index.GVFv9dZ0.js';
|
|
7
|
+
import 'node:console';
|
|
3
8
|
import 'vite';
|
|
4
9
|
import 'node:path';
|
|
5
10
|
import 'node:url';
|
|
6
11
|
import 'node:process';
|
|
7
12
|
import 'node:fs';
|
|
8
|
-
import './vendor/constants.i1PoEnhr.js';
|
|
9
13
|
import './vendor/_commonjsHelpers.jjO7Zipk.js';
|
|
10
14
|
import 'os';
|
|
11
15
|
import 'path';
|
|
@@ -18,40 +22,36 @@ import 'picocolors';
|
|
|
18
22
|
import 'vite-node/client';
|
|
19
23
|
import '@vitest/snapshot/manager';
|
|
20
24
|
import 'vite-node/server';
|
|
21
|
-
import './vendor/index.
|
|
25
|
+
import './vendor/index.ir9i0ywP.js';
|
|
22
26
|
import 'std-env';
|
|
23
27
|
import '@vitest/runner/utils';
|
|
24
28
|
import '@vitest/utils';
|
|
25
29
|
import './vendor/global.CkGT_TMy.js';
|
|
26
|
-
import './vendor/coverage.E7sG1b3r.js';
|
|
27
30
|
import './path.js';
|
|
28
31
|
import 'node:v8';
|
|
29
32
|
import 'node:os';
|
|
30
33
|
import 'node:events';
|
|
31
34
|
import 'tinypool';
|
|
32
|
-
import './vendor/index.
|
|
33
|
-
import './vendor/base.
|
|
35
|
+
import './vendor/index.8bPxjt7g.js';
|
|
36
|
+
import './vendor/base.knFzp7G3.js';
|
|
34
37
|
import 'node:worker_threads';
|
|
35
|
-
import 'node:fs/promises';
|
|
36
|
-
import 'node:perf_hooks';
|
|
37
|
-
import 'execa';
|
|
38
|
-
import '@vitest/utils/source-map';
|
|
39
|
-
import 'module';
|
|
40
|
-
import 'acorn-walk';
|
|
41
|
-
import './vendor/reporters.cA9x-5v-.js';
|
|
42
|
-
import './chunks/runtime-console.Iloo9fIt.js';
|
|
43
|
-
import 'node:stream';
|
|
44
|
-
import 'node:console';
|
|
45
|
-
import './vendor/date.Ns1pGd_X.js';
|
|
46
|
-
import './vendor/tasks.IknbGB2n.js';
|
|
47
|
-
import 'node:module';
|
|
48
38
|
import 'local-pkg';
|
|
49
39
|
import 'node:crypto';
|
|
50
40
|
import 'vite-node/utils';
|
|
51
|
-
import 'assert';
|
|
52
41
|
import 'magic-string';
|
|
42
|
+
import 'acorn-walk';
|
|
53
43
|
import '@vitest/utils/ast';
|
|
54
44
|
import 'strip-literal';
|
|
55
|
-
import '
|
|
45
|
+
import 'node:module';
|
|
56
46
|
import 'node:readline';
|
|
57
47
|
import 'readline';
|
|
48
|
+
import 'node:perf_hooks';
|
|
49
|
+
import './chunks/runtime-console.Iloo9fIt.js';
|
|
50
|
+
import 'node:stream';
|
|
51
|
+
import './vendor/date.Ns1pGd_X.js';
|
|
52
|
+
import './vendor/tasks.IknbGB2n.js';
|
|
53
|
+
import '@vitest/utils/source-map';
|
|
54
|
+
import 'node:fs/promises';
|
|
55
|
+
import 'execa';
|
|
56
|
+
import 'module';
|
|
57
|
+
import 'assert';
|