Skip to content

Instantly share code, notes, and snippets.

@pconerly
Created March 5, 2015 19:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save pconerly/3d5d4f1ca8bd58e7f440 to your computer and use it in GitHub Desktop.
Save pconerly/3d5d4f1ca8bd58e7f440 to your computer and use it in GitHub Desktop.
Record nocks to a json file
var nock = require('nock');
var low = require('lowdb');
// lowdb is a great straight-to-json minidb.
var db = low('integration_test_nock_records.json');
writeToFileLog = function(object) {
console.log("writing nock to json....");
db('records').push(object);
}
nock.recorder.rec({
output_objects: true, // we want object representations
logging: writeToFileLog, // use our custom func instead of `console.log`
use_separator: false, // no `<<<<<< cut here >>>>>` string appended to output
enable_reqheaders_recording: true, // see what request headers we sent
});
// Kick off your http requests here!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment