Skip to content

Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia

refactor(cli): match test-result helper name to documented contract (#6122)

Basavaraj_m_n5d855f95c9fb
diff --git a/packages/hoppscotch-cli/src/utils/request.ts b/packages/hoppscotch-cli/src/utils/request.ts
index d2ac8a794..3a5dda05f 100644
--- a/packages/hoppscotch-cli/src/utils/request.ts
+++ b/packages/hoppscotch-cli/src/utils/request.ts
@@ -30,7 +30,7 @@ import {
} from "./display";
import { getDurationInSeconds, getMetaDataPairs } from "./getters";
import { preRequestScriptRunner } from "./pre-request";
-import { getTestScriptParams, hasFailedTestCases, testRunner } from "./test";
+import { getTestScriptParams, hasAllTestsPassed, testRunner } from "./test";
/**
* Processes given variable, which includes checking for secret variables
@@ -337,7 +337,7 @@ export const processRequest =
report.result = false;
} else {
const { envs, testsReport, duration } = testRunnerRes.right;
- const _hasFailedTestCases = hasFailedTestCases(testsReport);
+ const _allTestsPassed = hasAllTestsPassed(testsReport);
// Check if any tests have uncaught runtime errors (e.g., ReferenceError, TypeError)
// Don't include validation errors (they're reported as individual testcases)
@@ -369,7 +369,7 @@ export const processRequest =
// Updating report with current tests, result and duration.
report.tests = testsReport;
- report.result = report.result && _hasFailedTestCases;
+ report.result = report.result && _allTestsPassed;
report.duration.test = duration;
// Updating resulting envs from test-runner.
diff --git a/packages/hoppscotch-cli/src/utils/test.ts b/packages/hoppscotch-cli/src/utils/test.ts
index f358bcf61..820ed06f3 100644
--- a/packages/hoppscotch-cli/src/utils/test.ts
+++ b/packages/hoppscotch-cli/src/utils/test.ts
@@ -237,12 +237,11 @@ export const getFailedExpectedResults = (expectResults: ExpectResult[]) =>
);
/**
- * Checks if any of the tests-report have failed test-cases.
+ * Checks whether every test report has zero failed test cases.
* @param testsReport Provides "failed" test-cases data.
- * @returns True, if one or more failed test-cases found.
- * False, if all test-cases passed.
+ * @returns True, if all test-cases passed. False, otherwise.
*/
-export const hasFailedTestCases = (testsReport: TestReport[]) =>
+export const hasAllTestsPassed = (testsReport: TestReport[]) =>
pipe(
testsReport,
A.every(({ failed }) => failed === 0)