Socket
Socket
Sign inDemoInstall

@vitest/spy

Package Overview
Dependencies
Maintainers
3
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 0.29.8 to 0.30.0

./dist/index.js

4

dist/index.d.ts

@@ -1,2 +0,2 @@

import { SpyImpl } from 'tinyspy';
import { SpyInternalImpl } from 'tinyspy';

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

} & T;
type EnhancedSpy<TArgs extends any[] = any[], TReturns = any> = SpyInstance<TArgs, TReturns> & SpyImpl<TArgs, TReturns>;
type EnhancedSpy<TArgs extends any[] = any[], TReturns = any> = SpyInstance<TArgs, TReturns> & SpyInternalImpl<TArgs, TReturns>;
declare const spies: Set<SpyInstance<any[], any>>;

@@ -99,0 +99,0 @@ declare function isMockFunction(fn: any): fn is EnhancedSpy;

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

const objMethod = accessType ? { [dictionary[accessType]]: method } : method;
const stub = tinyspy.spyOn(obj, objMethod);
const stub = tinyspy.internalSpyOn(obj, objMethod);
return enhanceSpy(stub);

@@ -23,5 +23,6 @@ }

let invocations = [];
const state = tinyspy.getInternalState(spy);
const mockContext = {
get calls() {
return stub.calls;
return state.calls;
},

@@ -35,3 +36,3 @@ get instances() {

get results() {
return stub.results.map(([callType, value]) => {
return state.results.map(([callType, value]) => {
const type = callType === "error" ? "throw" : "return";

@@ -42,3 +43,3 @@ return { type, value };

get lastCall() {
return stub.calls[stub.calls.length - 1];
return state.calls[state.calls.length - 1];
}

@@ -55,3 +56,3 @@ };

stub.mockClear = () => {
stub.reset();
state.reset();
instances = [];

@@ -112,6 +113,6 @@ invocations = [];

});
stub.willCall(function(...args) {
state.willCall(function(...args) {
instances.push(this);
invocations.push(++callOrder);
const impl = implementationChangedTemporarily ? implementation : onceImplementations.shift() || implementation || stub.getOriginal() || (() => {
const impl = implementationChangedTemporarily ? implementation : onceImplementations.shift() || implementation || state.getOriginal() || (() => {
});

@@ -124,3 +125,3 @@ return impl.apply(this, args);

function fn(implementation) {
return enhanceSpy(tinyspy.spyOn({ fn: implementation || (() => {
return enhanceSpy(tinyspy.internalSpyOn({ fn: implementation || (() => {
}) }, "fn"));

@@ -127,0 +128,0 @@ }

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

@@ -27,3 +27,3 @@ "license": "MIT",

"dependencies": {
"tinyspy": "^1.0.2"
"tinyspy": "^2.1.0"
},

@@ -30,0 +30,0 @@ "scripts": {

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