All Projects → vadimdemedes → interaptor

vadimdemedes / interaptor

Licence: other
Intercept HTTP requests for testing purposes.

Programming Languages

javascript
184084 projects - #8 most used programming language
Makefile
30231 projects

interaptor Circle CI

Intercept HTTP requests for testing purposes. Uses mitm under the hood.

Installation

$ npm install interaptor --save

Usage

const intercept = require('interaptor');
const request = require('request');

intercept('api.digitalocean.com')
	.get('/v2/droplets') // intercept http://api.digitalocean.com/v2/droplets only
	.set('Content-Type', 'application/json') // set Content-Type response header
	.set(200) // set response status code
	.set('woohoo') // set response body (if object, will be JSON.stringify'ed)

request('http://api.digitalocean.com/v2/droplets', function (err, res, body) {
	// request was not sent to api.digitalocean.com
	// request was intercepted by interaptor
	
	// res.headers['Content-Type'] === 'application/json'
	// res.statusCode === 200
	// body === 'woohoo'
});

Tests

Circle CI

$ make test

License

Interaptor is released under the MIT license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].