Skip to content

Instantly share code, notes, and snippets.

@rkaw92
Created July 18, 2018 09:36
Show Gist options
  • Save rkaw92/bdbd034ec8d150ed809ca2f46d3c4619 to your computer and use it in GitHub Desktop.
Save rkaw92/bdbd034ec8d150ed809ca2f46d3c4619 to your computer and use it in GitHub Desktop.
http monkey patching in Node.js 10
'use strict';
const http = require('http');
http.request = function fakeRequest() {
console.log('faked!');
};
'use strict';
const http = require('http');
require('./fake-http');
http.request();
// now "faked!" has been printed to the output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment