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

jest-mock

Package Overview
Dependencies
Maintainers
7
Versions
238
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jest-mock - npm Package Compare versions

Comparing version 26.6.0 to 26.6.1

54

build/index.js

@@ -800,18 +800,46 @@ 'use strict';

const isMethodOwner = object.hasOwnProperty(methodName); // @ts-expect-error overriding original method with a Mock
const isMethodOwner = object.hasOwnProperty(methodName);
let descriptor = Object.getOwnPropertyDescriptor(object, methodName);
let proto = Object.getPrototypeOf(object);
object[methodName] = this._makeComponent(
{
type: 'function'
},
() => {
if (isMethodOwner) {
object[methodName] = original;
} else {
delete object[methodName];
while (!descriptor && proto !== null) {
descriptor = Object.getOwnPropertyDescriptor(proto, methodName);
proto = Object.getPrototypeOf(proto);
}
let mock;
if (descriptor && descriptor.get) {
const originalGet = descriptor.get;
mock = this._makeComponent(
{
type: 'function'
},
() => {
descriptor.get = originalGet;
Object.defineProperty(object, methodName, descriptor);
}
}
); // @ts-expect-error original method is now a Mock
);
object[methodName].mockImplementation(function () {
descriptor.get = () => mock;
Object.defineProperty(object, methodName, descriptor);
} else {
mock = this._makeComponent(
{
type: 'function'
},
() => {
if (isMethodOwner) {
object[methodName] = original;
} else {
delete object[methodName];
}
}
); // @ts-expect-error overriding original method with a Mock
object[methodName] = mock;
}
mock.mockImplementation(function () {
return original.apply(this, arguments);

@@ -818,0 +846,0 @@ });

{
"name": "jest-mock",
"version": "26.6.0",
"version": "26.6.1",
"repository": {

@@ -13,3 +13,3 @@ "type": "git",

"dependencies": {
"@jest/types": "^26.6.0",
"@jest/types": "^26.6.1",
"@types/node": "*"

@@ -23,3 +23,3 @@ },

},
"gitHead": "b254fd82fdedcba200e1c7eddeaab83a09bdaaef"
"gitHead": "f6366db60e32f1763e612288bf3984bcfa7a0a15"
}
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