Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@vitest/spy

Package Overview
Dependencies
Maintainers
4
Versions
106
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 3.0.0-beta.1 to 3.0.0-beta.2

18

dist/index.js
import * as tinyspy from 'tinyspy';
const vitestSpy = Symbol.for("vitest.spy");
const mocks = /* @__PURE__ */ new Set();

@@ -7,2 +8,11 @@ function isMockFunction(fn2) {

}
function getSpy(obj, method, accessType) {
const desc = Object.getOwnPropertyDescriptor(obj, method);
if (desc) {
const fn2 = desc[accessType ?? "value"];
if (typeof fn2 === "function" && vitestSpy in fn2) {
return fn2;
}
}
}
function spyOn(obj, method, accessType) {

@@ -14,2 +24,6 @@ const dictionary = {

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

@@ -66,2 +80,6 @@ return enhanceSpy(stub);

let name = stub.name;
Object.defineProperty(stub, vitestSpy, {
value: true,
enumerable: false
});
stub.getMockName = () => name || "vi.fn()";

@@ -68,0 +86,0 @@ stub.mockName = (n) => {

2

package.json
{
"name": "@vitest/spy",
"type": "module",
"version": "3.0.0-beta.1",
"version": "3.0.0-beta.2",
"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