You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP
Socket
Sign inDemoInstall
Socket

@vitest/spy

Package Overview
Dependencies
Maintainers
4
Versions
124
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vitest/spy - npm Package Compare versions

Comparing version

to
3.0.0-beta.4

17

dist/index.d.ts

@@ -138,3 +138,3 @@ interface MockResultReturn<T> {

type Procedure = (...args: any[]) => any;
type NormalizedPrecedure<T extends Procedure> = (...args: Parameters<T>) => ReturnType<T>;
type NormalizedProcedure<T extends Procedure> = (...args: Parameters<T>) => ReturnType<T>;
type Methods<T> = keyof {

@@ -189,10 +189,9 @@ [K in keyof T as T[K] extends Procedure ? K : never]: T[K];

/**
* Performs the same actions as `mockReset` and restores the inner implementation to the original function.
* Returns current permanent mock implementation if there is one.
*
* Note that restoring a mock created with `vi.fn()` will set the implementation to an empty function that returns `undefined`. Restoring a mock created with `vi.fn(impl)` will restore the implementation to `impl`.
* If mock was created with `vi.fn`, it will consider passed down method as a mock implementation.
*
* To automatically call this method before each test, enable the [`restoreMocks`](https://vitest.dev/config/#restoremocks) setting in the configuration.
* @see https://vitest.dev/api/mock#getmockimplementation
* If mock was created with `vi.spyOn`, it will return `undefined` unless a custom implementation was provided.
*/
getMockImplementation(): NormalizedPrecedure<T> | undefined;
getMockImplementation(): NormalizedProcedure<T> | undefined;
/**

@@ -205,3 +204,3 @@ * Accepts a function to be used as the mock implementation. TypeScript expects the arguments and return type to match those of the original function.

*/
mockImplementation(fn: NormalizedPrecedure<T>): this;
mockImplementation(fn: NormalizedProcedure<T>): this;
/**

@@ -217,3 +216,3 @@ * Accepts a function to be used as the mock implementation. TypeScript expects the arguments and return type to match those of the original function. This method can be chained to produce different results for multiple function calls.

*/
mockImplementationOnce(fn: NormalizedPrecedure<T>): this;
mockImplementationOnce(fn: NormalizedProcedure<T>): this;
/**

@@ -233,3 +232,3 @@ * Overrides the original mock implementation temporarily while the callback is being executed.

*/
withImplementation<T2>(fn: NormalizedPrecedure<T>, cb: () => T2): T2 extends Promise<unknown> ? Promise<this> : this;
withImplementation<T2>(fn: NormalizedProcedure<T>, cb: () => T2): T2 extends Promise<unknown> ? Promise<this> : this;
/**

@@ -236,0 +235,0 @@ * Use this if you need to return the `this` context from the method without invoking the actual implementation.

@@ -105,3 +105,3 @@ import * as tinyspy from 'tinyspy';

};
stub.getMockImplementation = () => implementation;
stub.getMockImplementation = () => implementationChangedTemporarily ? implementation : onceImplementations.at(0) || implementation;
stub.mockImplementation = (fn2) => {

@@ -108,0 +108,0 @@ implementation = fn2;

{
"name": "@vitest/spy",
"type": "module",
"version": "3.0.0-beta.3",
"version": "3.0.0-beta.4",
"description": "Lightweight Jest compatible spy implementation",

@@ -6,0 +6,0 @@ "license": "MIT",