Skip to content

Commit f88c81f

Browse files
test(cli): prevent flaky CLI E2E tests by detecting generic REQUEST_ERROR patterns
1 parent f232886 commit f88c81f

File tree

1 file changed

+14
-6
lines changed
  • packages/hoppscotch-cli/src/__tests__/e2e/commands

1 file changed

+14
-6
lines changed

packages/hoppscotch-cli/src/__tests__/e2e/commands/test.spec.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ describe("hopp test [options] <file_path_or_id>", { timeout: 100000 }, () => {
345345
// Check for transient errors in output (network or httpbin 5xx)
346346
const output = `${result.stdout}\n${result.stderr}`;
347347
const hasNetworkError =
348-
/ECONNRESET|EAI_AGAIN|ENOTFOUND|ETIMEDOUT|ECONNREFUSED|REQUEST_ERROR.*ECONNRESET/i.test(
348+
/ECONNRESET|EAI_AGAIN|ENOTFOUND|ETIMEDOUT|ECONNREFUSED|REQUEST_ERROR/i.test(
349349
output
350350
);
351351
const hasHttpbin5xx =
@@ -518,7 +518,7 @@ describe("hopp test [options] <file_path_or_id>", { timeout: 100000 }, () => {
518518

519519
// Clean up
520520
fs.unlinkSync(junitPath);
521-
}, 420000); // 420 second (7 minute) timeout - increased from 300s to handle retries and network delays
521+
}, 600000); // 600 second (10 minute) timeout
522522
});
523523

524524
describe("Test `hopp test <file_path_or_id> --env <file_path_or_id>` command:", () => {
@@ -1065,7 +1065,9 @@ describe("hopp test [options] <file_path_or_id>", { timeout: 100000 }, () => {
10651065
const hasNetworkErrorInXML =
10661066
/ECONNRESET|EAI_AGAIN|ENOTFOUND|ETIMEDOUT|ECONNREFUSED/i.test(
10671067
fileContents
1068-
);
1068+
) ||
1069+
(/REQUEST_ERROR/i.test(fileContents) &&
1070+
!/Invalid URL/i.test(fileContents));
10691071

10701072
if (!hasNetworkErrorInXML) {
10711073
break;
@@ -1133,7 +1135,9 @@ describe("hopp test [options] <file_path_or_id>", { timeout: 100000 }, () => {
11331135
const hasNetworkErrorInXML =
11341136
/ECONNRESET|EAI_AGAIN|ENOTFOUND|ETIMEDOUT|ECONNREFUSED/i.test(
11351137
fileContents
1136-
);
1138+
) ||
1139+
(/REQUEST_ERROR/i.test(fileContents) &&
1140+
!/Invalid URL/i.test(fileContents));
11371141

11381142
if (!hasNetworkErrorInXML) {
11391143
break;
@@ -1201,7 +1205,9 @@ describe("hopp test [options] <file_path_or_id>", { timeout: 100000 }, () => {
12011205
const hasNetworkErrorInXML =
12021206
/ECONNRESET|EAI_AGAIN|ENOTFOUND|ETIMEDOUT|ECONNREFUSED/i.test(
12031207
fileContents
1204-
);
1208+
) ||
1209+
(/REQUEST_ERROR/i.test(fileContents) &&
1210+
!/Invalid URL/i.test(fileContents));
12051211

12061212
if (!hasNetworkErrorInXML) {
12071213
break;
@@ -1273,7 +1279,9 @@ describe("hopp test [options] <file_path_or_id>", { timeout: 100000 }, () => {
12731279
const hasNetworkErrorInXML =
12741280
/ECONNRESET|EAI_AGAIN|ENOTFOUND|ETIMEDOUT|ECONNREFUSED/i.test(
12751281
fileContents
1276-
);
1282+
) ||
1283+
(/REQUEST_ERROR/i.test(fileContents) &&
1284+
!/Invalid URL/i.test(fileContents));
12771285

12781286
if (!hasNetworkErrorInXML) {
12791287
break;

0 commit comments

Comments
 (0)