From f88c81fccc544971f35040a24cea2ff02221ef27 Mon Sep 17 00:00:00 2001 From: James George <25279263+jamesgeorge007@users.noreply.github.com> Date: Thu, 4 Dec 2025 12:57:45 +0530 Subject: [PATCH] test(cli): prevent flaky CLI E2E tests by detecting generic `REQUEST_ERROR` patterns --- .../src/__tests__/e2e/commands/test.spec.ts | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/packages/hoppscotch-cli/src/__tests__/e2e/commands/test.spec.ts b/packages/hoppscotch-cli/src/__tests__/e2e/commands/test.spec.ts index 4014d99e..8a1b94f5 100644 --- a/packages/hoppscotch-cli/src/__tests__/e2e/commands/test.spec.ts +++ b/packages/hoppscotch-cli/src/__tests__/e2e/commands/test.spec.ts @@ -345,7 +345,7 @@ describe("hopp test [options] ", { timeout: 100000 }, () => { // Check for transient errors in output (network or httpbin 5xx) const output = `${result.stdout}\n${result.stderr}`; const hasNetworkError = - /ECONNRESET|EAI_AGAIN|ENOTFOUND|ETIMEDOUT|ECONNREFUSED|REQUEST_ERROR.*ECONNRESET/i.test( + /ECONNRESET|EAI_AGAIN|ENOTFOUND|ETIMEDOUT|ECONNREFUSED|REQUEST_ERROR/i.test( output ); const hasHttpbin5xx = @@ -518,7 +518,7 @@ describe("hopp test [options] ", { timeout: 100000 }, () => { // Clean up fs.unlinkSync(junitPath); - }, 420000); // 420 second (7 minute) timeout - increased from 300s to handle retries and network delays + }, 600000); // 600 second (10 minute) timeout }); describe("Test `hopp test --env ` command:", () => { @@ -1065,7 +1065,9 @@ describe("hopp test [options] ", { timeout: 100000 }, () => { const hasNetworkErrorInXML = /ECONNRESET|EAI_AGAIN|ENOTFOUND|ETIMEDOUT|ECONNREFUSED/i.test( fileContents - ); + ) || + (/REQUEST_ERROR/i.test(fileContents) && + !/Invalid URL/i.test(fileContents)); if (!hasNetworkErrorInXML) { break; @@ -1133,7 +1135,9 @@ describe("hopp test [options] ", { timeout: 100000 }, () => { const hasNetworkErrorInXML = /ECONNRESET|EAI_AGAIN|ENOTFOUND|ETIMEDOUT|ECONNREFUSED/i.test( fileContents - ); + ) || + (/REQUEST_ERROR/i.test(fileContents) && + !/Invalid URL/i.test(fileContents)); if (!hasNetworkErrorInXML) { break; @@ -1201,7 +1205,9 @@ describe("hopp test [options] ", { timeout: 100000 }, () => { const hasNetworkErrorInXML = /ECONNRESET|EAI_AGAIN|ENOTFOUND|ETIMEDOUT|ECONNREFUSED/i.test( fileContents - ); + ) || + (/REQUEST_ERROR/i.test(fileContents) && + !/Invalid URL/i.test(fileContents)); if (!hasNetworkErrorInXML) { break; @@ -1273,7 +1279,9 @@ describe("hopp test [options] ", { timeout: 100000 }, () => { const hasNetworkErrorInXML = /ECONNRESET|EAI_AGAIN|ENOTFOUND|ETIMEDOUT|ECONNREFUSED/i.test( fileContents - ); + ) || + (/REQUEST_ERROR/i.test(fileContents) && + !/Invalid URL/i.test(fileContents)); if (!hasNetworkErrorInXML) { break;