diff --git a/lib/mock/mock-interceptor.js b/lib/mock/mock-interceptor.js index 781e477502a..1772f0e424f 100644 --- a/lib/mock/mock-interceptor.js +++ b/lib/mock/mock-interceptor.js @@ -106,7 +106,7 @@ class MockInterceptor { if (typeof data === 'undefined') { throw new InvalidArgumentError('data must be defined') } - if (typeof responseOptions !== 'object') { + if (typeof responseOptions !== 'object' || responseOptions === null) { throw new InvalidArgumentError('responseOptions must be an object') } } diff --git a/test/mock-interceptor.js b/test/mock-interceptor.js index 036ea69df98..961a7576dc1 100644 --- a/test/mock-interceptor.js +++ b/test/mock-interceptor.js @@ -53,7 +53,7 @@ describe('MockInterceptor - reply callback', () => { }) test('should error if passed options invalid', t => { - t = tspl(t, { plan: 2 }) + t = tspl(t, { plan: 3 }) const mockInterceptor = new MockInterceptor({ path: '', @@ -61,6 +61,7 @@ describe('MockInterceptor - reply callback', () => { }, []) t.throws(() => mockInterceptor.reply(), new InvalidArgumentError('statusCode must be defined')) t.throws(() => mockInterceptor.reply(200, () => { }, 'hello'), new InvalidArgumentError('responseOptions must be an object')) + t.throws(() => mockInterceptor.reply(200, () => { }, null), new InvalidArgumentError('responseOptions must be an object')) }) })