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.31.0 to 0.31.1

22

./dist/index.js

@@ -45,2 +45,9 @@ import * as tinyspy from 'tinyspy';

let implementationChangedTemporarily = false;
function mockCall(...args) {
instances.push(this);
invocations.push(++callOrder);
const impl = implementationChangedTemporarily ? implementation : onceImplementations.shift() || implementation || state.getOriginal() || (() => {
});
return impl.apply(this, args);
}
let name = stub.name;

@@ -66,2 +73,3 @@ stub.getMockName = () => name || "vi.fn()";

stub.mockReset();
state.restore();
implementation = void 0;

@@ -73,2 +81,3 @@ return stub;

implementation = fn2;
state.willCall(mockCall);
return stub;

@@ -83,2 +92,3 @@ };

implementation = fn2;
state.willCall(mockCall);
implementationChangedTemporarily = true;

@@ -112,9 +122,3 @@ const reset = () => {

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

@@ -124,4 +128,4 @@ return stub;

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

@@ -128,0 +132,0 @@ enhancedSpy.mockImplementation(implementation);

@@ -45,2 +45,9 @@ import * as tinyspy from 'tinyspy';

let implementationChangedTemporarily = false;
function mockCall(...args) {
instances.push(this);
invocations.push(++callOrder);
const impl = implementationChangedTemporarily ? implementation : onceImplementations.shift() || implementation || state.getOriginal() || (() => {
});
return impl.apply(this, args);
}
let name = stub.name;

@@ -66,2 +73,3 @@ stub.getMockName = () => name || "vi.fn()";

stub.mockReset();
state.restore();
implementation = void 0;

@@ -73,2 +81,3 @@ return stub;

implementation = fn2;
state.willCall(mockCall);
return stub;

@@ -83,2 +92,3 @@ };

implementation = fn2;
state.willCall(mockCall);
implementationChangedTemporarily = true;

@@ -112,9 +122,3 @@ const reset = () => {

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

@@ -124,4 +128,4 @@ return stub;

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

@@ -128,0 +132,0 @@ enhancedSpy.mockImplementation(implementation);

{
"name": "@vitest/spy",
"type": "module",
"version": "0.31.0",
"version": "0.31.1",
"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