Socket
Socket
Sign inDemoInstall

@vitest/spy

Package Overview
Dependencies
Maintainers
4
Versions
95
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 1.2.2 to 1.3.0

32

dist/index.d.ts

@@ -108,7 +108,7 @@ interface MockResultReturn<T> {

*/
getMockName(): string;
getMockName: () => string;
/**
* Sets internal mock name. Useful to see the name of the mock if an assertion fails.
*/
mockName(n: string): this;
mockName: (n: string) => this;
/**

@@ -123,3 +123,3 @@ * Current context of the mock. It stores information about all invocation calls, instances, and results.

*/
mockClear(): this;
mockClear: () => this;
/**

@@ -130,3 +130,3 @@ * Does what `mockClear` does and makes inner implementation an empty function (returning `undefined` when invoked). This also resets all "once" implementations.

*/
mockReset(): this;
mockReset: () => this;
/**

@@ -137,3 +137,3 @@ * Does what `mockReset` does and restores inner implementation to the original function.

*/
mockRestore(): void;
mockRestore: () => void;
/**

@@ -146,3 +146,3 @@ * Returns current mock implementation if there is one.

*/
getMockImplementation(): ((...args: TArgs) => TReturns) | undefined;
getMockImplementation: () => ((...args: TArgs) => TReturns) | undefined;
/**

@@ -154,3 +154,3 @@ * Accepts a function that will be used as an implementation of the mock.

*/
mockImplementation(fn: ((...args: TArgs) => TReturns)): this;
mockImplementation: (fn: ((...args: TArgs) => TReturns)) => this;
/**

@@ -163,3 +163,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: ((...args: TArgs) => TReturns)): this;
mockImplementationOnce: (fn: ((...args: TArgs) => TReturns)) => this;
/**

@@ -176,11 +176,11 @@ * Overrides the original mock implementation temporarily while the callback is being executed.

*/
withImplementation<T>(fn: ((...args: TArgs) => TReturns), cb: () => T): T extends Promise<unknown> ? Promise<this> : this;
withImplementation: <T>(fn: ((...args: TArgs) => TReturns), cb: () => T) => T extends Promise<unknown> ? Promise<this> : this;
/**
* Use this if you need to return `this` context from the method without invoking actual implementation.
*/
mockReturnThis(): this;
mockReturnThis: () => this;
/**
* Accepts a value that will be returned whenever the mock function is called.
*/
mockReturnValue(obj: TReturns): this;
mockReturnValue: (obj: TReturns) => this;
/**

@@ -200,3 +200,3 @@ * Accepts a value that will be returned during the next function call. If chained, every consecutive call will return the specified value.

*/
mockReturnValueOnce(obj: TReturns): this;
mockReturnValueOnce: (obj: TReturns) => this;
/**

@@ -208,3 +208,3 @@ * Accepts a value that will be resolved when async function is called.

*/
mockResolvedValue(obj: Awaited<TReturns>): this;
mockResolvedValue: (obj: Awaited<TReturns>) => this;
/**

@@ -222,3 +222,3 @@ * Accepts a value that will be resolved during the next function call. If chained, every consecutive call will resolve specified value.

*/
mockResolvedValueOnce(obj: Awaited<TReturns>): this;
mockResolvedValueOnce: (obj: Awaited<TReturns>) => this;
/**

@@ -230,3 +230,3 @@ * Accepts an error that will be rejected when async function is called.

*/
mockRejectedValue(obj: any): this;
mockRejectedValue: (obj: any) => this;
/**

@@ -243,3 +243,3 @@ * Accepts a value that will be rejected during the next function call. If chained, every consecutive call will reject specified value.

*/
mockRejectedValueOnce(obj: any): this;
mockRejectedValueOnce: (obj: any) => this;
}

@@ -246,0 +246,0 @@ interface Mock<TArgs extends any[] = any, TReturns = any> extends MockInstance<TArgs, TReturns> {

{
"name": "@vitest/spy",
"type": "module",
"version": "1.2.2",
"version": "1.3.0",
"description": "Lightweight Jest compatible spy implementation",

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc