@vitest/spy
Advanced tools
Comparing version 2.0.3 to 2.0.4
@@ -131,2 +131,3 @@ interface MockResultReturn<T> { | ||
type Procedure = (...args: any[]) => any; | ||
type NormalizedPrecedure<T extends Procedure> = (...args: Parameters<T>) => ReturnType<T>; | ||
type Methods<T> = keyof { | ||
@@ -179,3 +180,3 @@ [K in keyof T as T[K] extends Procedure ? K : never]: T[K]; | ||
*/ | ||
getMockImplementation(): T | undefined; | ||
getMockImplementation(): NormalizedPrecedure<T> | undefined; | ||
/** | ||
@@ -187,3 +188,3 @@ * Accepts a function that will be used as an implementation of the mock. | ||
*/ | ||
mockImplementation(fn: T): this; | ||
mockImplementation(fn: NormalizedPrecedure<T>): this; | ||
/** | ||
@@ -196,3 +197,3 @@ * Accepts a function that will be used as a mock implementation during the next call. Can be chained so that multiple function calls produce different results. | ||
*/ | ||
mockImplementationOnce(fn: T): this; | ||
mockImplementationOnce(fn: NormalizedPrecedure<T>): this; | ||
/** | ||
@@ -209,3 +210,3 @@ * Overrides the original mock implementation temporarily while the callback is being executed. | ||
*/ | ||
withImplementation<T2>(fn: T, cb: () => T2): T2 extends Promise<unknown> ? Promise<this> : this; | ||
withImplementation<T2>(fn: NormalizedPrecedure<T>, cb: () => T2): T2 extends Promise<unknown> ? Promise<this> : this; | ||
/** | ||
@@ -317,3 +318,3 @@ * Use this if you need to return `this` context from the method without invoking actual implementation. | ||
} & T; | ||
declare const mocks: Set<MockInstance<Procedure>>; | ||
declare const mocks: Set<MockInstance>; | ||
declare function isMockFunction(fn: any): fn is MockInstance; | ||
@@ -320,0 +321,0 @@ declare function spyOn<T, S extends Properties<Required<T>>>(obj: T, methodName: S, accessType: 'get'): MockInstance<() => T[S]>; |
{ | ||
"name": "@vitest/spy", | ||
"type": "module", | ||
"version": "2.0.3", | ||
"version": "2.0.4", | ||
"description": "Lightweight Jest compatible spy implementation", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
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
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
19106
465