Join our webinar on Wednesday, June 26, at 1pm EDTHow Chia Mitigates Risk in the Crypto Industry.Register
Socket
Socket
Sign inDemoInstall

jest-mock

Package Overview
Dependencies
20
Maintainers
3
Versions
237
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 30.0.0-alpha.2 to 30.0.0-alpha.3

56

build/index.d.ts

@@ -8,6 +8,6 @@ /**

export declare type ClassLike = {
new (...args: any): any;
};
/// <reference lib="esnext.disposable" />
export declare type ClassLike = new (...args: any) => any;
export declare type ConstructorLikeKeys<T> = keyof {

@@ -45,6 +45,6 @@ [K in keyof T as Required<T>[K] extends ClassLike ? K : never]: T[K];

: T extends FunctionLike
? MockedFunction<T>
: T extends object
? MockedObject<T>
: T;
? MockedFunction<T>
: T extends object
? MockedObject<T>
: T;

@@ -81,6 +81,6 @@ export declare const mocked: {

: T[K] extends FunctionLike
? MockedFunction<T[K]>
: T[K] extends object
? MockedObject<T[K]>
: T[K];
? MockedFunction<T[K]>
: T[K] extends object
? MockedObject<T[K]>
: T[K];
} & T;

@@ -92,4 +92,4 @@

: T[K] extends FunctionLike
? MockedFunctionShallow<T[K]>
: T[K];
? MockedFunctionShallow<T[K]>
: T[K];
} & T;

@@ -100,6 +100,6 @@

: T extends FunctionLike
? MockedFunctionShallow<T>
: T extends object
? MockedObjectShallow<T>
: T;
? MockedFunctionShallow<T>
: T extends object
? MockedObjectShallow<T>
: T;

@@ -168,5 +168,4 @@ declare type MockFunctionResult<T extends FunctionLike = UnknownFunction> =

export declare interface MockInstance<
T extends FunctionLike = UnknownFunction,
> {
export declare interface MockInstance<T extends FunctionLike = UnknownFunction>
extends Disposable {
_isMockFunction: true;

@@ -205,2 +204,3 @@ _protoImpl: Function;

/// <reference lib="esnext.disposable" />
export declare type MockMetadataType =

@@ -274,4 +274,4 @@ | 'object'

: A extends 'set'
? SpiedSetter<V>
: never;
? SpiedSetter<V>
: never;
spyOn<

@@ -341,4 +341,4 @@ T extends object,

: T extends FunctionLike
? SpiedFunction<T>
: never;
? SpiedFunction<T>
: never;

@@ -378,4 +378,4 @@ export declare type SpiedClass<T extends ClassLike = UnknownClass> =

: A extends 'set'
? SpiedSetter<V>
: never;
? SpiedSetter<V>
: never;
<

@@ -401,5 +401,3 @@ T_1 extends object,

export declare type UnknownClass = {
new (...args: Array<unknown>): unknown;
};
export declare type UnknownClass = new (...args: Array<unknown>) => unknown;

@@ -406,0 +404,0 @@ export declare type UnknownFunction = (...args: Array<unknown>) => unknown;

@@ -35,2 +35,4 @@ /*!

/// <reference lib="ESNext.Disposable" />
/* eslint-disable local/ban-types-eventually, local/prefer-rest-params-eventually */

@@ -180,4 +182,3 @@

const ownNames = Object.getOwnPropertyNames(object);
for (let i = 0; i < ownNames.length; i++) {
const prop = ownNames[i];
for (const prop of ownNames) {
if (!isReadonlyProp(object, prop)) {

@@ -192,3 +193,3 @@ const propDesc = Object.getOwnPropertyDescriptor(object, prop);

}
return Array.from(slots);
return [...slots];
}

@@ -210,3 +211,3 @@ _ensureMockConfig(f) {

if (state.calls.length > 0) {
state.lastCall = state.calls[state.calls.length - 1];
state.lastCall = state.calls.at(-1);
}

@@ -377,2 +378,5 @@ return state;

f.withImplementation = withImplementation.bind(this);
if (Symbol.dispose) {
f[Symbol.dispose] = f.mockRestore;
}
function withImplementation(fn, callback) {

@@ -437,3 +441,3 @@ // Remember previous mock implementation, then set new one

do {
name = name.substring(boundFunctionPrefix.length);
name = name.slice(boundFunctionPrefix.length);
// Call bind() just to alter the function name.

@@ -459,3 +463,3 @@ bindCall = '.bind(null)';

if (FUNCTION_NAME_RESERVED_PATTERN.test(name)) {
name = name.replace(FUNCTION_NAME_RESERVED_REPLACE, '$');
name = name.replaceAll(FUNCTION_NAME_RESERVED_REPLACE, '$');
}

@@ -555,3 +559,3 @@ const body = `return function ${name}() {` + ` return ${MOCK_CONSTRUCTOR_NAME}.apply(this,arguments);` + `}${bindCall}`;

for (const slot of this._getSlots(component)) {
if (type === 'function' && this.isMockFunction(component) && slot.match(/^mock/)) {
if (type === 'function' && this.isMockFunction(component) && slot.startsWith('mock')) {
continue;

@@ -604,3 +608,3 @@ }

if (typeof original !== 'function') {
throw new Error(`Cannot spy on the \`${String(methodKey)}\` property because it is not a function; ${this._typeOf(original)} given instead.${typeof original === 'object' ? '' : ` If you are trying to mock a property, use \`jest.replaceProperty(object, '${String(methodKey)}', value)\` instead.`}`);
throw new TypeError(`Cannot spy on the \`${String(methodKey)}\` property because it is not a function; ${this._typeOf(original)} given instead.${typeof original === 'object' ? '' : ` If you are trying to mock a property, use \`jest.replaceProperty(object, '${String(methodKey)}', value)\` instead.`}`);
}

@@ -663,3 +667,3 @@ const isMethodOwner = Object.prototype.hasOwnProperty.call(object, methodKey);

if (typeof original !== 'function') {
throw new Error(`Cannot spy on the ${String(propertyKey)} property because it is not a function; ${this._typeOf(original)} given instead.${typeof original === 'object' ? '' : ` If you are trying to mock a property, use \`jest.replaceProperty(object, '${String(propertyKey)}', value)\` instead.`}`);
throw new TypeError(`Cannot spy on the ${String(propertyKey)} property because it is not a function; ${this._typeOf(original)} given instead.${typeof original === 'object' ? '' : ` If you are trying to mock a property, use \`jest.replaceProperty(object, '${String(propertyKey)}', value)\` instead.`}`);
}

@@ -707,3 +711,3 @@ descriptor[accessType] = this._makeComponent({

if (typeof descriptor.value === 'function') {
throw new Error(`Cannot replace the \`${String(propertyKey)}\` property because it is a function. Use \`jest.spyOn(object, '${String(propertyKey)}')\` instead.`);
throw new TypeError(`Cannot replace the \`${String(propertyKey)}\` property because it is a function. Use \`jest.spyOn(object, '${String(propertyKey)}')\` instead.`);
}

@@ -710,0 +714,0 @@ const existingRestore = this._findReplacedProperty(object, propertyKey);

{
"name": "jest-mock",
"version": "30.0.0-alpha.2",
"version": "30.0.0-alpha.3",
"repository": {

@@ -22,10 +22,6 @@ "type": "git",

"dependencies": {
"@jest/types": "30.0.0-alpha.2",
"@jest/types": "30.0.0-alpha.3",
"@types/node": "*",
"jest-util": "30.0.0-alpha.2"
"jest-util": "30.0.0-alpha.3"
},
"devDependencies": {
"@tsd/typescript": "^5.0.4",
"tsd-lite": "^0.8.0"
},
"engines": {

@@ -37,3 +33,3 @@ "node": "^16.10.0 || ^18.12.0 || >=20.0.0"

},
"gitHead": "c04d13d7abd22e47b0997f6027886aed225c9ce4"
"gitHead": "e267aff33d105399f2134bad7c8f82285104f3da"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc