From 5d855f95c9fb64e4ec9cac09385ede0a842c3ac9 Mon Sep 17 00:00:00 2001 From: Basavaraj_m_n <162813862+Basavaraj8143@users.noreply.github.com> Date: Wed, 15 Apr 2026 13:48:30 +0530 Subject: [PATCH] refactor(cli): match test-result helper name to documented contract (#6122) Co-authored-by: James George <25279263+jamesgeorge007@users.noreply.github.com> --- packages/hoppscotch-cli/src/utils/request.ts | 6 +++--- packages/hoppscotch-cli/src/utils/test.ts | 7 +++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/packages/hoppscotch-cli/src/utils/request.ts b/packages/hoppscotch-cli/src/utils/request.ts index d2ac8a79..3a5dda05 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 f358bcf6..820ed06f 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)