From cbc890292f406fcbde0b48663d46b510d842694c Mon Sep 17 00:00:00 2001 From: Szymon Marczak <36894700+szmarczak@users.noreply.github.com> Date: Thu, 12 Aug 2021 09:05:44 +0200 Subject: [PATCH] Fix invalid `afterResponse` return check --- source/as-promise/index.ts | 2 +- test/hooks.ts | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/source/as-promise/index.ts b/source/as-promise/index.ts index 9aca4a924..31b905e35 100644 --- a/source/as-promise/index.ts +++ b/source/as-promise/index.ts @@ -98,7 +98,7 @@ export default function asPromise(firstRequest: Request): CancelableRequest { t.is(response.retryCount, 2); t.is(counter, 1); }); + +test('does not throw on empty body when running afterResponse hooks', withServer, async (t, server, got) => { + server.get('/', (_request, response) => { + response.end(); + }); + + await t.notThrowsAsync(got('', { + hooks: { + afterResponse: [ + response => { + return response; + } + ] + } + })); +});