diff --git a/source/normalize-arguments.js b/source/normalize-arguments.js index 4fcf0a2a6..c0662076e 100644 --- a/source/normalize-arguments.js +++ b/source/normalize-arguments.js @@ -55,7 +55,8 @@ const preNormalize = options => { }; module.exports = (url, options, defaults) => { - options = merge({}, defaults.options, options ? preNormalize(options) : {}); + options = merge({}, defaults.options, options || {}); + options = preNormalize(options); if (Reflect.has(options, 'url') || (is.object(url) && Reflect.has(url, 'url'))) { throw new TypeError('Parameter `url` is not an option. Use got(url, options)'); diff --git a/test/create.js b/test/create.js index d28d885a9..4010ffd98 100644 --- a/test/create.js +++ b/test/create.js @@ -190,3 +190,20 @@ test('ability to pass a custom request method', async t => { t.true(called); }); + +test('hooks aren\'t overriden when merging options', async t => { + let called = false; + const instance = got.extend({ + hooks: { + beforeRequest: [ + () => { + called = true; + } + ] + } + }); + + await instance(s.url, {}); + + t.true(called); +});