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 2.0.3 to 2.0.4

11

dist/index.d.ts

@@ -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",

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