diff --git a/.travis.yml b/.travis.yml index 02c65b0..4aa28c5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,7 @@ node_js: - 4 - 6 - 7 + - 8 script: - npm run lint - npm run test diff --git a/test/setup.js b/test/setup.js index 83cd3bd..011b577 100644 --- a/test/setup.js +++ b/test/setup.js @@ -1,4 +1,26 @@ var nock = require('nock'); +if (parseInt(process.versions.node, 10) >= 8) { + // See DEP0066 at https://nodejs.org/api/deprecations.html. + // _headers and _headerNames have been removed from Node v8, which causes + // nock <= 9.0.13 to fail. The snippet below monkey-patches the library, see + // https://github.com/node-nock/nock/pull/929/commits/f6369d0edd2a172024124f + // for the equivalent logic without proxies. + Object.defineProperty(require('http').ClientRequest.prototype, '_headers', { + get: function() { + var request = this; + // eslint-disable-next-line no-undef + return new Proxy(request.getHeaders(), { + set: function(target, property, value) { + request.setHeader(property, value); + return true; + }, + }); + }, + set: function() { + // Ignore. + }, + }); +} nock.enableNetConnect('127.0.0.1');