mockery - Simplifying the use of mocks with Node.js

  •        24

If you've tried working with mocks in Node.js, you've no doubt discovered that it's not so easy to get your mocks hooked up in the face of Node's module loading system. When your source-under-test pulls in its dependencies through require, you want your mocks provided, instead of the original module, to enable true unit testing of your code. This is exactly the problem Mockery is designed to solve. Mockery gives you a simple and easy to use API with which you can hook in your mocks without having to get your hands dirty with the require cache or other Node implementation details.

https://github.com/mfncooper/mockery

Tags
Implementation
License
Platform

   




Related Projects

mockery - Mockery is a simple yet flexible PHP mock object framework for use in unit testing with PHPUnit, PHPSpec or any other testing framework

  •    PHP

Mockery is a simple yet flexible PHP mock object framework for use in unit testing with PHPUnit, PHPSpec or any other testing framework. Its core goal is to offer a test double framework with a succinct API capable of clearly defining all possible object operations and interactions using a human readable Domain Specific Language (DSL). Designed as a drop in alternative to PHPUnit's phpunit-mock-objects library, Mockery is easy to integrate with PHPUnit and can operate alongside phpunit-mock-objects without the World ending. Mockery is released under a New BSD License.

mockery

  •    PHP

Mockery is a simple yet flexible PHP mock object framework for use in unit testing with PHPUnit, PHPSpec or any other testing framework. Its core goal is to offer a test double framework with a succint API capable of clearly defining all possible object operations and interactions using a human readable Domain Specific Language (DSL). Designed as a drop in alternative to PHPUnit's phpunit-mock-objects library, Mockery is easy to integrate with PHPUnit and can operate alongside phpunit-mock-objec

padraic-mockery

  •    PHP

Mockery is a simple yet flexible PHP mock object framework for use in unit testing with PHPUnit, PHPSpec or any other testing framework. Its core goal is to offer a test double framework with a succint API capable of clearly defining all possible object operations and interactions using a human readable Domain Specific Language (DSL). Designed as a drop in alternative to PHPUnit's phpunit-mock-objects library, Mockery is easy to integrate with PHPUnit and can operate alongside phpunit-mock-objec

mock-require - Simple, intuitive mocking of Node.js modules.

  •    Javascript

mock-require is useful if you want to mock require statements in Node.js. I wrote it because I wanted something with a straight-forward API that would let me mock anything, from a single exported function to a standard library. The module you that you want to mock. This is the same string you would pass in if you wanted to require the module.

rewire - Easy monkey-patching for node.js unit tests

  •    Javascript

Please note: The current version of rewire is only compatible with CommonJS modules. See Limitations. rewire acts exactly like require. With just one difference: Your module will now export a special setter and getter for private variables.


FakePoint

  •    

FakePoint is a set of fake (mock or stub) SharePoint object model API classes to enable unit testing and TDD. The FakePoint DLL is referenced in the test project in place of the SharePoint assembly, allowing the fake API classes to be used transparently without special coding.

proxyquire - 🔮 Proxies nodejs require in order to allow overriding dependencies during testing.

  •    Javascript

Proxies nodejs's require in order to make overriding dependencies during testing easy while staying totally unobtrusive. If you want to stub dependencies for your client side modules, try proxyquireify, a proxyquire for browserify v2 or proxyquire-universal to test in both Node and the browser.

testdouble.js - A minimal test double library for TDD with JavaScript

  •    Javascript

Welcome! Are you writing JavaScript tests and in the market for a mocking library to fake out real things for you? testdouble.js is an opinionated, carefully-designed test double library maintained by, oddly enough, a software agency that's also named Test Double. If you practice test-driven development, testdouble.js was designed to promote terse, clear, and easy-to-understand tests. There's an awful lot to cover, so please take some time and enjoy our documentation, which is designed to show you how to make the most out of test doubles in your tests.

cmockery - A lightweight library to simplify and generalize the process of writing unit tests for C applications

  •    Shell

Cmockery is a lightweight library that is used to author C unit tests.There are a variety of C unit testing frameworks available however many of them are fairly complex and require the latest compiler technology. Some development requires the use of old compilers which makes it difficult to use some unit testing frameworks. In addition many unit testing frameworks assume the code being tested is an application or module that is targeted to the same platform that will ultimately execute the test. Because of this assumption many frameworks require the inclusion of standard C library headers in the code module being tested which may collide with the custom or incomplete implementation of the C library utilized by the code under test.

Legend Fakes - Fake it easy!

  •    

A dynamic fake framework. * Easier semantics, all fake objects are just that - fakes - the use of the fakes determines whether they're mocks or stubs. * Context aware fluent interface guides the developer. * Full VB.Net support.

mocha - Mocha is a mocking and stubbing library for Ruby

  •    Ruby

Install the latest version of the gem with the following command... Note: If you are intending to use Mocha with Test::Unit or MiniTest, you should only setup Mocha after loading the relevant test library...

api-mock - Creates a mock server based on an API Blueprint

  •    HTML

This project is no longer under active development and we're looking for a new maintainer (or owner). Please open an issue if you are interested in helping out. API-Mock is a node.js npm module that generates a mock server (express) from your API specification. Document your API in the API blueprint format, and API-Mock mocks your routes and sends the responses defined in the api spec.

BeanProxy

  •    DotNet

BeanProxy is both a mock library as well as a stub factory. It can be configured for behavior or state verification. It has a truly rich API for strong typing of both method names and parameters. Enjoy its elegant use of delegates and property overloading for simple unit testing.

sinon - Test spies, stubs and mocks for JavaScript.

  •    Javascript

Standalone and test framework agnostic JavaScript test spies, stubs and mocks (pronounced "sigh-non", named after Sinon, the warrior).or via sinon's browser builds available for download on the homepage. There are also npm based CDNs one can use.

node-mocks-http - Mock 'http' objects for testing Express routing functions

  •    Javascript

Mock 'http' objects for testing Express routing functions, but could be used for testing any Node.js web server applications that have code that requires mockups of the request and response objects. This project is available as a NPM package.

Catch2 - C++ Automated Test Cases in a Header

  •    C++

Catch2 stands for C++ Automated Test Cases in a Header and is a multi-paradigm test framework for C++. which also supports Objective-C (and maybe C). It is primarily distributed as a single header file, although certain extensions may require additional headers.

kahlan - :heavy_check_mark: PHP Test Framework for Freedom, Truth, and Justice

  •    PHP

Kahlan is a full-featured Unit & BDD test framework a la RSpec/JSpec which uses a describe-it syntax and moves testing in PHP one step forward. Kahlan lets you stub or monkey patch your code directly like in Ruby or JavaScript without any required PECL-extensions.

mock-socket - Javascript mocking library for websockets and socket.io

  •    Javascript

To use within a node environment you can simply import or require the files directly. This option is great for phantomjs or CI environments. This project uses mocha as its test framework. Tests are located in /test and have 1 of 3 file name prefixes (functional-, issue-#, or unit-).

redux-saga-test-plan - Test Redux Saga with an easy plan.

  •    Javascript

Redux Saga Test Plan makes testing sagas a breeze. Whether you need to test exact effects and their ordering or just test your saga put's a specific action at some point, Redux Saga Test Plan has you covered. Redux Saga Test Plan aims to embrace both integration testing and unit testing approaches to make testing your sagas easy.

Pester - Pester is the ubiquitous test and mock framework for PowerShell.

  •    PowerShell

Pester is the ubiquitous test and mock framework for PowerShell. This code example lies a tiny bit, find it annotated and production ready here.