diff --git a/functions/postwomanTesting.js b/functions/postwomanTesting.js index e657b0136..f0b1ed688 100644 --- a/functions/postwomanTesting.js +++ b/functions/postwomanTesting.js @@ -2,6 +2,13 @@ const PASS = 'PASS', FAIL = 'FAIL', ERROR = 'ERROR'; +const styles = { + [PASS]: {icon: 'check', class: 'success-response'}, + [FAIL]: {icon: 'close', class: 'cl-error-response'}, + [ERROR]: {icon: 'close', class: 'cl-error-response'}, + none: {icon: '', class: ''} +}; + //TODO: probably have to use a more global state for `test` export default function runTestScriptWitVariables(script, variables) { @@ -25,7 +32,15 @@ export default function runTestScriptWitVariables(script, variables) { let errors = null; new Function("pw", script)(pw); // - return {report: pw._report, errors: pw._errors, testResults: pw._testReports}; + const report = pw._report.map(item => { + if (item.status) { + item.styles = styles[status]; + } else { + item.styles = styles.none; + } + return item; + }); + return {report, errors: pw._errors, testResults: pw._testReports}; } function test(descriptor, func, _testReports) { diff --git a/pages/index.vue b/pages/index.vue index 99ad78041..1e3d1a123 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -369,6 +369,21 @@ useWorker: false }" /> + +
+
+
+ {{testReport.styles.icon}} {{testReport.result}} +
    +
  • {{testReport.message}}
  • +
+
+
+

{{testReport.startBlock}}

+
+

+
+
@@ -1290,6 +1305,7 @@ export default { testsEnabled: false, testScript: "// pw.expect('variable').toBe('value');", preRequestScript: "// pw.env.set('variable', 'value');", + testReports: null, copyButton: 'file_copy', downloadButton: 'get_app', doneButton: 'done', @@ -2202,8 +2218,8 @@ export default { body: this.response.body, headers: this.response.headers }; - const testResults = runTestScriptWitVariables(this.testScript, {response: syntheticResponse}); - console.log('test results!! ', testResults) + const { testResults } = runTestScriptWitVariables(this.testScript, {response: syntheticResponse}); + this.testReports = testResults; } catch (error) { console.error(error);