Last active
September 10, 2015 20:08
-
-
Save zedd45/25f340c7c80355ab983e to your computer and use it in GitHub Desktop.
Nock Record - Thanks @dbretoi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* For use with Nocking Hapi Requests (with Lab) | |
* Nock: https://github.com/pgte/nock/ | |
* Hapi: http://hapijs.com/api | |
* Lab: https://github.com/hapijs/lab | |
*/ | |
// npm deps | |
var Nock = require('nock'); | |
var Fs = require('fs'); | |
var Hoek = require('hoek'); | |
// the following lines go inside the `it` or `test` | |
var fileName = Hoek.reach(this, 'process.domain.title', { default: 'nock-mock' }) + '.js'; // lab | |
fileName = fileName.replace(/\s+/g, '_'); | |
var appendLogToFile = function(content) { | |
console.log('writing to ' + fileName); | |
Fs.appendFile(fileName, content); | |
}; | |
Nock.recorder.rec({ | |
logging: appendLogToFile, | |
use_separator: false | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment