
Research
2025 Report: Destructive Malware in Open Source Packages
Destructive malware is rising across open source registries, using delays and kill switches to wipe code, break builds, and disrupt CI/CD.
typescript-mockify
Advanced tools
Typescript mocking library. Makes it easy to create mocks in typescript. Spies are automatically added on every mock function. Properties that are not mapped in the constructor will get default values.
$ npm install typescript-mockify --save
import typescript-mockify
import {ConstructorArguments, Mock, MockBuilder} from "typescript-mockify";
If you would have the following class:
interface ICar {
speed: number;
brand: string;
age: number;
drive(speed: number): void;
stop(): void;
toString(): string;
}
class Car implements ICar {
public speed: number = 0;
constructor(public brand: string, public age: number) {
}
public drive(speed: number): void {
this.speed = speed;
}
public stop(): void {
this.speed = 0;
}
public toString(): string {
return "brand:" + this.brand + ", speed:" + this.speed + ", age:" + this.age;
}
}
You can create a mock like this..
var mockedCar: Mock<ICar> =
new MockBuilder<ICar>().createInstance(Car, new ConstructorArguments()
.map("brand", "vw")
.map("age", 12));
The actual instance will be in the instance property
var actualInstance = mockedCar.instance;
Even though typescript-mockify has created spies for every function, you can still declare returnvalues in an easy way
mockedCar
.setupMethod("toString").andReturn("my mocked returnvalue")
.setupMethod("dummyFunc").andCallFake(() => _.noop);
Or directly fetch the spy of a stubbed function...
var driveSpy: Spy = mockedCar
.setupMethod("drive").getSpy();
You can also use the callback notation to keep the chain alive
mockedCar
.setupSpy("drive", (driveSpy: Spy) => driveSpy.and.callFake(_.noop))
.setupSpy("toString", (toStringSpy: Spy) => toStringSpy.and.returnValue("I came from the spy"));
Or just use it directly...
var driveSpy: Spy = mockedCar.instance.drive;
Just a tiny example to show the difference between the real instance and the mock instance
var car: ICar = new Car("vw", 10);
console.log(car.speed); // 0
car.drive(100);
console.log(car.speed); // 100
car.stop();
console.log(car.speed); // 0
console.log(car.toString()); // brand:vw, speed:0, age:10
var mockedCar: Mock<ICar> = new MockBuilder<ICar>()
.withCallConstructor(true)
.createInstance(Car, new ConstructorArguments()
.map("brand", "vw")
.map("age", 12))
.setupMethod("toString").andReturn("mockedstr");
console.log(mockedCar.instance.speed); // 0
car.drive(100);
console.log(mockedCar.instance.speed); // 0
car.stop();
console.log(mockedCar.instance.speed); // 0
console.log(mockedCar.instance.toString()); // mocked str
FAQs
A library to automate mocking in typescript
We found that typescript-mockify demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
Destructive malware is rising across open source registries, using delays and kill switches to wipe code, break builds, and disrupt CI/CD.

Security News
Socket CTO Ahmad Nassri shares practical AI coding techniques, tools, and team workflows, plus what still feels noisy and why shipping remains human-led.

Research
/Security News
A five-month operation turned 27 npm packages into durable hosting for browser-run lures that mimic document-sharing portals and Microsoft sign-in, targeting 25 organizations across manufacturing, industrial automation, plastics, and healthcare for credential theft.