[PR #4518] [MERGED] fix(cli): use os-specific invalid paths for tests #4845

Closed
opened 2026-03-17 02:20:35 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/hoppscotch/hoppscotch/pull/4518
Author: @CuriousCorrelation
Created: 11/7/2024
Status: Merged
Merged: 11/7/2024
Merged by: @jamesgeorge007

Base: patchHead: cli/fix/parsing-err-msg


📝 Commits (1)

  • 7cbf644 fix(cli): use os-specific invalid paths for tests

📊 Changes

1 file changed (+5 additions, -1 deletions)

View changed files

📝 packages/hoppscotch-cli/src/__tests__/e2e/commands/test.spec.ts (+5 -1)

📄 Description

CLI test failing on trying to test for invalid paths

Initial Issue:

Test is for the CLI tool to verify how it behaves when attempting to export a report to an invalid path.
But, when running the test on Windows, it failed to pass the assertions in the test, even though the error output was as expected.

The Test:

  const args = `test ${COLL_PATH} --reporter-junit /non-existent-path/report.xml`;
  ...
  ...
  const out = getErrorCode(stderr);
  expect(out).toBe<HoppErrorCode>("REPORT_EXPORT_FAILED");
});

What Went Wrong:

  • The test passed on most platforms, but not on Windows.
  • The main issue occurred because we were checking for a specific error code in the stderr, but Windows returned something different in stderr - ENOENT

The Solution:

  • On Windows, Z: would be an invalid drive letter (unless the drive is manually mapped, which it usually isn't).
  • On Linux (or other Unix-like systems), / is the root path.
  • Now both systems will have root path as the base for invalid paths.
const invalidPath = process.platform === 'win32'
  ? 'Z:/non-existent-path/report.xml'
  : '/non-existent/report.xml';

Closes HFE-647


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/hoppscotch/hoppscotch/pull/4518 **Author:** [@CuriousCorrelation](https://github.com/CuriousCorrelation) **Created:** 11/7/2024 **Status:** ✅ Merged **Merged:** 11/7/2024 **Merged by:** [@jamesgeorge007](https://github.com/jamesgeorge007) **Base:** `patch` ← **Head:** `cli/fix/parsing-err-msg` --- ### 📝 Commits (1) - [`7cbf644`](https://github.com/hoppscotch/hoppscotch/commit/7cbf64419885160a29741778160d6936f74ef157) fix(cli): use os-specific invalid paths for tests ### 📊 Changes **1 file changed** (+5 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `packages/hoppscotch-cli/src/__tests__/e2e/commands/test.spec.ts` (+5 -1) </details> ### 📄 Description ## CLI test failing on trying to test for invalid paths #### **Initial Issue:** Test is for the CLI tool to verify how it behaves when attempting to export a report to an invalid path. But, when running the test on **Windows**, it failed to pass the assertions in the test, even though the error output was as expected. #### **The Test:** ```javascript const args = `test ${COLL_PATH} --reporter-junit /non-existent-path/report.xml`; ... ... const out = getErrorCode(stderr); expect(out).toBe<HoppErrorCode>("REPORT_EXPORT_FAILED"); }); ``` #### **What Went Wrong:** - The test passed **on most platforms**, but not on **Windows**. - The main issue occurred because we were checking for a specific error code in the `stderr`, but Windows returned something different in `stderr` - `ENOENT` --- ### **The Solution:** - On **Windows**, `Z:` would be an invalid drive letter (unless the drive is manually mapped, which it usually isn't). - On **Linux** (or other Unix-like systems), `/` is the root path. - Now both systems will have root path as the base for invalid paths. ```javascript const invalidPath = process.platform === 'win32' ? 'Z:/non-existent-path/report.xml' : '/non-existent/report.xml'; ``` Closes HFE-647 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-17 02:20:35 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hoppscotch#4845
No description provided.