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

mockery

Package Overview
Dependencies
Maintainers
4
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mockery

Simplifying the use of mocks with Node.js

  • 2.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
164K
increased by16.4%
Maintainers
4
Weekly downloads
 
Created

What is mockery?

Mockery is a versatile and powerful library for mocking modules in Node.js. It allows you to replace dependencies with mock objects during testing, making it easier to isolate and test individual components of your application.

What are mockery's main functionalities?

Enable Mockery

This feature enables Mockery, allowing you to start mocking modules. It is typically called at the beginning of your test setup.

const mockery = require('mockery');
mockery.enable();

Register Mock

This feature allows you to register a mock for a specific module. In this example, 'module-to-mock' is replaced with an object that has a mocked function.

const mockery = require('mockery');
mockery.registerMock('module-to-mock', { mockedFunction: () => 'mocked result' });

Deregister Mock

This feature allows you to deregister a previously registered mock. This is useful for cleaning up after tests.

const mockery = require('mockery');
mockery.deregisterMock('module-to-mock');

Disable Mockery

This feature disables Mockery, stopping any further mocking. It is typically called at the end of your test teardown.

const mockery = require('mockery');
mockery.disable();

Other packages similar to mockery

Keywords

FAQs

Package last updated on 26 Jun 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