From 63b7035e749a661872ee5ecf0a2e901e5f2932c7 Mon Sep 17 00:00:00 2001 From: Nicholas Palenchar Date: Fri, 24 Jan 2020 10:10:50 -0500 Subject: [PATCH] re-add testing functions --- functions/postwomanTesting.js | 1 - pages/index.vue | 70 +++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 1 deletion(-) diff --git a/functions/postwomanTesting.js b/functions/postwomanTesting.js index aad694ec8..e657b0136 100644 --- a/functions/postwomanTesting.js +++ b/functions/postwomanTesting.js @@ -1,4 +1,3 @@ -import {parse} from "graphql"; const PASS = 'PASS', FAIL = 'FAIL', ERROR = 'ERROR'; diff --git a/pages/index.vue b/pages/index.vue index 12845ead1..99ad78041 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -282,6 +282,26 @@ >close + + + + + + + + +
@@ -1152,6 +1209,7 @@ import querystring from "querystring"; import textareaAutoHeight from "../directives/textareaAutoHeight"; import parseCurlCommand from "../assets/js/curlparser.js"; import getEnvironmentVariablesFromScript from "../functions/preRequest"; +import runTestScriptWitVariables from '../functions/postWomanTesting' import parseTemplateString from "../functions/templating"; import AceEditor from "../components/ace-editor"; import { tokenRequest, oauthRedirect } from "../assets/js/oauth"; @@ -1229,6 +1287,8 @@ export default { return { showModal: false, showPreRequestScript: false, + testsEnabled: false, + testScript: "// pw.expect('variable').toBe('value');", preRequestScript: "// pw.env.set('variable', 'value');", copyButton: 'file_copy', downloadButton: 'get_app', @@ -2135,6 +2195,16 @@ export default { } } })(); + + // tests + const syntheticResponse = { + status: this.response.status, + body: this.response.body, + headers: this.response.headers + }; + const testResults = runTestScriptWitVariables(this.testScript, {response: syntheticResponse}); + console.log('test results!! ', testResults) + } catch (error) { console.error(error); if (error.response) {