From 8a07f281ff2b41d46a0f84aee4025d6d16806377 Mon Sep 17 00:00:00 2001 From: Andrew Bastin Date: Mon, 3 Aug 2020 13:42:33 -0400 Subject: [PATCH] Test scripts get parsed JSON body --- pages/index.vue | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pages/index.vue b/pages/index.vue index b1763e188..62385871e 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -2200,6 +2200,19 @@ export default { body: this.response.body, headers: this.response.headers, } + + // Parse JSON body + if ( + syntheticResponse.headers["content-type"] && + isJSONContentType(syntheticResponse.headers["content-type"]) + ) { + try { + syntheticResponse.body = JSON.parse( + new TextDecoder("utf-8").decode(new Uint8Array(syntheticResponse.body)) + ) + } catch (_e) {} + } + const { testResults } = runTestScriptWithVariables(this.testScript, { response: syntheticResponse, })