diff --git a/src/handle_request.js b/src/handle_request.js index 7ad2bb0..070ade4 100644 --- a/src/handle_request.js +++ b/src/handle_request.js @@ -21,7 +21,6 @@ function handleRequest(mockAdapter, resolve, reject, config) { } delete config.adapter; - mockAdapter.history[config.method].push(config); var handler = utils.findHandler( mockAdapter.handlers, @@ -33,6 +32,12 @@ function handleRequest(mockAdapter, resolve, reject, config) { config.baseURL ); + mockAdapter.history[config.method].push(Object.assign(config, { + handler: { + passThrough: handler && handler.length === 2 + } + })); + if (handler) { if (handler.length === 7) { utils.purgeIfReplyOnce(mockAdapter, handler); diff --git a/test/history.spec.js b/test/history.spec.js index 444cd48..fd17ead 100644 --- a/test/history.spec.js +++ b/test/history.spec.js @@ -27,6 +27,7 @@ describe('MockAdapter history', function() { expect(mock.history.get.length).to.equal(1); expect(mock.history.get[0].method).to.equal('get'); expect(mock.history.get[0].url).to.equal('/foo'); + expect(mock.history.get[0].handler.passThrough).to.equal(false); }); }); diff --git a/types/index.d.ts b/types/index.d.ts index c070869..eeb0b2d 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -10,6 +10,10 @@ type ResponseSpecFunc = ( headers?: any ) => MockAdapter; +type RequestHandlerInfo = { + passThrough: boolean +} + interface RequestHandler { reply: ResponseSpecFunc; replyOnce: ResponseSpecFunc; @@ -50,7 +54,9 @@ declare class MockAdapter { resetHistory(): void; restore(): void; - history: { [method: string]: AxiosRequestConfig[] }; + history: { [method: string]: AxiosRequestConfig & { + handler: RequestHandlerInfo + }[] }; onGet: RequestMatcherFunc; onPost: RequestMatcherFunc;