fix: fail state requests with response data can run tests fixes #1996
This commit is contained in:
@@ -16,7 +16,9 @@ import { HoppTestData, HoppTestResult } from "./types/HoppTestResult"
|
|||||||
import { isJSONContentType } from "./utils/contenttypes"
|
import { isJSONContentType } from "./utils/contenttypes"
|
||||||
import { getRESTRequest, setRESTTestResults } from "~/newstore/RESTSession"
|
import { getRESTRequest, setRESTTestResults } from "~/newstore/RESTSession"
|
||||||
|
|
||||||
const getTestableBody = (res: HoppRESTResponse & { type: "success" }) => {
|
const getTestableBody = (
|
||||||
|
res: HoppRESTResponse & { type: "success" | "fail" }
|
||||||
|
) => {
|
||||||
const contentTypeHeader = res.headers.find(
|
const contentTypeHeader = res.headers.find(
|
||||||
(h) => h.key.toLowerCase() === "content-type"
|
(h) => h.key.toLowerCase() === "content-type"
|
||||||
)
|
)
|
||||||
@@ -60,9 +62,9 @@ export const runRESTRequest$ = (): TaskEither<
|
|||||||
|
|
||||||
// Run Test Script when request ran successfully
|
// Run Test Script when request ran successfully
|
||||||
const subscription = stream
|
const subscription = stream
|
||||||
.pipe(filter((res) => res.type === "success"))
|
.pipe(filter((res) => res.type === "success" || res.type === "fail"))
|
||||||
.subscribe(async (res) => {
|
.subscribe(async (res) => {
|
||||||
if (res.type === "success") {
|
if (res.type === "success" || res.type === "fail") {
|
||||||
const runResult = await runTestScript(res.req.testScript, {
|
const runResult = await runTestScript(res.req.testScript, {
|
||||||
status: res.statusCode,
|
status: res.statusCode,
|
||||||
body: getTestableBody(res),
|
body: getTestableBody(res),
|
||||||
|
|||||||
Reference in New Issue
Block a user