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.0-beta.10 to 2.0.0-beta.11

10

dist/index.d.ts

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

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

@@ -195,3 +195,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;
/**

@@ -208,3 +208,3 @@ * 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;
/**

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

declare function spyOn<T, G extends Properties<Required<T>>>(obj: T, methodName: G, accessType: 'set'): MockInstance<[T[G]], void>;
declare function spyOn<T, M extends (Classes<Required<T>> | Methods<Required<T>>)>(obj: T, methodName: M): Required<T>[M] extends ({
declare function spyOn<T, M extends Classes<Required<T>> | Methods<Required<T>>>(obj: T, methodName: M): Required<T>[M] extends {
new (...args: infer A): infer R;
}) | ((...args: infer A) => infer R) ? MockInstance<A, R> : never;
} | ((...args: infer A) => infer R) ? MockInstance<A, R> : never;
declare function fn<TArgs extends any[] = any, R = any>(): Mock<TArgs, R>;

@@ -324,0 +324,0 @@ declare function fn<TArgs extends any[] = any[], R = any>(implementation: (...args: TArgs) => R): Mock<TArgs, R>;

@@ -129,6 +129,9 @@ import * as tinyspy from 'tinyspy';

function fn(implementation) {
const enhancedSpy = enhanceSpy(tinyspy.internalSpyOn({ spy: implementation || (() => {
}) }, "spy"));
if (implementation)
const enhancedSpy = enhanceSpy(
tinyspy.internalSpyOn({ spy: implementation || (() => {
}) }, "spy")
);
if (implementation) {
enhancedSpy.mockImplementation(implementation);
}
return enhancedSpy;

@@ -135,0 +138,0 @@ }

{
"name": "@vitest/spy",
"type": "module",
"version": "2.0.0-beta.10",
"version": "2.0.0-beta.11",
"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