Skip to content

Instantly share code, notes, and snippets.

@LinuxBozo
Last active August 29, 2015 14:14
Show Gist options
  • Save LinuxBozo/c28b038485018dd303c2 to your computer and use it in GitHub Desktop.
Save LinuxBozo/c28b038485018dd303c2 to your computer and use it in GitHub Desktop.
var shmock = require('shmock');
var mockAPI = shmock(10000);
mockAPI.get('/foo').reply(200, 'bar');
mockAPI.get('/isChildFI/2013/1').reply(200, JSON.stringify({ result: true }));
var request = require('sync-request');
var resp1 = request('GET', 'http://localhost:10000/foo');
console.log(resp1.getBody('utf8'));
var resp2 = request('GET', 'http://localhost:10000/isChildFI/2013/1');
console.log(resp2.getBody('utf8'));
$ node mockserver.js && node output_tests.js
bar
{"result":true}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment