mirror of
https://github.com/usebruno/bruno.git
synced 2025-02-15 01:10:14 +01:00
feat: summarize test and assertion results for getTestResults and getAssertionResults fns
This commit is contained in:
parent
ca5fbea7b6
commit
7b86febc87
@ -32,6 +32,25 @@ const CryptoJS = require('crypto-js');
|
||||
const NodeVault = require('node-vault');
|
||||
const { executeQuickJsVmAsync } = require('../sandbox/quickjs');
|
||||
|
||||
const summarizeResults = (results) => {
|
||||
const summary = {
|
||||
total: results.length,
|
||||
passed: 0,
|
||||
failed: 0,
|
||||
skipped: 0,
|
||||
};
|
||||
|
||||
results.forEach((r) => {
|
||||
const passed = r.status === "pass";
|
||||
if (passed) summary.passed += 1;
|
||||
else if (r.status === "fail") summary.failed += 1;
|
||||
else summary.skipped += 1;
|
||||
});
|
||||
|
||||
return { summary, results };
|
||||
}
|
||||
|
||||
|
||||
class TestRuntime {
|
||||
constructor(props) {
|
||||
this.runtime = props?.runtime || 'vm2';
|
||||
@ -93,10 +112,10 @@ class TestRuntime {
|
||||
|
||||
bru.getTestResults = async () => {
|
||||
let results = await __brunoTestResults.getResults();
|
||||
return results;
|
||||
return summarizeResults(results);
|
||||
}
|
||||
bru.getAssertionResults = async () => {
|
||||
return assertionResults
|
||||
return summarizeResults(assertionResults);
|
||||
}
|
||||
|
||||
const context = {
|
||||
|
Loading…
Reference in New Issue
Block a user