mirror of
https://github.com/usebruno/bruno.git
synced 2025-02-19 11:11:40 +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 NodeVault = require('node-vault');
|
||||||
const { executeQuickJsVmAsync } = require('../sandbox/quickjs');
|
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 {
|
class TestRuntime {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
this.runtime = props?.runtime || 'vm2';
|
this.runtime = props?.runtime || 'vm2';
|
||||||
@ -93,10 +112,10 @@ class TestRuntime {
|
|||||||
|
|
||||||
bru.getTestResults = async () => {
|
bru.getTestResults = async () => {
|
||||||
let results = await __brunoTestResults.getResults();
|
let results = await __brunoTestResults.getResults();
|
||||||
return results;
|
return summarizeResults(results);
|
||||||
}
|
}
|
||||||
bru.getAssertionResults = async () => {
|
bru.getAssertionResults = async () => {
|
||||||
return assertionResults
|
return summarizeResults(assertionResults);
|
||||||
}
|
}
|
||||||
|
|
||||||
const context = {
|
const context = {
|
||||||
|
Loading…
Reference in New Issue
Block a user