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

  •        86

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.

https://github.com/jhnns/rewire

Dependencies:

eslint : ^4.19.1

Tags
Implementation
License
Platform

   




Related Projects

mockery - Simplifying the use of mocks with Node.js

  •    Javascript

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.

node-sandboxed-module - A sandboxed node

  •    Javascript

A sandboxed node.js module loader that lets you inject dependencies into your modules.This module is intended to ease dependency injection for unit testing. However, feel free to use it for whatever crimes you can think of.

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.

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.

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.


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-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.

Mockito - Most popular Mocking framework for unit tests written in Java

  •    Java

Mockito is a mocking framework that tastes really good. It lets you write beautiful tests with a clean & simple API. Mockito doesn’t give you hangover because the tests are very readable and they produce clean verification errors.

Arquillian - Testing Platform for JVM

  •    Java

Arquillian is an innovative and highly extensible testing platform for the JVM that enables developers to easily create automated integration, functional and acceptance tests for Java middleware. Arquillian handles all the plumbing of container management, deployment and framework initialization so you can focus on the task at hand, writing your tests. Real tests.

atoum - The modern, simple and intuitive PHP unit testing framework.

  •    PHP

To accomplish that, it massively uses capabilities provided by PHP, to give the developer a whole new way of writing unit tests. Therefore, it can be installed and integrated into an existing project extremely easily, since it is only a single PHAR archive, which is the one and only entry point for the developer. Also, thanks to its fluent interface, it allows for writing unit tests in a fashion close to natural language. It also makes it easier to implement stubbing within tests, thanks to intelligent uses of anonymous functions and closures. atoum natively, and by default, performs the execution of each unit test within a separate PHP process, to warrant isolation. Of course, it can be used seamlessly for continuous integration, and given its design, it can be made to cope with specific needs extremely easily. atoum also accomplishes all of this without affecting performance, since it has been developed to boast a reduced memory footprint while allowing for hastened test execution. It can also generate unit test execution reports in the Xunit format, which makes it compatible with continuous integration tools such as Jenkins. atoum also generates code coverage reports, in order to make it possible to supervise unit tests. Finally, even though it is developed mainly on UNIX, it can also work on Windows. If Xdebug or equivalent gets displayed, then the module is properly installed.

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.

QueryUnit

  •    

A project that allow the execution of Unit Testing against a database (Relational or Multidimensional). It uses NUnit as unit-testing framework and does not require DBA or BI Developer to know anything about .NET: just write your SQL or MDX queries and test them

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.

Criterion - A cross-platform C and C++ unit testing framework for the 21th century

  •    C

A dead-simple, yet extensible, C and C++ unit testing framework. Most test frameworks for C require a lot of boilerplate code to set up tests and test suites -- you need to create a main, then register new test suites, then register the tests within these suits, and finally call the right functions.

typedi - Simple yet powerful dependency injection tool for JavaScript and TypeScript.

  •    TypeScript

TypeDI is a dependency injection tool for JavaScript and TypeScript. Using TypeDI you can build well-structured and easily tested applications. Then you can call Container.get(SomeClass) from anywhere in your application and you'll always have the same instance of SomeClass.

CUnit - A Unit Testing Framework for C

  •    C

CUnit is a lightweight system for writing, administering, and running unit tests in C. It provides C programmers a basic testing functionality with a flexible variety of user interfaces. CUnit is built as a static library which is linked with the user's testing code. It uses a simple framework for building test structures, and provides a rich set of assertions for testing common data types.

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-).

android-testing-guide - [Examples] Complete reference for Android Testing with examples.

  •    Java

Complete reference for Android Testing with examples. A unit test generally exercises the functionality of the smallest possible unit of code (which could be a method, class, or component) in a repeatable way.

SpringUnit

  •    Java

SpringUnit is an open source framework for unit and integration testing of Java software. It marries Spring's Dependency Injection container with JUnit's test framework to enable data-driven testing.

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.