Comparing version 1.6.0 to 2.0.0-beta.1
export { processError, startTests } from '@vitest/runner'; | ||
import { R as ResolvedConfig, C as CoverageOptions, b as CoverageProvider, c as CoverageProviderModule } from './reporters-yx5ZTtEV.js'; | ||
import { R as ResolvedConfig, C as CoverageOptions, b as CoverageProvider, c as CoverageProviderModule } from './reporters-MGvT5U9f.js'; | ||
import { VitestExecutor } from './execute.js'; | ||
@@ -4,0 +4,0 @@ import 'vite'; |
export { processError, startTests } from '@vitest/runner'; | ||
export { l as loadDiffConfig, a as loadSnapshotSerializers, s as setupCommonEnv } from './vendor/setup-common.8nJLd4ay.js'; | ||
export { g as getCoverageProvider, a as startCoverageInsideWorker, s as stopCoverageInsideWorker, t as takeCoverageInsideWorker } from './vendor/coverage.E7sG1b3r.js'; | ||
export { l as loadDiffConfig, a as loadSnapshotSerializers, s as setupCommonEnv } from './vendor/setup-common.XeoZAW8t.js'; | ||
export { g as getCoverageProvider, a as startCoverageInsideWorker, s as stopCoverageInsideWorker, t as takeCoverageInsideWorker } from './vendor/coverage.ChSqD-qS.js'; | ||
import '@vitest/utils'; | ||
import '@vitest/snapshot'; | ||
import './vendor/run-once.Olz_Zkd8.js'; | ||
import './vendor/global.CkGT_TMy.js'; | ||
import './vendor/run-once.DLomgGUH.js'; | ||
import './vendor/global.7bFbnyXl.js'; |
@@ -1,9 +0,9 @@ | ||
import { c as createCLI } from './vendor/cac.EdDItJD-.js'; | ||
import { c as createCLI } from './vendor/cac.DzKZaJu2.js'; | ||
import 'pathe'; | ||
import 'events'; | ||
import 'picocolors'; | ||
import './vendor/base.5NT-gWu5.js'; | ||
import './vendor/base._gnK9Slw.js'; | ||
import '@vitest/utils'; | ||
import './vendor/constants.5J7I254_.js'; | ||
import './vendor/constants.5SOfHUj0.js'; | ||
createCLI().parse(); |
export { ConfigEnv, UserConfig, mergeConfig } from 'vite'; | ||
export { ax as UserConfigExport, aw as UserConfigFn, au as UserConfigFnObject, av as UserConfigFnPromise, az as UserProjectConfigExport, ay as UserProjectConfigFn, a1 as UserWorkspaceConfig, aD as configDefaults, aG as coverageConfigDefaults, aF as defaultExclude, aE as defaultInclude, aA as defineConfig, aB as defineProject, aC as defineWorkspace, aH as extraInlineDeps } from './reporters-yx5ZTtEV.js'; | ||
export { ax as UserConfigExport, aw as UserConfigFn, au as UserConfigFnObject, av as UserConfigFnPromise, az as UserProjectConfigExport, ay as UserProjectConfigFn, a1 as UserWorkspaceConfig, aD as configDefaults, aG as coverageConfigDefaults, aF as defaultExclude, aE as defaultInclude, aA as defineConfig, aB as defineProject, aC as defineWorkspace, aH as extraInlineDeps } from './reporters-MGvT5U9f.js'; | ||
import '@vitest/runner'; | ||
@@ -4,0 +4,0 @@ import 'vite-node'; |
@@ -42,3 +42,3 @@ import os from 'node:os'; | ||
allowExternal: false, | ||
ignoreEmptyLines: false, | ||
ignoreEmptyLines: true, | ||
processingConcurrency: Math.min(20, ((_b = (_a = os).availableParallelism) == null ? void 0 : _b.call(_a)) ?? os.cpus().length) | ||
@@ -74,3 +74,2 @@ }; | ||
teardownTimeout: 1e4, | ||
watchExclude: ["**/node_modules/**", "**/dist/**"], | ||
forceRerunTriggers: [ | ||
@@ -77,0 +76,0 @@ "**/package.json/**", |
@@ -1,2 +0,2 @@ | ||
import { B as BaseCoverageOptions, a as ResolvedCoverageOptions } from './reporters-yx5ZTtEV.js'; | ||
import { B as BaseCoverageOptions, a as ResolvedCoverageOptions } from './reporters-MGvT5U9f.js'; | ||
import 'vite'; | ||
@@ -3,0 +3,0 @@ import '@vitest/runner'; |
import { relative } from 'pathe'; | ||
import { m as mm } from './vendor/index.xL8XjTLv.js'; | ||
import './vendor/_commonjsHelpers.jjO7Zipk.js'; | ||
import { m as mm } from './vendor/index.DP-km6lF.js'; | ||
import './vendor/_commonjsHelpers.BFTU3MAI.js'; | ||
import 'util'; | ||
@@ -5,0 +5,0 @@ import 'path'; |
@@ -1,2 +0,2 @@ | ||
import { E as Environment } from './reporters-yx5ZTtEV.js'; | ||
import { E as Environment } from './reporters-MGvT5U9f.js'; | ||
import 'vite'; | ||
@@ -3,0 +3,0 @@ import '@vitest/runner'; |
@@ -1,2 +0,2 @@ | ||
export { e as builtinEnvironments, p as populateGlobal } from './vendor/index.GVFv9dZ0.js'; | ||
export { e as builtinEnvironments, p as populateGlobal } from './vendor/index.DeR1hhfY.js'; | ||
import 'node:console'; |
import vm from 'node:vm'; | ||
import { ViteNodeRunner } from 'vite-node/client'; | ||
import { ViteNodeRunnerOptions } from 'vite-node'; | ||
import { ar as PendingSuiteMock, as as MockFactory, e as RuntimeRPC, W as WorkerGlobalState, at as MockMap } from './reporters-yx5ZTtEV.js'; | ||
import { ar as PendingSuiteMock, as as MockFactory, e as RuntimeRPC, W as WorkerGlobalState, at as MockMap } from './reporters-MGvT5U9f.js'; | ||
import 'vite'; | ||
@@ -87,2 +87,3 @@ import '@vitest/runner'; | ||
private fsBufferCache; | ||
readFileAsync(path: string): Promise<string>; | ||
readFile(path: string): string; | ||
@@ -89,0 +90,0 @@ readBuffer(path: string): Buffer; |
@@ -1,2 +0,2 @@ | ||
export { V as VitestExecutor } from './vendor/execute.fL3szUAI.js'; | ||
export { V as VitestExecutor } from './vendor/execute.CLLNVNnK.js'; | ||
import 'node:vm'; | ||
@@ -11,2 +11,2 @@ import 'node:url'; | ||
import '@vitest/utils'; | ||
import './vendor/base.5NT-gWu5.js'; | ||
import './vendor/base._gnK9Slw.js'; |
import { TaskPopulated, File, TaskResultPack, CancelReason } from '@vitest/runner'; | ||
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'; | ||
export { b as bench } from './suite-IbNSsUWN.js'; | ||
export { b as bench } from './suite-8WAe-urM.js'; | ||
import { ExpectStatic } from '@vitest/expect'; | ||
export { Assertion, AsymmetricMatchersContaining, ExpectStatic, JestAssertion } from '@vitest/expect'; | ||
import { F as FakeTimerInstallOpts, M as MockFactoryWithHelper, s as RuntimeConfig, P as ProvidedContext, A as AfterSuiteRunMeta, t as UserConsoleLog, R as ResolvedConfig, u as ModuleGraphData, v as Reporter } from './reporters-yx5ZTtEV.js'; | ||
export { Q as ApiConfig, aa as ArgumentsType, a9 as Arrayable, a7 as Awaitable, B as BaseCoverageOptions, ap as BenchFunction, an as Benchmark, aq as BenchmarkAPI, ao as BenchmarkResult, am as BenchmarkUserOptions, a0 as BrowserConfigOptions, r as BrowserScript, L as BuiltinEnvironment, O as CSSModuleScopeStrategy, y as CollectLineNumbers, z as CollectLines, ac as Constructable, G as Context, f as ContextRPC, a3 as ContextTestEnvironment, aj as CoverageIstanbulOptions, C as CoverageOptions, b as CoverageProvider, c as CoverageProviderModule, ai as CoverageReporter, ak as CoverageV8Options, al as CustomProviderOptions, X as DepsOptimizationOptions, E as Environment, S as EnvironmentOptions, ae as EnvironmentReturn, K as HappyDOMOptions, Z as InlineConfig, J as JSDOMOptions, ad as ModuleCache, ab as MutableArray, a8 as Nullable, ag as OnServerRestartHandler, H as Pool, I as PoolOptions, $ as ProjectConfig, w as RawErrsMap, ah as ReportContext, a5 as ResolveIdFunction, a as ResolvedCoverageOptions, a4 as ResolvedTestEnvironment, D as RootAndTarget, a2 as RunnerRPC, e as RuntimeRPC, Y as TransformModePatterns, x as TscErrorInfo, _ as TypecheckConfig, U as UserConfig, a1 as UserWorkspaceConfig, i as Vitest, N as VitestEnvironment, V as VitestRunMode, af as VmEnvironmentReturn, g as WorkerContext, W as WorkerGlobalState, a6 as WorkerRPC } from './reporters-yx5ZTtEV.js'; | ||
import { F as FakeTimerInstallOpts, M as MockFactoryWithHelper, s as RuntimeConfig, P as ProvidedContext, A as AfterSuiteRunMeta, t as UserConsoleLog, R as ResolvedConfig, u as ModuleGraphData, v as Reporter } from './reporters-MGvT5U9f.js'; | ||
export { Q as ApiConfig, aa as ArgumentsType, a9 as Arrayable, a7 as Awaitable, B as BaseCoverageOptions, ap as BenchFunction, an as Benchmark, aq as BenchmarkAPI, ao as BenchmarkResult, am as BenchmarkUserOptions, a0 as BrowserConfigOptions, r as BrowserScript, L as BuiltinEnvironment, O as CSSModuleScopeStrategy, y as CollectLineNumbers, z as CollectLines, ac as Constructable, G as Context, f as ContextRPC, a3 as ContextTestEnvironment, aj as CoverageIstanbulOptions, C as CoverageOptions, b as CoverageProvider, c as CoverageProviderModule, ai as CoverageReporter, ak as CoverageV8Options, al as CustomProviderOptions, X as DepsOptimizationOptions, E as Environment, S as EnvironmentOptions, ae as EnvironmentReturn, K as HappyDOMOptions, Z as InlineConfig, J as JSDOMOptions, ad as ModuleCache, ab as MutableArray, a8 as Nullable, ag as OnServerRestartHandler, H as Pool, I as PoolOptions, $ as ProjectConfig, w as RawErrsMap, ah as ReportContext, a5 as ResolveIdFunction, a as ResolvedCoverageOptions, a4 as ResolvedTestEnvironment, D as RootAndTarget, a2 as RunnerRPC, e as RuntimeRPC, Y as TransformModePatterns, x as TscErrorInfo, _ as TypecheckConfig, U as UserConfig, a1 as UserWorkspaceConfig, i as Vitest, N as VitestEnvironment, V as VitestRunMode, af as VmEnvironmentReturn, g as WorkerContext, W as WorkerGlobalState, a6 as WorkerRPC } from './reporters-MGvT5U9f.js'; | ||
import { spyOn, fn, MaybeMockedDeep, MaybeMocked, MaybePartiallyMocked, MaybePartiallyMockedDeep, MockInstance } from '@vitest/spy'; | ||
@@ -29,16 +29,46 @@ export { Mock, MockContext, MockInstance, Mocked, MockedClass, MockedFunction, MockedObject, SpyInstance } from '@vitest/spy'; | ||
/** | ||
* Negates a boolean type. | ||
*/ | ||
declare type Not<T extends boolean> = T extends true ? false : true; | ||
/** | ||
* Checks if all the boolean types in the {@linkcode Types} array are `true`. | ||
*/ | ||
declare type And<Types extends boolean[]> = Types[number] extends true ? true : false; | ||
/** | ||
* Represents an equality type that returns {@linkcode Right} if | ||
* {@linkcode Left} is `true`, | ||
* otherwise returns the negation of {@linkcode Right}. | ||
*/ | ||
declare type Eq<Left extends boolean, Right extends boolean> = Left extends true ? Right : Not<Right>; | ||
declare const secret: unique symbol; | ||
declare type Secret = typeof secret; | ||
/** | ||
* Checks if the given type is `never`. | ||
*/ | ||
declare type IsNever<T> = [T] extends [never] ? true : false; | ||
/** | ||
* Checks if the given type is `any`. | ||
*/ | ||
declare type IsAny<T> = [T] extends [Secret] ? Not<IsNever<T>> : false; | ||
/** | ||
* Determines if the given type is `unknown`. | ||
*/ | ||
declare type IsUnknown<T> = [unknown] extends [T] ? Not<IsAny<T>> : false; | ||
/** | ||
* Determines the printable type representation for a given type. | ||
*/ | ||
declare type PrintType<T> = IsUnknown<T> extends true ? 'unknown' : IsNever<T> extends true ? 'never' : IsAny<T> extends true ? never : boolean extends T ? 'boolean' : T extends boolean ? `literal boolean: ${T}` : string extends T ? 'string' : T extends string ? `literal string: ${T}` : number extends T ? 'number' : T extends number ? `literal number: ${T}` : T extends null ? 'null' : T extends undefined ? 'undefined' : T extends (...args: any[]) => any ? 'function' : '...'; | ||
/** Subjective "useful" keys from a type. For objects it's just `keyof` but for tuples/arrays it's the number keys | ||
/** | ||
* Subjective "useful" keys from a type. For objects it's just `keyof` but for | ||
* tuples/arrays it's the number keys. | ||
* | ||
* @example | ||
* ```ts | ||
* UsefulKeys<{a: 1; b: 2}> // 'a' | 'b' | ||
* | ||
* UsefulKeys<['a', 'b']> // '0' | '1' | ||
* | ||
* UsefulKeys<string[]> // number | ||
* ``` | ||
*/ | ||
@@ -52,5 +82,9 @@ declare type UsefulKeys<T> = T extends any[] ? { | ||
/** | ||
* Recursively walk a type and replace it with a branded type related to the original. This is useful for | ||
* equality-checking stricter than `A extends B ? B extends A ? true : false : false`, because it detects | ||
* the difference between a few edge-case types that vanilla typescript doesn't by default: | ||
* Represents a deeply branded type. | ||
* | ||
* Recursively walk a type and replace it with a branded type related to the | ||
* original. This is useful for equality-checking stricter than | ||
* `A extends B ? B extends A ? true : false : false`, because it detects the | ||
* difference between a few edge-case types that vanilla typescript | ||
* doesn't by default: | ||
* - `any` vs `unknown` | ||
@@ -60,4 +94,5 @@ * - `{ readonly a: string }` vs `{ a: string }` | ||
* | ||
* Note: not very performant for complex types - this should only be used when you know you need it. If doing | ||
* an equality check, it's almost always better to use `StrictEqualUsingTSInternalIdenticalToOperator`. | ||
* __Note__: not very performant for complex types - this should only be used | ||
* when you know you need it. If doing an equality check, it's almost always | ||
* better to use {@linkcode StrictEqualUsingTSInternalIdenticalToOperator}. | ||
*/ | ||
@@ -98,6 +133,15 @@ declare type DeepBrand<T> = IsNever<T> extends true ? { | ||
}; | ||
/** | ||
* Extracts the keys from a type that are required (not optional). | ||
*/ | ||
declare type RequiredKeys<T> = Extract<{ | ||
[K in keyof T]-?: {} extends Pick<T, K> ? never : K; | ||
}[keyof T], keyof T>; | ||
/** | ||
* Gets the keys of an object type that are optional. | ||
*/ | ||
declare type OptionalKeys<T> = Exclude<keyof T, RequiredKeys<T>>; | ||
/** | ||
* Extracts the keys from a type that are not readonly. | ||
*/ | ||
declare type ReadonlyKeys<T> = Extract<{ | ||
@@ -110,8 +154,22 @@ [K in keyof T]-?: ReadonlyEquivalent<{ | ||
}[keyof T], keyof T>; | ||
/** | ||
* Determines if two types, are equivalent in a `readonly` manner. | ||
*/ | ||
declare type ReadonlyEquivalent<X, Y> = Extends<(<T>() => T extends X ? true : false), (<T>() => T extends Y ? true : false)>; | ||
/** Returns true if `L extends R`. Explicitly checks for `never` since that can give unexpected results. */ | ||
/** | ||
* Checks if one type extends another. | ||
*/ | ||
declare type Extends<L, R> = IsNever<L> extends true ? IsNever<R> : [L] extends [R] ? true : false; | ||
declare type ExtendsUsingBranding<L, R> = Extends<DeepBrand<L>, DeepBrand<R>>; | ||
declare type ExtendsExcludingAnyOrNever<L, R> = IsAny<L> extends true ? IsAny<R> : Extends<L, R>; | ||
/** | ||
* Checks if two types are strictly equal using | ||
* the TypeScript internal identical-to operator. | ||
* | ||
* @see {@link https://github.com/microsoft/TypeScript/issues/55188#issuecomment-1656328122 much history} | ||
*/ | ||
declare type StrictEqualUsingTSInternalIdenticalToOperator<L, R> = (<T>() => T extends (L & T) | T ? true : false) extends <T>() => T extends (R & T) | T ? true : false ? IsNever<L> extends IsNever<R> ? true : false : false; | ||
/** | ||
* Checks if two types are strictly equal using branding. | ||
*/ | ||
declare type StrictEqualUsingBranding<Left, Right> = And<[ | ||
@@ -121,3 +179,10 @@ ExtendsUsingBranding<Left, Right>, | ||
]>; | ||
declare type Params<Actual> = Actual extends (...args: infer P) => any ? P : never; | ||
/** | ||
* Extracts the parameter types from a function type. | ||
*/ | ||
declare type Params<Actual> = Actual extends (...args: infer ParameterTypes) => any ? ParameterTypes : never; | ||
/** | ||
* Represents the constructor parameters of a class or constructor function. | ||
* If the constructor takes no arguments, an empty array is returned. | ||
*/ | ||
declare type ConstructorParams<Actual> = Actual extends new (...args: infer P) => any ? Actual extends new () => any ? P | [] : P : never; | ||
@@ -128,7 +193,25 @@ declare const mismatch: unique symbol; | ||
}; | ||
/** A type which should match anything passed as a value but *doesn't* match `Mismatch` - helps TypeScript select the right overload for `toEqualTypeOf` and `toMatchTypeOf`. */ | ||
/** | ||
* A type which should match anything passed as a value but *doesn't* | ||
* match {@linkcode Mismatch}. It helps TypeScript select the right overload | ||
* for {@linkcode PositiveExpectTypeOf.toEqualTypeOf `.toEqualTypeOf()`} and | ||
* {@linkcode PositiveExpectTypeOf.toMatchTypeOf `.toMatchTypeOf()`}. | ||
*/ | ||
declare const avalue: unique symbol; | ||
/** | ||
* Represents a value that can be of various types. | ||
*/ | ||
declare type AValue = { | ||
[avalue]?: undefined; | ||
} | string | number | boolean | symbol | bigint | null | undefined | void; | ||
/** | ||
* Represents the type of mismatched arguments between | ||
* the actual result and the expected result. | ||
* | ||
* If {@linkcode ActualResult} and {@linkcode ExpectedResult} are equivalent, | ||
* the type resolves to an empty tuple `[]`, indicating no mismatch. | ||
* If they are not equivalent, it resolves to a tuple containing the element | ||
* {@linkcode Mismatch}, signifying a discrepancy between | ||
* the expected and actual results. | ||
*/ | ||
declare type MismatchArgs<ActualResult extends boolean, ExpectedResult extends boolean> = Eq<ActualResult, ExpectedResult> extends true ? [] : [Mismatch]; | ||
@@ -209,2 +292,6 @@ declare const inverted: unique symbol; | ||
}; | ||
/** | ||
* Represents a scolder function that checks if the result of an expecter | ||
* matches the specified options. | ||
*/ | ||
declare type Scolder<Expecter extends { | ||
@@ -215,2 +302,6 @@ result: boolean; | ||
}> = Expecter['result'] extends Options['positive'] ? () => true : Options['positive'] extends true ? Expecter : Inverted<Expecter>; | ||
/** | ||
* Represents the positive assertion methods available for type checking in the | ||
* {@linkcode expectTypeOf()} utility. | ||
*/ | ||
interface PositiveExpectTypeOf<Actual> extends BaseExpectTypeOf<Actual, { | ||
@@ -221,17 +312,197 @@ positive: true; | ||
toEqualTypeOf: { | ||
/** | ||
* Uses TypeScript's internal technique to check for type "identicalness". | ||
* | ||
* It will check if the types are fully equal to each other. | ||
* It will not fail if two objects have different values, but the same type. | ||
* It will fail however if an object is missing a property. | ||
* | ||
* **_Unexpected failure_**? For a more permissive but less performant | ||
* check that accommodates for equivalent intersection types, | ||
* use {@linkcode branded `.branded.toEqualTypeOf()`}. | ||
* @see {@link https://github.com/mmkal/expect-type#why-is-my-assertion-failing The documentation for details}. | ||
* | ||
* @example | ||
* <caption>Using generic type argument syntax</caption> | ||
* ```ts | ||
* expectTypeOf({ a: 1 }).toEqualTypeOf<{ a: number }>() | ||
* | ||
* expectTypeOf({ a: 1, b: 1 }).not.toEqualTypeOf<{ a: number }>() | ||
* ``` | ||
* | ||
* @example | ||
* <caption>Using inferred type syntax by passing a value</caption> | ||
* ```ts | ||
* expectTypeOf({ a: 1 }).toEqualTypeOf({ a: 1 }) | ||
* | ||
* expectTypeOf({ a: 1 }).toEqualTypeOf({ a: 2 }) | ||
* ``` | ||
* | ||
* @param value - The value to compare against the expected type. | ||
* @param MISMATCH - The mismatch arguments. | ||
* @returns `true`. | ||
*/ | ||
<Expected extends StrictEqualUsingTSInternalIdenticalToOperator<Actual, Expected> extends true ? unknown : MismatchInfo<Actual, Expected>>(value: Expected & AValue, // reason for `& AValue`: make sure this is only the selected overload when the end-user passes a value for an inferred typearg. The `Mismatch` type does match `AValue`. | ||
...MISMATCH: MismatchArgs<StrictEqualUsingTSInternalIdenticalToOperator<Actual, Expected>, true>): true; | ||
/** | ||
* Uses TypeScript's internal technique to check for type "identicalness". | ||
* | ||
* It will check if the types are fully equal to each other. | ||
* It will not fail if two objects have different values, but the same type. | ||
* It will fail however if an object is missing a property. | ||
* | ||
* **_Unexpected failure_**? For a more permissive but less performant | ||
* check that accommodates for equivalent intersection types, | ||
* use {@linkcode branded `.branded.toEqualTypeOf()`}. | ||
* @see {@link https://github.com/mmkal/expect-type#why-is-my-assertion-failing The documentation for details}. | ||
* | ||
* @example | ||
* <caption>Using generic type argument syntax</caption> | ||
* ```ts | ||
* expectTypeOf({ a: 1 }).toEqualTypeOf<{ a: number }>() | ||
* | ||
* expectTypeOf({ a: 1, b: 1 }).not.toEqualTypeOf<{ a: number }>() | ||
* ``` | ||
* | ||
* @example | ||
* <caption>Using inferred type syntax by passing a value</caption> | ||
* ```ts | ||
* expectTypeOf({ a: 1 }).toEqualTypeOf({ a: 1 }) | ||
* | ||
* expectTypeOf({ a: 1 }).toEqualTypeOf({ a: 2 }) | ||
* ``` | ||
* | ||
* @param MISMATCH - The mismatch arguments. | ||
* @returns `true`. | ||
*/ | ||
<Expected extends StrictEqualUsingTSInternalIdenticalToOperator<Actual, Expected> extends true ? unknown : MismatchInfo<Actual, Expected>>(...MISMATCH: MismatchArgs<StrictEqualUsingTSInternalIdenticalToOperator<Actual, Expected>, true>): true; | ||
}; | ||
toMatchTypeOf: { | ||
/** | ||
* A less strict version of {@linkcode toEqualTypeOf `.toEqualTypeOf()`} | ||
* that allows for extra properties. | ||
* This is roughly equivalent to an `extends` constraint | ||
* in a function type argument. | ||
* | ||
* @example | ||
* <caption>Using generic type argument syntax</caption> | ||
* ```ts | ||
* expectTypeOf({ a: 1, b: 1 }).toMatchTypeOf<{ a: number }>() | ||
* ``` | ||
* | ||
* @example | ||
* <caption>Using inferred type syntax by passing a value</caption> | ||
* ```ts | ||
* expectTypeOf({ a: 1, b: 1 }).toMatchTypeOf({ a: 2 }) | ||
* ``` | ||
* | ||
* @param value - The value to compare against the expected type. | ||
* @param MISMATCH - The mismatch arguments. | ||
* @returns `true`. | ||
*/ | ||
<Expected extends Extends<Actual, Expected> extends true ? unknown : MismatchInfo<Actual, Expected>>(value: Expected & AValue, // reason for `& AValue`: make sure this is only the selected overload when the end-user passes a value for an inferred typearg. The `Mismatch` type does match `AValue`. | ||
...MISMATCH: MismatchArgs<Extends<Actual, Expected>, true>): true; | ||
/** | ||
* A less strict version of {@linkcode toEqualTypeOf `.toEqualTypeOf()`} | ||
* that allows for extra properties. | ||
* This is roughly equivalent to an `extends` constraint | ||
* in a function type argument. | ||
* | ||
* @example | ||
* <caption>Using generic type argument syntax</caption> | ||
* ```ts | ||
* expectTypeOf({ a: 1, b: 1 }).toMatchTypeOf<{ a: number }>() | ||
* ``` | ||
* | ||
* @example | ||
* <caption>Using inferred type syntax by passing a value</caption> | ||
* ```ts | ||
* expectTypeOf({ a: 1, b: 1 }).toMatchTypeOf({ a: 2 }) | ||
* ``` | ||
* | ||
* @param MISMATCH - The mismatch arguments. | ||
* @returns `true`. | ||
*/ | ||
<Expected extends Extends<Actual, Expected> extends true ? unknown : MismatchInfo<Actual, Expected>>(...MISMATCH: MismatchArgs<Extends<Actual, Expected>, true>): true; | ||
}; | ||
toHaveProperty: <K extends keyof Actual>(key: K, ...MISMATCH: MismatchArgs<Extends<K, keyof Actual>, true>) => K extends keyof Actual ? PositiveExpectTypeOf<Actual[K]> : true; | ||
/** | ||
* Checks whether an object has a given property. | ||
* | ||
* @example | ||
* <caption>check that properties exist</caption> | ||
* ```ts | ||
* const obj = {a: 1, b: ''} | ||
* | ||
* expectTypeOf(obj).toHaveProperty('a') | ||
* | ||
* expectTypeOf(obj).not.toHaveProperty('c') | ||
* ``` | ||
* | ||
* @param key - The property key to check for. | ||
* @param MISMATCH - The mismatch arguments. | ||
* @returns `true`. | ||
*/ | ||
toHaveProperty: <KeyType extends keyof Actual>(key: KeyType, ...MISMATCH: MismatchArgs<Extends<KeyType, keyof Actual>, true>) => KeyType extends keyof Actual ? PositiveExpectTypeOf<Actual[KeyType]> : true; | ||
/** | ||
* Inverts the result of the following assertions. | ||
* | ||
* @example | ||
* ```ts | ||
* expectTypeOf({ a: 1 }).not.toMatchTypeOf({ b: 1 }) | ||
* ``` | ||
*/ | ||
not: NegativeExpectTypeOf<Actual>; | ||
/** | ||
* Intersection types can cause issues with | ||
* {@linkcode toEqualTypeOf `.toEqualTypeOf()`}: | ||
* ```ts | ||
* // ❌ The following line doesn't compile, even though the types are arguably the same. | ||
* expectTypeOf<{ a: 1 } & { b: 2 }>().toEqualTypeOf<{ a: 1; b: 2 }>() | ||
* ``` | ||
* This helper works around this problem by using | ||
* a more permissive but less performant check. | ||
* | ||
* __Note__: This comes at a performance cost, and can cause the compiler | ||
* to 'give up' if used with excessively deep types, so use sparingly. | ||
* | ||
* @see {@link https://github.com/mmkal/expect-type/pull/21 Reference} | ||
*/ | ||
branded: { | ||
/** | ||
* Uses TypeScript's internal technique to check for type "identicalness". | ||
* | ||
* It will check if the types are fully equal to each other. | ||
* It will not fail if two objects have different values, but the same type. | ||
* It will fail however if an object is missing a property. | ||
* | ||
* **_Unexpected failure_**? For a more permissive but less performant | ||
* check that accommodates for equivalent intersection types, | ||
* use {@linkcode PositiveExpectTypeOf.branded `.branded.toEqualTypeOf()`}. | ||
* @see {@link https://github.com/mmkal/expect-type#why-is-my-assertion-failing The documentation for details}. | ||
* | ||
* @example | ||
* <caption>Using generic type argument syntax</caption> | ||
* ```ts | ||
* expectTypeOf({ a: 1 }).toEqualTypeOf<{ a: number }>() | ||
* | ||
* expectTypeOf({ a: 1, b: 1 }).not.toEqualTypeOf<{ a: number }>() | ||
* ``` | ||
* | ||
* @example | ||
* <caption>Using inferred type syntax by passing a value</caption> | ||
* ```ts | ||
* expectTypeOf({ a: 1 }).toEqualTypeOf({ a: 1 }) | ||
* | ||
* expectTypeOf({ a: 1 }).toEqualTypeOf({ a: 2 }) | ||
* ``` | ||
* | ||
* @param MISMATCH - The mismatch arguments. | ||
* @returns `true`. | ||
*/ | ||
toEqualTypeOf: <Expected extends StrictEqualUsingBranding<Actual, Expected> extends true ? unknown : MismatchInfo<Actual, Expected>>(...MISMATCH: MismatchArgs<StrictEqualUsingBranding<Actual, Expected>, true>) => true; | ||
}; | ||
} | ||
/** | ||
* Represents the negative expectation type for the {@linkcode Actual} type. | ||
*/ | ||
interface NegativeExpectTypeOf<Actual> extends BaseExpectTypeOf<Actual, { | ||
@@ -241,48 +512,516 @@ positive: false; | ||
toEqualTypeOf: { | ||
/** | ||
* Uses TypeScript's internal technique to check for type "identicalness". | ||
* | ||
* It will check if the types are fully equal to each other. | ||
* It will not fail if two objects have different values, but the same type. | ||
* It will fail however if an object is missing a property. | ||
* | ||
* **_Unexpected failure_**? For a more permissive but less performant | ||
* check that accommodates for equivalent intersection types, | ||
* use {@linkcode PositiveExpectTypeOf.branded `.branded.toEqualTypeOf()`}. | ||
* @see {@link https://github.com/mmkal/expect-type#why-is-my-assertion-failing The documentation for details}. | ||
* | ||
* @example | ||
* <caption>Using generic type argument syntax</caption> | ||
* ```ts | ||
* expectTypeOf({ a: 1 }).toEqualTypeOf<{ a: number }>() | ||
* | ||
* expectTypeOf({ a: 1, b: 1 }).not.toEqualTypeOf<{ a: number }>() | ||
* ``` | ||
* | ||
* @example | ||
* <caption>Using inferred type syntax by passing a value</caption> | ||
* ```ts | ||
* expectTypeOf({ a: 1 }).toEqualTypeOf({ a: 1 }) | ||
* | ||
* expectTypeOf({ a: 1 }).toEqualTypeOf({ a: 2 }) | ||
* ``` | ||
* | ||
* @param value - The value to compare against the expected type. | ||
* @param MISMATCH - The mismatch arguments. | ||
* @returns `true`. | ||
*/ | ||
<Expected>(value: Expected & AValue, ...MISMATCH: MismatchArgs<StrictEqualUsingTSInternalIdenticalToOperator<Actual, Expected>, false>): true; | ||
/** | ||
* Uses TypeScript's internal technique to check for type "identicalness". | ||
* | ||
* It will check if the types are fully equal to each other. | ||
* It will not fail if two objects have different values, but the same type. | ||
* It will fail however if an object is missing a property. | ||
* | ||
* **_Unexpected failure_**? For a more permissive but less performant | ||
* check that accommodates for equivalent intersection types, | ||
* use {@linkcode PositiveExpectTypeOf.branded `.branded.toEqualTypeOf()`}. | ||
* @see {@link https://github.com/mmkal/expect-type#why-is-my-assertion-failing The documentation for details}. | ||
* | ||
* @example | ||
* <caption>Using generic type argument syntax</caption> | ||
* ```ts | ||
* expectTypeOf({ a: 1 }).toEqualTypeOf<{ a: number }>() | ||
* | ||
* expectTypeOf({ a: 1, b: 1 }).not.toEqualTypeOf<{ a: number }>() | ||
* ``` | ||
* | ||
* @example | ||
* <caption>Using inferred type syntax by passing a value</caption> | ||
* ```ts | ||
* expectTypeOf({ a: 1 }).toEqualTypeOf({ a: 1 }) | ||
* | ||
* expectTypeOf({ a: 1 }).toEqualTypeOf({ a: 2 }) | ||
* ``` | ||
* | ||
* @param MISMATCH - The mismatch arguments. | ||
* @returns `true`. | ||
*/ | ||
<Expected>(...MISMATCH: MismatchArgs<StrictEqualUsingTSInternalIdenticalToOperator<Actual, Expected>, false>): true; | ||
}; | ||
toMatchTypeOf: { | ||
/** | ||
* A less strict version of | ||
* {@linkcode PositiveExpectTypeOf.toEqualTypeOf `.toEqualTypeOf()`} | ||
* that allows for extra properties. | ||
* This is roughly equivalent to an `extends` constraint | ||
* in a function type argument. | ||
* | ||
* @example | ||
* <caption>Using generic type argument syntax</caption> | ||
* ```ts | ||
* expectTypeOf({ a: 1, b: 1 }).toMatchTypeOf<{ a: number }>() | ||
* ``` | ||
* | ||
* @example | ||
* <caption>Using inferred type syntax by passing a value</caption> | ||
* ```ts | ||
* expectTypeOf({ a: 1, b: 1 }).toMatchTypeOf({ a: 2 }) | ||
* ``` | ||
* | ||
* @param value - The value to compare against the expected type. | ||
* @param MISMATCH - The mismatch arguments. | ||
* @returns `true`. | ||
*/ | ||
<Expected>(value: Expected & AValue, // reason for `& AValue`: make sure this is only the selected overload when the end-user passes a value for an inferred typearg. The `Mismatch` type does match `AValue`. | ||
...MISMATCH: MismatchArgs<Extends<Actual, Expected>, false>): true; | ||
/** | ||
* A less strict version of | ||
* {@linkcode PositiveExpectTypeOf.toEqualTypeOf `.toEqualTypeOf()`} | ||
* that allows for extra properties. | ||
* This is roughly equivalent to an `extends` constraint | ||
* in a function type argument. | ||
* | ||
* @example | ||
* <caption>Using generic type argument syntax</caption> | ||
* ```ts | ||
* expectTypeOf({ a: 1, b: 1 }).toMatchTypeOf<{ a: number }>() | ||
* ``` | ||
* | ||
* @example | ||
* <caption>Using inferred type syntax by passing a value</caption> | ||
* ```ts | ||
* expectTypeOf({ a: 1, b: 1 }).toMatchTypeOf({ a: 2 }) | ||
* ``` | ||
* | ||
* @param MISMATCH - The mismatch arguments. | ||
* @returns `true`. | ||
*/ | ||
<Expected>(...MISMATCH: MismatchArgs<Extends<Actual, Expected>, false>): true; | ||
}; | ||
toHaveProperty: <K extends string | number | symbol>(key: K, ...MISMATCH: MismatchArgs<Extends<K, keyof Actual>, false>) => true; | ||
/** | ||
* Checks whether an object has a given property. | ||
* | ||
* @example | ||
* <caption>check that properties exist</caption> | ||
* ```ts | ||
* const obj = {a: 1, b: ''} | ||
* | ||
* expectTypeOf(obj).toHaveProperty('a') | ||
* | ||
* expectTypeOf(obj).not.toHaveProperty('c') | ||
* ``` | ||
* | ||
* @param key - The property key to check for. | ||
* @param MISMATCH - The mismatch arguments. | ||
* @returns `true`. | ||
*/ | ||
toHaveProperty: <KeyType extends string | number | symbol>(key: KeyType, ...MISMATCH: MismatchArgs<Extends<KeyType, keyof Actual>, false>) => true; | ||
} | ||
/** | ||
* Represents a conditional type that selects either | ||
* {@linkcode PositiveExpectTypeOf} or {@linkcode NegativeExpectTypeOf} based | ||
* on the value of the `positive` property in the {@linkcode Options} type. | ||
*/ | ||
declare type ExpectTypeOf<Actual, Options extends { | ||
positive: boolean; | ||
}> = Options['positive'] extends true ? PositiveExpectTypeOf<Actual> : NegativeExpectTypeOf<Actual>; | ||
/** | ||
* Represents the base interface for the | ||
* {@linkcode expectTypeOf()} function. | ||
* Provides a set of assertion methods to perform type checks on a value. | ||
*/ | ||
interface BaseExpectTypeOf<Actual, Options extends { | ||
positive: boolean; | ||
}> { | ||
/** | ||
* Checks whether the type of the value is `any`. | ||
*/ | ||
toBeAny: Scolder<ExpectAny<Actual>, Options>; | ||
/** | ||
* Checks whether the type of the value is `unknown`. | ||
*/ | ||
toBeUnknown: Scolder<ExpectUnknown<Actual>, Options>; | ||
/** | ||
* Checks whether the type of the value is `never`. | ||
*/ | ||
toBeNever: Scolder<ExpectNever<Actual>, Options>; | ||
/** | ||
* Checks whether the type of the value is `function`. | ||
*/ | ||
toBeFunction: Scolder<ExpectFunction<Actual>, Options>; | ||
/** | ||
* Checks whether the type of the value is `object`. | ||
*/ | ||
toBeObject: Scolder<ExpectObject<Actual>, Options>; | ||
/** | ||
* Checks whether the type of the value is an {@linkcode Array}. | ||
*/ | ||
toBeArray: Scolder<ExpectArray<Actual>, Options>; | ||
/** | ||
* Checks whether the type of the value is `number`. | ||
*/ | ||
toBeNumber: Scolder<ExpectNumber<Actual>, Options>; | ||
/** | ||
* Checks whether the type of the value is `string`. | ||
*/ | ||
toBeString: Scolder<ExpectString<Actual>, Options>; | ||
/** | ||
* Checks whether the type of the value is `boolean`. | ||
*/ | ||
toBeBoolean: Scolder<ExpectBoolean<Actual>, Options>; | ||
/** | ||
* Checks whether the type of the value is `void`. | ||
*/ | ||
toBeVoid: Scolder<ExpectVoid<Actual>, Options>; | ||
/** | ||
* Checks whether the type of the value is `symbol`. | ||
*/ | ||
toBeSymbol: Scolder<ExpectSymbol<Actual>, Options>; | ||
/** | ||
* Checks whether the type of the value is `null`. | ||
*/ | ||
toBeNull: Scolder<ExpectNull<Actual>, Options>; | ||
/** | ||
* Checks whether the type of the value is `undefined`. | ||
*/ | ||
toBeUndefined: Scolder<ExpectUndefined<Actual>, Options>; | ||
/** | ||
* Checks whether the type of the value is `null` or `undefined`. | ||
*/ | ||
toBeNullable: Scolder<ExpectNullable<Actual>, Options>; | ||
/** | ||
* Checks whether a function is callable with the given parameters. | ||
* | ||
* __Note__: You cannot negate this assertion with | ||
* {@linkcode PositiveExpectTypeOf.not `.not`} you need to use | ||
* `ts-expect-error` instead. | ||
* | ||
* @example | ||
* ```ts | ||
* const f = (a: number) => [a, a] | ||
* | ||
* expectTypeOf(f).toBeCallableWith(1) | ||
* ``` | ||
* | ||
* __Known Limitation__: This assertion will likely fail if you try to use it | ||
* with a generic function or an overload. | ||
* @see {@link https://github.com/mmkal/expect-type/issues/50 This issue} for an example and a workaround. | ||
* | ||
* @param args - The arguments to check for callability. | ||
* @returns `true`. | ||
*/ | ||
toBeCallableWith: Options['positive'] extends true ? (...args: Params<Actual>) => true : never; | ||
/** | ||
* Checks whether a class is constructible with the given parameters. | ||
* | ||
* @example | ||
* ```ts | ||
* expectTypeOf(Date).toBeConstructibleWith('1970') | ||
* | ||
* expectTypeOf(Date).toBeConstructibleWith(0) | ||
* | ||
* expectTypeOf(Date).toBeConstructibleWith(new Date()) | ||
* | ||
* expectTypeOf(Date).toBeConstructibleWith() | ||
* ``` | ||
* | ||
* @param args - The arguments to check for constructibility. | ||
* @returns `true`. | ||
*/ | ||
toBeConstructibleWith: Options['positive'] extends true ? (...args: ConstructorParams<Actual>) => true : never; | ||
/** | ||
* Equivalent to the {@linkcode Extract} utility type. | ||
* Helps narrow down complex union types. | ||
* | ||
* @example | ||
* ```ts | ||
* type ResponsiveProp<T> = T | T[] | { xs?: T; sm?: T; md?: T } | ||
* | ||
* interface CSSProperties { | ||
* margin?: string | ||
* padding?: string | ||
* } | ||
* | ||
* function getResponsiveProp<T>(_props: T): ResponsiveProp<T> { | ||
* return {} | ||
* } | ||
* | ||
* const cssProperties: CSSProperties = { margin: '1px', padding: '2px' } | ||
* | ||
* expectTypeOf(getResponsiveProp(cssProperties)) | ||
* .extract<{ xs?: any }>() // extracts the last type from a union | ||
* .toEqualTypeOf<{ | ||
* xs?: CSSProperties | ||
* sm?: CSSProperties | ||
* md?: CSSProperties | ||
* }>() | ||
* | ||
* expectTypeOf(getResponsiveProp(cssProperties)) | ||
* .extract<unknown[]>() // extracts an array from a union | ||
* .toEqualTypeOf<CSSProperties[]>() | ||
* ``` | ||
* | ||
* __Note__: If no type is found in the union, it will return `never`. | ||
* | ||
* @param v - The type to extract from the union. | ||
* @returns The type after extracting the type from the union. | ||
*/ | ||
extract: <V>(v?: V) => ExpectTypeOf<Extract<Actual, V>, Options>; | ||
/** | ||
* Equivalent to the {@linkcode Exclude} utility type. | ||
* Removes types from a union. | ||
* | ||
* @example | ||
* ```ts | ||
* type ResponsiveProp<T> = T | T[] | { xs?: T; sm?: T; md?: T } | ||
* | ||
* interface CSSProperties { | ||
* margin?: string | ||
* padding?: string | ||
* } | ||
* | ||
* function getResponsiveProp<T>(_props: T): ResponsiveProp<T> { | ||
* return {} | ||
* } | ||
* | ||
* const cssProperties: CSSProperties = { margin: '1px', padding: '2px' } | ||
* | ||
* expectTypeOf(getResponsiveProp(cssProperties)) | ||
* .exclude<unknown[]>() | ||
* .exclude<{ xs?: unknown }>() // or just `.exclude<unknown[] | { xs?: unknown }>()` | ||
* .toEqualTypeOf<CSSProperties>() | ||
* ``` | ||
*/ | ||
exclude: <V>(v?: V) => ExpectTypeOf<Exclude<Actual, V>, Options>; | ||
parameter: <K extends keyof Params<Actual>>(number: K) => ExpectTypeOf<Params<Actual>[K], Options>; | ||
/** | ||
* Equivalent to the {@linkcode Pick} utility type. | ||
* Helps select a subset of properties from an object type. | ||
* | ||
* @example | ||
* ```ts | ||
* interface Person { | ||
* name: string | ||
* age: number | ||
* } | ||
* | ||
* expectTypeOf<Person>() | ||
* .pick<'name'>() | ||
* .toEqualTypeOf<{ name: string }>() | ||
* ``` | ||
* | ||
* @param keyToPick - The property key to pick. | ||
* @returns The type after picking the property. | ||
*/ | ||
pick: <KeyToPick extends keyof Actual>(keyToPick?: KeyToPick) => ExpectTypeOf<Pick<Actual, KeyToPick>, Options>; | ||
/** | ||
* Equivalent to the {@linkcode Omit} utility type. | ||
* Helps remove a subset of properties from an object type. | ||
* | ||
* @example | ||
* ```ts | ||
* interface Person { | ||
* name: string | ||
* age: number | ||
* } | ||
* | ||
* expectTypeOf<Person>().omit<'name'>().toEqualTypeOf<{ age: number }>() | ||
* ``` | ||
* | ||
* @param keyToOmit - The property key to omit. | ||
* @returns The type after omitting the property. | ||
*/ | ||
omit: <KeyToOmit extends keyof Actual | (PropertyKey & Record<never, never>)>(keyToOmit?: KeyToOmit) => ExpectTypeOf<Omit<Actual, KeyToOmit>, Options>; | ||
/** | ||
* Extracts a certain function argument with `.parameter(number)` call to | ||
* perform other assertions on it. | ||
* | ||
* @example | ||
* ```ts | ||
* function foo(a: number, b: string) { | ||
* return [a, b] | ||
* } | ||
* | ||
* expectTypeOf(foo).parameter(0).toBeNumber() | ||
* | ||
* expectTypeOf(foo).parameter(1).toBeString() | ||
* ``` | ||
* | ||
* @param index - The index of the parameter to extract. | ||
* @returns The extracted parameter type. | ||
*/ | ||
parameter: <Index extends keyof Params<Actual>>(index: Index) => ExpectTypeOf<Params<Actual>[Index], Options>; | ||
/** | ||
* Equivalent to the {@linkcode Parameters} utility type. | ||
* Extracts function parameters to perform assertions on its value. | ||
* Parameters are returned as an array. | ||
* | ||
* @example | ||
* ```ts | ||
* function noParam() {} | ||
* | ||
* function hasParam(s: string) {} | ||
* | ||
* expectTypeOf(noParam).parameters.toEqualTypeOf<[]>() | ||
* | ||
* expectTypeOf(hasParam).parameters.toEqualTypeOf<[string]>() | ||
* ``` | ||
*/ | ||
parameters: ExpectTypeOf<Params<Actual>, Options>; | ||
/** | ||
* Equivalent to the {@linkcode ConstructorParameters} utility type. | ||
* Extracts constructor parameters as an array of values and | ||
* perform assertions on them with this method. | ||
* | ||
* @example | ||
* ```ts | ||
* expectTypeOf(Date).constructorParameters.toEqualTypeOf< | ||
* [] | [string | number | Date] | ||
* >() | ||
* ``` | ||
*/ | ||
constructorParameters: ExpectTypeOf<ConstructorParams<Actual>, Options>; | ||
/** | ||
* Equivalent to the {@linkcode ThisParameterType} utility type. | ||
* Extracts the `this` parameter of a function to | ||
* perform assertions on its value. | ||
* | ||
* @example | ||
* ```ts | ||
* function greet(this: { name: string }, message: string) { | ||
* return `Hello ${this.name}, here's your message: ${message}` | ||
* } | ||
* | ||
* expectTypeOf(greet).thisParameter.toEqualTypeOf<{ name: string }>() | ||
* ``` | ||
*/ | ||
thisParameter: ExpectTypeOf<ThisParameterType<Actual>, Options>; | ||
/** | ||
* Equivalent to the {@linkcode InstanceType} utility type. | ||
* Extracts the instance type of a class to perform assertions on. | ||
* | ||
* @example | ||
* ```ts | ||
* expectTypeOf(Date).instance.toHaveProperty('toISOString') | ||
* ``` | ||
*/ | ||
instance: Actual extends new (...args: any[]) => infer I ? ExpectTypeOf<I, Options> : never; | ||
/** | ||
* Equivalent to the {@linkcode ReturnType} utility type. | ||
* Extracts the return type of a function. | ||
* | ||
* @example | ||
* ```ts | ||
* expectTypeOf(() => {}).returns.toBeVoid() | ||
* | ||
* expectTypeOf((a: number) => [a, a]).returns.toEqualTypeOf([1, 2]) | ||
* ``` | ||
*/ | ||
returns: Actual extends (...args: any[]) => infer R ? ExpectTypeOf<R, Options> : never; | ||
resolves: Actual extends PromiseLike<infer R> ? ExpectTypeOf<R, Options> : never; | ||
items: Actual extends ArrayLike<infer R> ? ExpectTypeOf<R, Options> : never; | ||
/** | ||
* Extracts resolved value of a Promise, | ||
* so you can perform other assertions on it. | ||
* | ||
* @example | ||
* ```ts | ||
* async function asyncFunc() { | ||
* return 123 | ||
* } | ||
* | ||
* expectTypeOf(asyncFunc).returns.resolves.toBeNumber() | ||
* | ||
* expectTypeOf(Promise.resolve('string')).resolves.toBeString() | ||
* ``` | ||
* | ||
* Type Equivalent: | ||
* ```ts | ||
* type Resolves<PromiseType> = PromiseType extends PromiseLike<infer ResolvedType> | ||
* ? ResolvedType | ||
* : never | ||
* ``` | ||
*/ | ||
resolves: Actual extends PromiseLike<infer ResolvedType> ? ExpectTypeOf<ResolvedType, Options> : never; | ||
/** | ||
* Extracts array item type to perform assertions on. | ||
* | ||
* @example | ||
* ```ts | ||
* expectTypeOf([1, 2, 3]).items.toEqualTypeOf<number>() | ||
* | ||
* expectTypeOf([1, 2, 3]).items.not.toEqualTypeOf<string>() | ||
* ``` | ||
* | ||
* __Type Equivalent__: | ||
* ```ts | ||
* type Items<ArrayType> = ArrayType extends ArrayLike<infer ItemType> | ||
* ? ItemType | ||
* : never | ||
* ``` | ||
*/ | ||
items: Actual extends ArrayLike<infer ItemType> ? ExpectTypeOf<ItemType, Options> : never; | ||
/** | ||
* Extracts the type guarded by a function to perform assertions on. | ||
* | ||
* @example | ||
* ```ts | ||
* function isString(v: any): v is string { | ||
* return typeof v === 'string' | ||
* } | ||
* | ||
* expectTypeOf(isString).guards.toBeString() | ||
* ``` | ||
*/ | ||
guards: Actual extends (v: any, ...args: any[]) => v is infer T ? ExpectTypeOf<T, Options> : never; | ||
/** | ||
* Extracts the type asserted by a function to perform assertions on. | ||
* | ||
* @example | ||
* ```ts | ||
* function assertNumber(v: any): asserts v is number { | ||
* if (typeof v !== 'number') | ||
* throw new TypeError('Nope !') | ||
* } | ||
* | ||
* expectTypeOf(assertNumber).asserts.toBeNumber() | ||
* ``` | ||
*/ | ||
asserts: Actual extends (v: any, ...args: any[]) => asserts v is infer T ? unknown extends T ? never : ExpectTypeOf<T, Options> : never; | ||
} | ||
/** | ||
* Represents a function that allows asserting the expected type of a value. | ||
*/ | ||
declare type _ExpectTypeOf = { | ||
/** | ||
* Asserts the expected type of a value. | ||
* | ||
* @param actual - The actual value being asserted. | ||
* @returns An object representing the expected type assertion. | ||
*/ | ||
<Actual>(actual: Actual): ExpectTypeOf<Actual, { | ||
@@ -292,2 +1031,7 @@ positive: true; | ||
}>; | ||
/** | ||
* Asserts the expected type of a value without providing an actual value. | ||
* | ||
* @returns An object representing the expected type assertion. | ||
*/ | ||
<Actual>(): ExpectTypeOf<Actual, { | ||
@@ -534,3 +1278,4 @@ positive: true; | ||
*/ | ||
mock: (path: string, factory?: MockFactoryWithHelper) => void; | ||
mock(path: string, factory?: MockFactoryWithHelper): void; | ||
mock<T>(module: Promise<T>, factory?: MockFactoryWithHelper<T>): void; | ||
/** | ||
@@ -542,3 +1287,4 @@ * Removes module from mocked registry. All calls to import will return the original module even if it was mocked before. | ||
*/ | ||
unmock: (path: string) => void; | ||
unmock(path: string): void; | ||
unmock(module: Promise<unknown>): void; | ||
/** | ||
@@ -553,3 +1299,4 @@ * Mocks every subsequent [dynamic import](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import) call. | ||
*/ | ||
doMock: (path: string, factory?: MockFactoryWithHelper) => void; | ||
doMock(path: string, factory?: MockFactoryWithHelper): void; | ||
doMock<T>(module: Promise<T>, factory?: MockFactoryWithHelper<T>): void; | ||
/** | ||
@@ -561,3 +1308,4 @@ * Removes module from mocked registry. All subsequent calls to import will return original module. | ||
*/ | ||
doUnmock: (path: string) => void; | ||
doUnmock(path: string): void; | ||
doUnmock(module: Promise<unknown>): void; | ||
/** | ||
@@ -564,0 +1312,0 @@ * Imports module, bypassing all checks if it should be mocked. |
export { afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, onTestFinished, suite, test } from '@vitest/runner'; | ||
export { b as bench } from './vendor/benchmark.yGkUTKnC.js'; | ||
export { i as isFirstRun, a as runOnce } from './vendor/run-once.Olz_Zkd8.js'; | ||
export { c as createExpect, a as expect, v as vi, b as vitest } from './vendor/vi.YFlodzP_.js'; | ||
import { d as dist } from './vendor/index.dI9lHwVn.js'; | ||
export { b as assertType, g as getRunningMode, i as inject, a as isWatchMode } from './vendor/index.dI9lHwVn.js'; | ||
export { b as bench } from './vendor/benchmark.BNLebNi5.js'; | ||
export { i as isFirstRun, a as runOnce } from './vendor/run-once.DLomgGUH.js'; | ||
export { c as createExpect, a as expect, v as vi, b as vitest } from './vendor/vi.ClD3hi7L.js'; | ||
import { d as dist } from './vendor/index.CmILuxzC.js'; | ||
export { b as assertType, g as getRunningMode, i as inject, a as isWatchMode } from './vendor/index.CmILuxzC.js'; | ||
import * as chai from 'chai'; | ||
@@ -12,15 +12,15 @@ export { chai }; | ||
import '@vitest/utils'; | ||
import './vendor/index.SMVOaj7F.js'; | ||
import './vendor/index._7XLd8Kd.js'; | ||
import 'pathe'; | ||
import './vendor/global.CkGT_TMy.js'; | ||
import './vendor/env.AtSIuHFg.js'; | ||
import './vendor/global.7bFbnyXl.js'; | ||
import './vendor/env.bmJgw1qP.js'; | ||
import 'std-env'; | ||
import './vendor/_commonjsHelpers.jjO7Zipk.js'; | ||
import './vendor/_commonjsHelpers.BFTU3MAI.js'; | ||
import '@vitest/expect'; | ||
import '@vitest/snapshot'; | ||
import '@vitest/utils/error'; | ||
import './vendor/tasks.IknbGB2n.js'; | ||
import './vendor/tasks.WC7M-K-v.js'; | ||
import '@vitest/utils/source-map'; | ||
import './vendor/base.5NT-gWu5.js'; | ||
import './vendor/date.Ns1pGd_X.js'; | ||
import './vendor/base._gnK9Slw.js'; | ||
import './vendor/date.BKM1wewY.js'; | ||
import '@vitest/spy'; | ||
@@ -27,0 +27,0 @@ |
@@ -1,3 +0,3 @@ | ||
import { V as VitestRunMode, U as UserConfig, h as VitestOptions, i as Vitest, R as ResolvedConfig, P as ProvidedContext, j as WorkspaceProject, e as RuntimeRPC, T as TestSequencer, k as WorkspaceSpec } from './reporters-yx5ZTtEV.js'; | ||
export { p as BrowserProvider, o as BrowserProviderInitializationOptions, q as BrowserProviderOptions, r as BrowserScript, l as ProcessPool, n as TestSequencerConstructor, m as VitestPackageInstaller } from './reporters-yx5ZTtEV.js'; | ||
import { V as VitestRunMode, U as UserConfig, h as VitestOptions, i as Vitest, R as ResolvedConfig, P as ProvidedContext, j as WorkspaceProject, e as RuntimeRPC, T as TestSequencer, k as WorkspaceSpec } from './reporters-MGvT5U9f.js'; | ||
export { p as BrowserProvider, o as BrowserProviderInitializationOptions, q as BrowserProviderOptions, r as BrowserScript, l as ProcessPool, n as TestSequencerConstructor, m as VitestPackageInstaller } from './reporters-MGvT5U9f.js'; | ||
import { UserConfig as UserConfig$1, Plugin } from 'vite'; | ||
@@ -4,0 +4,0 @@ import { Writable } from 'node:stream'; |
@@ -1,8 +0,8 @@ | ||
export { b as VitestPackageInstaller, V as VitestPlugin, a as createMethodsRPC, c as createVitest, r as registerConsoleShortcuts, s as startVitest } from './vendor/cli-api.E07AF1Yq.js'; | ||
export { p as parseCLI } from './vendor/cac.EdDItJD-.js'; | ||
export { B as BaseSequencer } from './vendor/index.Q04MCqDO.js'; | ||
export { b as VitestPackageInstaller, V as VitestPlugin, a as createMethodsRPC, c as createVitest, r as registerConsoleShortcuts, s as startVitest } from './vendor/cli-api.DTeni0Qq.js'; | ||
export { p as parseCLI } from './vendor/cac.DzKZaJu2.js'; | ||
export { B as BaseSequencer } from './vendor/index.CRxYS9H3.js'; | ||
import 'pathe'; | ||
import './vendor/constants.5J7I254_.js'; | ||
import './vendor/coverage.E7sG1b3r.js'; | ||
import './vendor/index.GVFv9dZ0.js'; | ||
import './vendor/constants.5SOfHUj0.js'; | ||
import './vendor/coverage.ChSqD-qS.js'; | ||
import './vendor/index.DeR1hhfY.js'; | ||
import 'node:console'; | ||
@@ -15,6 +15,6 @@ import 'vite'; | ||
import 'node:worker_threads'; | ||
import './vendor/_commonjsHelpers.jjO7Zipk.js'; | ||
import './vendor/_commonjsHelpers.BFTU3MAI.js'; | ||
import 'os'; | ||
import 'path'; | ||
import './vendor/index.xL8XjTLv.js'; | ||
import './vendor/index.DP-km6lF.js'; | ||
import 'util'; | ||
@@ -29,8 +29,8 @@ import 'stream'; | ||
import '@vitest/runner/utils'; | ||
import './vendor/base.5NT-gWu5.js'; | ||
import './vendor/base._gnK9Slw.js'; | ||
import '@vitest/utils'; | ||
import './vendor/env.AtSIuHFg.js'; | ||
import './vendor/env.bmJgw1qP.js'; | ||
import 'std-env'; | ||
import './path.js'; | ||
import './vendor/index.8bPxjt7g.js'; | ||
import './vendor/index.BpSiYbpB.js'; | ||
import 'zlib'; | ||
@@ -51,21 +51,20 @@ import 'buffer'; | ||
import 'node:fs/promises'; | ||
import 'local-pkg'; | ||
import 'node:module'; | ||
import 'node:assert'; | ||
import 'node:util'; | ||
import 'vite-node/utils'; | ||
import 'magic-string'; | ||
import 'acorn-walk'; | ||
import '@vitest/utils/ast'; | ||
import 'strip-literal'; | ||
import './vendor/utils.dEtNIEgr.js'; | ||
import 'node:module'; | ||
import './vendor/index.SMVOaj7F.js'; | ||
import './vendor/global.CkGT_TMy.js'; | ||
import './vendor/utils.D5gGkwyH.js'; | ||
import './vendor/index._7XLd8Kd.js'; | ||
import './vendor/global.7bFbnyXl.js'; | ||
import 'node:readline'; | ||
import 'readline'; | ||
import './vendor/tasks.IknbGB2n.js'; | ||
import './vendor/tasks.WC7M-K-v.js'; | ||
import 'node:perf_hooks'; | ||
import './chunks/runtime-console.EO5ha7qv.js'; | ||
import './chunks/runtime-console.CUES-L8X.js'; | ||
import 'node:stream'; | ||
import './vendor/date.Ns1pGd_X.js'; | ||
import './vendor/date.BKM1wewY.js'; | ||
import 'execa'; | ||
import 'module'; | ||
import 'assert'; |
@@ -1,2 +0,2 @@ | ||
export { aS as BaseReporter, aJ as BasicReporter, a_ as BenchmarkBuiltinReporters, aZ as BenchmarkReportsMap, aV as BuiltinReporterOptions, aU as BuiltinReporters, aI as DefaultReporter, aK as DotReporter, aR as GithubActionsReporter, aQ as HangingProcessReporter, aO as JUnitReporter, aW as JsonAssertionResult, aL as JsonReporter, aX as JsonTestResult, aY as JsonTestResults, v as Reporter, aT as ReportersMap, aP as TapFlatReporter, aN as TapReporter, aM as VerboseReporter } from './reporters-yx5ZTtEV.js'; | ||
export { aS as BaseReporter, aJ as BasicReporter, a_ as BenchmarkBuiltinReporters, aZ as BenchmarkReportsMap, aV as BuiltinReporterOptions, aU as BuiltinReporters, aI as DefaultReporter, aK as DotReporter, aR as GithubActionsReporter, aQ as HangingProcessReporter, aO as JUnitReporter, aW as JsonAssertionResult, aL as JsonReporter, aX as JsonTestResult, aY as JsonTestResults, v as Reporter, aT as ReportersMap, aP as TapFlatReporter, aN as TapReporter, aM as VerboseReporter } from './reporters-MGvT5U9f.js'; | ||
import 'vite'; | ||
@@ -3,0 +3,0 @@ import '@vitest/runner'; |
@@ -1,20 +0,20 @@ | ||
export { a as BasicReporter, e as BenchmarkReportsMap, D as DefaultReporter, b as DotReporter, G as GithubActionsReporter, H as HangingProcessReporter, c as JUnitReporter, J as JsonReporter, R as ReportersMap, d as TapFlatReporter, T as TapReporter, V as VerboseReporter } from './vendor/index.Q04MCqDO.js'; | ||
export { a as BasicReporter, e as BenchmarkReportsMap, D as DefaultReporter, b as DotReporter, G as GithubActionsReporter, H as HangingProcessReporter, c as JUnitReporter, J as JsonReporter, R as ReportersMap, d as TapFlatReporter, T as TapReporter, V as VerboseReporter } from './vendor/index.CRxYS9H3.js'; | ||
import 'node:fs'; | ||
import 'picocolors'; | ||
import 'pathe'; | ||
import './vendor/tasks.IknbGB2n.js'; | ||
import './vendor/tasks.WC7M-K-v.js'; | ||
import '@vitest/runner/utils'; | ||
import '@vitest/utils'; | ||
import './vendor/env.AtSIuHFg.js'; | ||
import './vendor/env.bmJgw1qP.js'; | ||
import 'std-env'; | ||
import './vendor/utils.dEtNIEgr.js'; | ||
import './vendor/base.5NT-gWu5.js'; | ||
import './vendor/utils.D5gGkwyH.js'; | ||
import './vendor/base._gnK9Slw.js'; | ||
import 'node:perf_hooks'; | ||
import './vendor/index.SMVOaj7F.js'; | ||
import './vendor/global.CkGT_TMy.js'; | ||
import './chunks/runtime-console.EO5ha7qv.js'; | ||
import './vendor/index._7XLd8Kd.js'; | ||
import './vendor/global.7bFbnyXl.js'; | ||
import './chunks/runtime-console.CUES-L8X.js'; | ||
import 'node:stream'; | ||
import 'node:console'; | ||
import 'node:path'; | ||
import './vendor/date.Ns1pGd_X.js'; | ||
import './vendor/date.BKM1wewY.js'; | ||
import '@vitest/utils/source-map'; | ||
@@ -29,5 +29,4 @@ import 'node:os'; | ||
import 'vite'; | ||
import 'acorn-walk'; | ||
import 'node:process'; | ||
import './vendor/_commonjsHelpers.jjO7Zipk.js'; | ||
import './vendor/_commonjsHelpers.BFTU3MAI.js'; | ||
import 'assert'; | ||
@@ -34,0 +33,0 @@ import 'events'; |
import { VitestRunner, VitestRunnerImportSource, Suite, Task, CancelReason, Test, Custom, TaskContext, ExtendedContext } from '@vitest/runner'; | ||
import { R as ResolvedConfig } from './reporters-yx5ZTtEV.js'; | ||
import { R as ResolvedConfig } from './reporters-MGvT5U9f.js'; | ||
import * as tinybench from 'tinybench'; | ||
@@ -4,0 +4,0 @@ import 'vite'; |
import { setState, GLOBAL_EXPECT, getState } from '@vitest/expect'; | ||
import { g as getSnapshotClient, c as createExpect, v as vi } from './vendor/vi.YFlodzP_.js'; | ||
import { g as getSnapshotClient, c as createExpect, v as vi } from './vendor/vi.ClD3hi7L.js'; | ||
import 'pathe'; | ||
import { g as getFullName } from './vendor/tasks.IknbGB2n.js'; | ||
import { g as getTestName } from './vendor/tasks.WC7M-K-v.js'; | ||
import { createDefer, getSafeTimers } from '@vitest/utils'; | ||
import { g as getWorkerState } from './vendor/global.CkGT_TMy.js'; | ||
import './vendor/env.AtSIuHFg.js'; | ||
import { r as rpc } from './vendor/rpc.joBhAkyK.js'; | ||
import { g as getWorkerState } from './vendor/global.7bFbnyXl.js'; | ||
import './vendor/env.bmJgw1qP.js'; | ||
import { r as rpc } from './vendor/rpc.DRDE9Pu1.js'; | ||
import { getTests, getNames } from '@vitest/runner/utils'; | ||
import { updateTask } from '@vitest/runner'; | ||
import { a as getBenchOptions, g as getBenchFn } from './vendor/benchmark.yGkUTKnC.js'; | ||
import { a as getBenchOptions, g as getBenchFn } from './vendor/benchmark.BNLebNi5.js'; | ||
import 'chai'; | ||
import './vendor/_commonjsHelpers.jjO7Zipk.js'; | ||
import './vendor/_commonjsHelpers.BFTU3MAI.js'; | ||
import '@vitest/snapshot'; | ||
import '@vitest/utils/error'; | ||
import '@vitest/utils/source-map'; | ||
import './vendor/base.5NT-gWu5.js'; | ||
import './vendor/date.Ns1pGd_X.js'; | ||
import './vendor/base._gnK9Slw.js'; | ||
import './vendor/date.BKM1wewY.js'; | ||
import '@vitest/spy'; | ||
import 'std-env'; | ||
import './vendor/index.8bPxjt7g.js'; | ||
import './vendor/index.SMVOaj7F.js'; | ||
import './vendor/index.BpSiYbpB.js'; | ||
import './vendor/index._7XLd8Kd.js'; | ||
@@ -46,3 +46,3 @@ class VitestTestRunner { | ||
suite.result.heap = process.memoryUsage().heapUsed; | ||
if (suite.mode !== "skip" && typeof suite.filepath !== "undefined") { | ||
if (suite.mode !== "skip" && "filepath" in suite) { | ||
for (const test of getTests(suite)) { | ||
@@ -58,3 +58,3 @@ if (test.mode === "skip") { | ||
} | ||
this.workerState.current = suite.suite; | ||
this.workerState.current = suite.suite || suite.file; | ||
} | ||
@@ -65,3 +65,3 @@ onAfterRunTask(test) { | ||
test.result.heap = process.memoryUsage().heapUsed; | ||
this.workerState.current = test.suite; | ||
this.workerState.current = test.suite || test.file; | ||
} | ||
@@ -82,3 +82,3 @@ onCancel(_reason) { | ||
suite.mode = "skip"; | ||
if (suite.mode !== "skip" && typeof suite.filepath !== "undefined") { | ||
if (suite.mode !== "skip" && "filepath" in suite) { | ||
await this.snapshotClient.startCurrentRun(suite.filepath, "__default_name_", this.workerState.config.snapshotOptions); | ||
@@ -89,3 +89,2 @@ } | ||
onBeforeTryTask(test) { | ||
var _a, _b; | ||
setState({ | ||
@@ -97,4 +96,4 @@ assertionCalls: 0, | ||
expectedAssertionsNumberErrorGen: null, | ||
testPath: (_b = (_a = test.suite) == null ? void 0 : _a.file) == null ? void 0 : _b.filepath, | ||
currentTestName: getFullName(test), | ||
testPath: test.file.filepath, | ||
currentTestName: getTestName(test), | ||
snapshotState: this.snapshotClient.snapshotState | ||
@@ -101,0 +100,0 @@ }, globalThis[GLOBAL_EXPECT]); |
@@ -1,2 +0,2 @@ | ||
export { VitestNodeSnapshotEnvironment as VitestSnapshotEnvironment } from './chunks/environments-node.vcoXCoKs.js'; | ||
export { VitestNodeSnapshotEnvironment as VitestSnapshotEnvironment } from './chunks/environments-node.39w4gmlF.js'; | ||
import '@vitest/snapshot/environment'; | ||
@@ -6,4 +6,4 @@ import 'pathe'; | ||
import '@vitest/utils'; | ||
import './vendor/global.CkGT_TMy.js'; | ||
import './vendor/env.AtSIuHFg.js'; | ||
import './vendor/global.7bFbnyXl.js'; | ||
import './vendor/env.bmJgw1qP.js'; | ||
import 'std-env'; |
export { createTaskCollector, getCurrentSuite, getCurrentTest, getFn, getHooks, setFn, setHooks } from '@vitest/runner'; | ||
export { createChainable } from '@vitest/runner/utils'; | ||
export { g as getBenchFn, a as getBenchOptions } from './suite-IbNSsUWN.js'; | ||
import './reporters-yx5ZTtEV.js'; | ||
export { g as getBenchFn, a as getBenchOptions } from './suite-8WAe-urM.js'; | ||
import './reporters-MGvT5U9f.js'; | ||
import 'vite'; | ||
@@ -6,0 +6,0 @@ import 'vite-node'; |
export { createTaskCollector, getCurrentSuite, getCurrentTest, getFn, getHooks, setFn, setHooks } from '@vitest/runner'; | ||
export { createChainable } from '@vitest/runner/utils'; | ||
export { g as getBenchFn, a as getBenchOptions } from './vendor/benchmark.yGkUTKnC.js'; | ||
export { g as getBenchFn, a as getBenchOptions } from './vendor/benchmark.BNLebNi5.js'; | ||
import '@vitest/utils'; | ||
import './vendor/index.SMVOaj7F.js'; | ||
import './vendor/index._7XLd8Kd.js'; | ||
import 'pathe'; | ||
import './vendor/global.CkGT_TMy.js'; | ||
import './vendor/env.AtSIuHFg.js'; | ||
import './vendor/global.7bFbnyXl.js'; | ||
import './vendor/env.bmJgw1qP.js'; | ||
import 'std-env'; |
@@ -6,11 +6,11 @@ import { pathToFileURL } from 'node:url'; | ||
import { resolve, normalize } from 'pathe'; | ||
import { e as environments } from './vendor/index.GVFv9dZ0.js'; | ||
import { i as isChildProcess, s as setProcessTitle } from './vendor/base.5NT-gWu5.js'; | ||
import { s as setupInspect } from './vendor/inspector.IgLX3ur5.js'; | ||
import { c as createRuntimeRpc, a as rpcDone } from './vendor/rpc.joBhAkyK.js'; | ||
import { e as environments } from './vendor/index.DeR1hhfY.js'; | ||
import { i as isChildProcess, s as setProcessTitle } from './vendor/base._gnK9Slw.js'; | ||
import { s as setupInspect } from './vendor/inspector.hPQncR7V.js'; | ||
import { c as createRuntimeRpc, a as rpcDone } from './vendor/rpc.DRDE9Pu1.js'; | ||
import 'node:console'; | ||
import '@vitest/utils'; | ||
import 'node:module'; | ||
import './vendor/index.8bPxjt7g.js'; | ||
import './vendor/global.CkGT_TMy.js'; | ||
import './vendor/index.BpSiYbpB.js'; | ||
import './vendor/global.7bFbnyXl.js'; | ||
@@ -17,0 +17,0 @@ function isBuiltinEnvironment(env) { |
import * as v8 from 'v8'; | ||
import { d as BirpcOptions, e as RuntimeRPC, f as ContextRPC, W as WorkerGlobalState, g as WorkerContext, R as ResolvedConfig } from './reporters-yx5ZTtEV.js'; | ||
import { d as BirpcOptions, e as RuntimeRPC, f as ContextRPC, W as WorkerGlobalState, g as WorkerContext, R as ResolvedConfig } from './reporters-MGvT5U9f.js'; | ||
import { Awaitable } from '@vitest/utils'; | ||
@@ -4,0 +4,0 @@ import 'vite'; |
@@ -1,6 +0,6 @@ | ||
export { c as createForksRpcOptions, a as createThreadsRpcOptions, u as unwrapSerializableConfig } from './vendor/utils.0uYuCbzo.js'; | ||
export { p as provideWorkerState } from './vendor/global.CkGT_TMy.js'; | ||
export { c as createForksRpcOptions, a as createThreadsRpcOptions, u as unwrapSerializableConfig } from './vendor/utils.CUjzkRH7.js'; | ||
export { p as provideWorkerState } from './vendor/global.7bFbnyXl.js'; | ||
export { run as runVitestWorker } from './worker.js'; | ||
export { r as runVmTests } from './vendor/vm.QEE48c0T.js'; | ||
export { r as runBaseTests } from './vendor/base.Ybri3C14.js'; | ||
export { r as runVmTests } from './vendor/vm.Bi3bljci.js'; | ||
export { r as runBaseTests } from './vendor/base.VFkIJ66g.js'; | ||
import '@vitest/utils'; | ||
@@ -12,18 +12,18 @@ import 'node:url'; | ||
import 'pathe'; | ||
import './vendor/index.GVFv9dZ0.js'; | ||
import './vendor/index.DeR1hhfY.js'; | ||
import 'node:console'; | ||
import './vendor/base.5NT-gWu5.js'; | ||
import './vendor/inspector.IgLX3ur5.js'; | ||
import './vendor/base._gnK9Slw.js'; | ||
import './vendor/inspector.hPQncR7V.js'; | ||
import 'node:module'; | ||
import './vendor/rpc.joBhAkyK.js'; | ||
import './vendor/index.8bPxjt7g.js'; | ||
import './vendor/rpc.DRDE9Pu1.js'; | ||
import './vendor/index.BpSiYbpB.js'; | ||
import 'node:vm'; | ||
import './chunks/runtime-console.EO5ha7qv.js'; | ||
import './chunks/runtime-console.CUES-L8X.js'; | ||
import 'node:stream'; | ||
import 'node:path'; | ||
import './vendor/date.Ns1pGd_X.js'; | ||
import './vendor/date.BKM1wewY.js'; | ||
import '@vitest/runner/utils'; | ||
import './vendor/env.AtSIuHFg.js'; | ||
import './vendor/env.bmJgw1qP.js'; | ||
import 'std-env'; | ||
import './vendor/execute.fL3szUAI.js'; | ||
import './vendor/execute.CLLNVNnK.js'; | ||
import 'vite-node/utils'; | ||
@@ -30,0 +30,0 @@ import '@vitest/utils/error'; |
import v8 from 'node:v8'; | ||
import { c as createForksRpcOptions, u as unwrapSerializableConfig } from '../vendor/utils.0uYuCbzo.js'; | ||
import { r as runBaseTests } from '../vendor/base.Ybri3C14.js'; | ||
import { c as createForksRpcOptions, u as unwrapSerializableConfig } from '../vendor/utils.CUjzkRH7.js'; | ||
import { r as runBaseTests } from '../vendor/base.VFkIJ66g.js'; | ||
import '@vitest/utils'; | ||
import 'vite-node/client'; | ||
import '../vendor/global.CkGT_TMy.js'; | ||
import '../vendor/execute.fL3szUAI.js'; | ||
import '../vendor/global.7bFbnyXl.js'; | ||
import '../vendor/execute.CLLNVNnK.js'; | ||
import 'node:vm'; | ||
@@ -15,3 +15,3 @@ import 'node:url'; | ||
import '../path.js'; | ||
import '../vendor/base.5NT-gWu5.js'; | ||
import '../vendor/base._gnK9Slw.js'; | ||
@@ -18,0 +18,0 @@ class ForksBaseWorker { |
@@ -9,8 +9,8 @@ import { isatty } from 'node:tty'; | ||
import { installSourcemapsSupport } from 'vite-node/source-map'; | ||
import { s as setupChaiConfig, r as resolveTestRunner, a as resolveSnapshotEnvironment } from '../vendor/index.DpVgvm2P.js'; | ||
import { a as startCoverageInsideWorker, s as stopCoverageInsideWorker } from '../vendor/coverage.E7sG1b3r.js'; | ||
import { g as getWorkerState } from '../vendor/global.CkGT_TMy.js'; | ||
import { V as VitestIndex } from '../vendor/index.dI9lHwVn.js'; | ||
import { s as setupCommonEnv } from '../vendor/setup-common.8nJLd4ay.js'; | ||
import { c as closeInspector } from '../vendor/inspector.IgLX3ur5.js'; | ||
import { s as setupChaiConfig, r as resolveTestRunner, a as resolveSnapshotEnvironment } from '../vendor/index.BfoZyXD1.js'; | ||
import { a as startCoverageInsideWorker, s as stopCoverageInsideWorker } from '../vendor/coverage.ChSqD-qS.js'; | ||
import { g as getWorkerState } from '../vendor/global.7bFbnyXl.js'; | ||
import { V as VitestIndex } from '../vendor/index.CmILuxzC.js'; | ||
import { s as setupCommonEnv } from '../vendor/setup-common.XeoZAW8t.js'; | ||
import { c as closeInspector } from '../vendor/inspector.hPQncR7V.js'; | ||
import 'chai'; | ||
@@ -20,19 +20,19 @@ import 'pathe'; | ||
import 'node:url'; | ||
import '../vendor/rpc.joBhAkyK.js'; | ||
import '../vendor/index.8bPxjt7g.js'; | ||
import '../vendor/benchmark.yGkUTKnC.js'; | ||
import '../vendor/rpc.DRDE9Pu1.js'; | ||
import '../vendor/index.BpSiYbpB.js'; | ||
import '../vendor/benchmark.BNLebNi5.js'; | ||
import '@vitest/runner/utils'; | ||
import '../vendor/index.SMVOaj7F.js'; | ||
import '../vendor/env.AtSIuHFg.js'; | ||
import '../vendor/index._7XLd8Kd.js'; | ||
import '../vendor/env.bmJgw1qP.js'; | ||
import 'std-env'; | ||
import '../vendor/run-once.Olz_Zkd8.js'; | ||
import '../vendor/vi.YFlodzP_.js'; | ||
import '../vendor/_commonjsHelpers.jjO7Zipk.js'; | ||
import '../vendor/run-once.DLomgGUH.js'; | ||
import '../vendor/vi.ClD3hi7L.js'; | ||
import '../vendor/_commonjsHelpers.BFTU3MAI.js'; | ||
import '@vitest/expect'; | ||
import '@vitest/snapshot'; | ||
import '@vitest/utils/error'; | ||
import '../vendor/tasks.IknbGB2n.js'; | ||
import '../vendor/tasks.WC7M-K-v.js'; | ||
import '@vitest/utils/source-map'; | ||
import '../vendor/base.5NT-gWu5.js'; | ||
import '../vendor/date.Ns1pGd_X.js'; | ||
import '../vendor/base._gnK9Slw.js'; | ||
import '../vendor/date.BKM1wewY.js'; | ||
import '@vitest/spy'; | ||
@@ -39,0 +39,0 @@ |
@@ -1,6 +0,6 @@ | ||
import { r as runBaseTests } from '../vendor/base.Ybri3C14.js'; | ||
import { a as createThreadsRpcOptions } from '../vendor/utils.0uYuCbzo.js'; | ||
import { r as runBaseTests } from '../vendor/base.VFkIJ66g.js'; | ||
import { a as createThreadsRpcOptions } from '../vendor/utils.CUjzkRH7.js'; | ||
import 'vite-node/client'; | ||
import '../vendor/global.CkGT_TMy.js'; | ||
import '../vendor/execute.fL3szUAI.js'; | ||
import '../vendor/global.7bFbnyXl.js'; | ||
import '../vendor/execute.CLLNVNnK.js'; | ||
import 'node:vm'; | ||
@@ -14,3 +14,3 @@ import 'node:url'; | ||
import '@vitest/utils'; | ||
import '../vendor/base.5NT-gWu5.js'; | ||
import '../vendor/base._gnK9Slw.js'; | ||
@@ -17,0 +17,0 @@ class ThreadsBaseWorker { |
import v8 from 'node:v8'; | ||
import { c as createForksRpcOptions, u as unwrapSerializableConfig } from '../vendor/utils.0uYuCbzo.js'; | ||
import { r as runVmTests } from '../vendor/vm.QEE48c0T.js'; | ||
import { c as createForksRpcOptions, u as unwrapSerializableConfig } from '../vendor/utils.CUjzkRH7.js'; | ||
import { r as runVmTests } from '../vendor/vm.Bi3bljci.js'; | ||
import '@vitest/utils'; | ||
@@ -8,12 +8,12 @@ import 'node:vm'; | ||
import 'pathe'; | ||
import '../chunks/runtime-console.EO5ha7qv.js'; | ||
import '../chunks/runtime-console.CUES-L8X.js'; | ||
import 'node:stream'; | ||
import 'node:console'; | ||
import 'node:path'; | ||
import '../vendor/date.Ns1pGd_X.js'; | ||
import '../vendor/date.BKM1wewY.js'; | ||
import '@vitest/runner/utils'; | ||
import '../vendor/global.CkGT_TMy.js'; | ||
import '../vendor/env.AtSIuHFg.js'; | ||
import '../vendor/global.7bFbnyXl.js'; | ||
import '../vendor/env.bmJgw1qP.js'; | ||
import 'std-env'; | ||
import '../vendor/execute.fL3szUAI.js'; | ||
import '../vendor/execute.CLLNVNnK.js'; | ||
import 'node:fs'; | ||
@@ -24,3 +24,3 @@ import 'vite-node/client'; | ||
import '../path.js'; | ||
import '../vendor/base.5NT-gWu5.js'; | ||
import '../vendor/base._gnK9Slw.js'; | ||
import 'node:module'; | ||
@@ -27,0 +27,0 @@ import 'vite-node/constants'; |
@@ -1,3 +0,3 @@ | ||
import { a as createThreadsRpcOptions } from '../vendor/utils.0uYuCbzo.js'; | ||
import { r as runVmTests } from '../vendor/vm.QEE48c0T.js'; | ||
import { a as createThreadsRpcOptions } from '../vendor/utils.CUjzkRH7.js'; | ||
import { r as runVmTests } from '../vendor/vm.Bi3bljci.js'; | ||
import '@vitest/utils'; | ||
@@ -7,12 +7,12 @@ import 'node:vm'; | ||
import 'pathe'; | ||
import '../chunks/runtime-console.EO5ha7qv.js'; | ||
import '../chunks/runtime-console.CUES-L8X.js'; | ||
import 'node:stream'; | ||
import 'node:console'; | ||
import 'node:path'; | ||
import '../vendor/date.Ns1pGd_X.js'; | ||
import '../vendor/date.BKM1wewY.js'; | ||
import '@vitest/runner/utils'; | ||
import '../vendor/global.CkGT_TMy.js'; | ||
import '../vendor/env.AtSIuHFg.js'; | ||
import '../vendor/global.7bFbnyXl.js'; | ||
import '../vendor/env.bmJgw1qP.js'; | ||
import 'std-env'; | ||
import '../vendor/execute.fL3szUAI.js'; | ||
import '../vendor/execute.CLLNVNnK.js'; | ||
import 'node:fs'; | ||
@@ -23,3 +23,3 @@ import 'vite-node/client'; | ||
import '../path.js'; | ||
import '../vendor/base.5NT-gWu5.js'; | ||
import '../vendor/base._gnK9Slw.js'; | ||
import 'node:module'; | ||
@@ -26,0 +26,0 @@ import 'vite-node/constants'; |
{ | ||
"name": "vitest", | ||
"type": "module", | ||
"version": "1.6.0", | ||
"version": "2.0.0-beta.1", | ||
"description": "Next generation testing framework powered by Vite", | ||
@@ -122,4 +122,4 @@ "author": "Anthony Fu <anthonyfu117@hotmail.com>", | ||
"jsdom": "*", | ||
"@vitest/browser": "1.6.0", | ||
"@vitest/ui": "1.6.0" | ||
"@vitest/ui": "2.0.0-beta.1", | ||
"@vitest/browser": "2.0.0-beta.1" | ||
}, | ||
@@ -147,27 +147,24 @@ "peerDependenciesMeta": { | ||
"dependencies": { | ||
"acorn-walk": "^8.3.2", | ||
"chai": "^4.3.10", | ||
"chai": "^5.1.1", | ||
"debug": "^4.3.4", | ||
"execa": "^8.0.1", | ||
"local-pkg": "^0.5.0", | ||
"magic-string": "^0.30.5", | ||
"pathe": "^1.1.1", | ||
"magic-string": "^0.30.10", | ||
"pathe": "^1.1.2", | ||
"picocolors": "^1.0.0", | ||
"std-env": "^3.5.0", | ||
"strip-literal": "^2.0.0", | ||
"tinybench": "^2.5.1", | ||
"tinypool": "^0.8.3", | ||
"std-env": "^3.7.0", | ||
"tinybench": "^2.8.0", | ||
"tinypool": "^0.8.4", | ||
"vite": "^5.0.0", | ||
"why-is-node-running": "^2.2.2", | ||
"@vitest/expect": "1.6.0", | ||
"@vitest/runner": "1.6.0", | ||
"@vitest/snapshot": "1.6.0", | ||
"@vitest/spy": "1.6.0", | ||
"vite-node": "1.6.0", | ||
"@vitest/utils": "1.6.0" | ||
"@vitest/runner": "2.0.0-beta.1", | ||
"@vitest/expect": "2.0.0-beta.1", | ||
"@vitest/snapshot": "2.0.0-beta.1", | ||
"@vitest/utils": "2.0.0-beta.1", | ||
"@vitest/spy": "2.0.0-beta.1", | ||
"vite-node": "2.0.0-beta.1" | ||
}, | ||
"devDependencies": { | ||
"@ampproject/remapping": "^2.2.1", | ||
"@antfu/install-pkg": "^0.3.1", | ||
"@edge-runtime/vm": "^3.1.8", | ||
"@ampproject/remapping": "^2.3.0", | ||
"@antfu/install-pkg": "0.3.1", | ||
"@edge-runtime/vm": "^3.2.0", | ||
"@sinonjs/fake-timers": "11.1.0", | ||
@@ -178,17 +175,19 @@ "@types/estree": "^1.0.5", | ||
"@types/jsdom": "^21.1.6", | ||
"@types/micromatch": "^4.0.6", | ||
"@types/node": "^20.11.5", | ||
"@types/micromatch": "^4.0.7", | ||
"@types/node": "^20.12.11", | ||
"@types/prompts": "^2.4.9", | ||
"@types/sinonjs__fake-timers": "^8.1.5", | ||
"birpc": "0.2.15", | ||
"acorn-walk": "^8.3.2", | ||
"birpc": "0.2.17", | ||
"cac": "^6.7.14", | ||
"chai-subset": "^1.6.0", | ||
"cli-truncate": "^4.0.0", | ||
"expect-type": "^0.17.3", | ||
"expect-type": "^0.19.0", | ||
"fast-glob": "^3.3.2", | ||
"find-up": "^6.3.0", | ||
"flatted": "^3.2.9", | ||
"get-tsconfig": "^4.7.3", | ||
"happy-dom": "^14.3.10", | ||
"flatted": "^3.3.1", | ||
"get-tsconfig": "^4.7.4", | ||
"happy-dom": "^14.10.1", | ||
"jsdom": "^24.0.0", | ||
"local-pkg": "^0.5.0", | ||
"log-update": "^5.0.1", | ||
@@ -200,3 +199,4 @@ "micromatch": "^4.0.5", | ||
"strip-ansi": "^7.1.0", | ||
"ws": "^8.14.2" | ||
"strip-literal": "^2.1.0", | ||
"ws": "^8.17.0" | ||
}, | ||
@@ -203,0 +203,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
1548871
23
41770
61
33
95
1
+ Added@types/node@22.8.4(transitive)
+ Added@vitest/browser@2.0.0-beta.1(transitive)
+ Added@vitest/expect@2.0.0-beta.1(transitive)
+ Added@vitest/runner@2.0.0-beta.1(transitive)
+ Added@vitest/snapshot@2.0.0-beta.1(transitive)
+ Added@vitest/spy@2.0.0-beta.1(transitive)
+ Added@vitest/ui@2.0.0-beta.1(transitive)
+ Added@vitest/utils@2.0.0-beta.1(transitive)
+ Addedassertion-error@2.0.1(transitive)
+ Addedchai@5.1.2(transitive)
+ Addedcheck-error@2.1.1(transitive)
+ Addeddeep-eql@5.0.2(transitive)
+ Addedloupe@3.1.2(transitive)
+ Addedpathval@2.0.0(transitive)
+ Addedvite-node@2.0.0-beta.1(transitive)
- Removedacorn-walk@^8.3.2
- Removedlocal-pkg@^0.5.0
- Removedstrip-literal@^2.0.0
- Removed@types/node@22.8.6(transitive)
- Removed@vitest/browser@1.6.0(transitive)
- Removed@vitest/expect@1.6.0(transitive)
- Removed@vitest/runner@1.6.0(transitive)
- Removed@vitest/snapshot@1.6.0(transitive)
- Removed@vitest/spy@1.6.0(transitive)
- Removed@vitest/ui@1.6.0(transitive)
- Removed@vitest/utils@1.6.0(transitive)
- Removedacorn@8.14.0(transitive)
- Removedacorn-walk@8.3.4(transitive)
- Removedassertion-error@1.1.0(transitive)
- Removedchai@4.5.0(transitive)
- Removedcheck-error@1.0.3(transitive)
- Removedconfbox@0.1.8(transitive)
- Removeddeep-eql@4.1.4(transitive)
- Removedget-func-name@2.0.2(transitive)
- Removedjs-tokens@9.0.0(transitive)
- Removedlocal-pkg@0.5.0(transitive)
- Removedloupe@2.3.7(transitive)
- Removedmlly@1.7.2(transitive)
- Removedpathval@1.1.1(transitive)
- Removedpkg-types@1.2.1(transitive)
- Removedstrip-literal@2.1.0(transitive)
- Removedtype-detect@4.1.0(transitive)
- Removedufo@1.5.4(transitive)
- Removedvite-node@1.6.0(transitive)
Updated@vitest/expect@2.0.0-beta.1
Updated@vitest/runner@2.0.0-beta.1
Updated@vitest/spy@2.0.0-beta.1
Updated@vitest/utils@2.0.0-beta.1
Updatedchai@^5.1.1
Updatedmagic-string@^0.30.10
Updatedpathe@^1.1.2
Updatedstd-env@^3.7.0
Updatedtinybench@^2.8.0
Updatedtinypool@^0.8.4
Updatedvite-node@2.0.0-beta.1