Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
universal-mock
Advanced tools
A JavaScript object that is everything...
Yarn:
yarn add universal-mock -D
Universal Mock is developed using Yarn
npm:
npm install --save-dev universal-mock
Universal Mock is an object that pretends to have every property, and will return a Universal Mock for everything, so you can do
import { mock } from "universal-mock";
mock.anythingAtAll === undefined; // false!
mock.anythingAtAll === null; // false!
mock.something.somethingElse.whatever; // OK
let value = mock.someOtherRandom(); // It's a function!
mock.someMethod = jest.fn(); // It works great with Jest!
You can also set pre-determined value for any mock at any level:
mock.value = 42;
console.log(mock.value); // Returns "42"
mock.something = () => "Hello!";
console.log(mock.something()); // "Hello!"
You can also generate new mock instances:
import { createMock } from "universal-mock";
const myMock = createMock();
Universal Mock is useful when you only want to mock out part of an object and don't care about the rest. This is particularly useful in TypeScript where interfaces may require you to implement everything.
FAQs
A JavaScript object that is everything
The npm package universal-mock receives a total of 89 weekly downloads. As such, universal-mock popularity was classified as not popular.
We found that universal-mock demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.