Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cli): use os-specific invalid paths for tests #4518

Merged

Conversation

CuriousCorrelation
Copy link
Contributor

@CuriousCorrelation CuriousCorrelation commented Nov 7, 2024

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

@jamesgeorge007 jamesgeorge007 merged commit 3de3209 into hoppscotch:patch Nov 7, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants