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

  •        57

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.

https://github.com/howardabrams/node-mocks-http

Dependencies:

accepts : ^1.3.3
depd : ^1.1.0
fresh : ^0.5.2
merge-descriptors : ^1.0.1
methods : ^1.1.2
mime : ^1.3.4
net : ^1.0.2
parseurl : ^1.3.1
range-parser : ^1.2.0
type-is : ^1.6.14

Tags
Implementation
License
Platform

   




Related Projects

mountebank - Over the wire test doubles

  •    HTML

In fact, halfway through we discovered our corporate mocking software couldn’t handle the sheer amount of performance testing we were running as part of this effort (we completely crushed some pretty industrial enterprise software in the process). As a result, we made the call to move the entire program over to a Mountebank OSS-based solution with a custom provision to give us the ability to expand/shrink our mocking needs on demand. mountebank is the first open source tool to provide cross-platform, multi-protocol test doubles over the wire. Just point your application to mountebank instead of the real dependency, and test like you would with traditional stubs and mocks.

apimocker - node.js module to run a simple http server for mock service responses.

  •    Javascript

Then you can visit "http://localhost:7878/first" in your browser to see it work. The quiet and port options can also be set in the config.json file, and values from config.json will override values from the command line. After you get up and running, you should put your config.json and mock responses in a better location. It's not a good idea to keep them under the "node_modules" directory. Make sure another process is not already using the port you want. If you want port 80, you may need to use "sudo" on Mac OSX. Sometimes you only want some service endpoints to be mocked, but have other requests forwarded to real service endpoints. In this case, provide the proxy URL option on startup e.g. apimocker --proxy http://myrealservice.io When the proxy option is set, any requests to apimocker with URLs that are not configured with mock files, will be forwarded to the specified URL.

node-mitm - Intercept and mock outgoing Node

  •    Javascript

Mitm.js is a library for Node.js (and Io.js) to intercept and mock outgoing network TCP and HTTP connections. Mitm.js intercepts and gives you a Net.Socket to communicate as if you were the remote server. For HTTP requests it even gives you Http.IncomingMessage and Http.ServerResponse — just like you're used to when writing Node.js servers. Except there's no actual server running, it's all just In-Process Interception™. Intercepting connections and requests is extremely useful to test and ensure your code does what you expect. Assert on request parameters and send back various responses to your code without ever having to hit the real network. Fast as hell and a lot easier to develop with than external test servers.

mockbin - Mock, Test & Track HTTP Requests and Responses.

  •    Javascript

Mockbin is used internally and maintained by Mashape, who also maintain the open-source API Gateway Kong. read more on Installation.


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.

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.

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.

pollyjs - Record, Replay, and Stub HTTP Interactions.

  •    Javascript

Polly.JS is a standalone, framework-agnostic JavaScript library that enables recording, replaying, and stubbing HTTP interactions. Polly taps into native browser APIs to mock requests and responses with little to no configuration while giving you the ability to take full control of each request with a simple, powerful, and intuitive API.

httplive - HTTP Request & Response Service, Mock HTTP

  •    Go

The HttpLive is a tool for API designers, Proxy, mobile and web application developers to develop and test their applications faster without being dependent on any server or backend applications. HttpLive has a built-in user interface. Therefore, you can do all the configurations you need on this UI, and with dynamic URL (Routing) definitions you can specify your own JSON return types for your applications.

fetch-mock - Mock http requests made using fetch

  •    Javascript

Mock http requests made using fetch (or isomorphic-fetch)

flashback - mock the internet

  •    Java

Flashback is designed to mock HTTP and HTTPS resources, like web services and REST APIs, for testing purposes. It records HTTP/HTTPS requests and plays back a previously recorded HTTP transaction—which we call a "scene"—so that no external connection to the internet is required in order to complete testing.Note: The flashback and flashback scene are used for testing purpose only. Each scene contains a list of Http request and response. Those http request and response might contain some sensitive data such as api key, secret, token etc. You'd better either blacklist them using customized match rule or mask them.

HTTPretty - HTTP client mocking tool for Python, it's like ruby's FakeWeb for python

  •    Python

Due to big API incompatibility between python 3.3, 3.4 and 3.5, the author of HTTPretty is not supporting python3 officially. You will notice that the travis build for python 3 might be broken, and while pull requests fixing py3 support are most welcome, it is still not official at least for now. Since you are interested in HTTPretty you should also be interested in speeding up your build. Replace pip with curdling and see your build running a lot faster.

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.

dyson - Node server for dynamic, fake JSON.

  •    Javascript

Node server for dynamic, fake JSON. When developing client-side applications, often either static JSON files, or an actual server, backend, datastore, or API, is used. Sometimes static files are too static, and sometimes an actual server is not available, not accessible, or too tedious to set up.

pytest-mock - Thin-wrapper around the mock package for easier use with py.test

  •    Python

The spy acts exactly like the original method in all cases, except it allows use of mock features with it, like retrieving call count. It also works for class and static methods. The stub is a mock object that accepts any arguments and is useful to test callbacks, for instance. May be passed a name to be used by the constructed stub object in its repr (useful for debugging).

mmock - Mmock is an HTTP mocking application for testing and fast prototyping

  •    Go

Easy and fast HTTP mock server. Built with Go - Mmock runs without installation on multiple platforms.

pact-ruby - Enables consumer driven contract testing, providing a mock service and DSL for the consumer project, and interaction playback and verification for the service provider project

  •    Ruby

Define a pact between service consumers and providers, enabling "consumer driven contract" testing. Pact provides a fluent API for service consumers to define the HTTP requests they will make to a service provider and the HTTP responses they expect back. These expectations are used in the consumer specs to provide a mock service provider. The interactions are recorded, and played back in the service provider specs to ensure the service provider actually does provide the response the consumer expects.

interfake - :computer: Fake APIs for prototypes & automated tests.

  •    Javascript

Interfake is a tool which allows developers of client-side applications of any platform to easily create dummy HTTP APIs to develop against. Let's get started with a simple example.If you don't want to use the JavaScript method to create your Interfake API, go read up on all the methods. Otherwise, read on.