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

universal-mock

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

universal-mock

A JavaScript object that is everything

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Build Status

UniversalMock

A JavaScript object that is everything...

Universal Mock is an object that pretends to have every property, and will return a Universal Mock for everything, so you can do

const mock = require("universalMock");

mock.anythingAtAll === undefined; // false!
mock.anythingAtAll === null; // false!
mock.something.somethingElse.whatever; // OK
let value = mock.someOtherRandom(); // It's a function!

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!"

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.

Keywords

FAQs

Package last updated on 07 Apr 2017

Did you know?

Socket

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.

Install

Related posts

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