From 02be413effc6f13755b8948df2f677894b1595ea Mon Sep 17 00:00:00 2001 From: Andrew Bastin Date: Mon, 6 Dec 2021 20:06:19 +0530 Subject: [PATCH] fix: fail state requests with response data can run tests fixes #1996 --- packages/hoppscotch-app/helpers/RequestRunner.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/hoppscotch-app/helpers/RequestRunner.ts b/packages/hoppscotch-app/helpers/RequestRunner.ts index 0aa11181d..bd4b2dfa3 100644 --- a/packages/hoppscotch-app/helpers/RequestRunner.ts +++ b/packages/hoppscotch-app/helpers/RequestRunner.ts @@ -16,7 +16,9 @@ import { HoppTestData, HoppTestResult } from "./types/HoppTestResult" import { isJSONContentType } from "./utils/contenttypes" import { getRESTRequest, setRESTTestResults } from "~/newstore/RESTSession" -const getTestableBody = (res: HoppRESTResponse & { type: "success" }) => { +const getTestableBody = ( + res: HoppRESTResponse & { type: "success" | "fail" } +) => { const contentTypeHeader = res.headers.find( (h) => h.key.toLowerCase() === "content-type" ) @@ -60,9 +62,9 @@ export const runRESTRequest$ = (): TaskEither< // Run Test Script when request ran successfully const subscription = stream - .pipe(filter((res) => res.type === "success")) + .pipe(filter((res) => res.type === "success" || res.type === "fail")) .subscribe(async (res) => { - if (res.type === "success") { + if (res.type === "success" || res.type === "fail") { const runResult = await runTestScript(res.req.testScript, { status: res.statusCode, body: getTestableBody(res),