0.0.1 • Published 10 years ago

doppleganger v0.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
10 years ago

For e.g., to mock GET http://abc.com/:id?api_key=XYZ

var dopple = require('doppleganger');
var doppleURL = "http:/abc.com";

var done;

var ender = function(err, res) {
    //the headers
    console.log(res.headers);
    //the body
    console.log(res.body);

}

dopple.base(doppleURL)
    .get( { query: { 'api_key': 'xyz' }, params: { id: '.*' } } )
    .respond( { header: { code: 200 }, body: require('./fixture1.json') } );
    .end(cb);

1 mock a URL namespace with http

2 assert presence of URI parameters

3 fail if the mock isn't called in the duration of the test