[PR #4657] test(cli): migrate unit tests to vitest #4895

Open
opened 2026-03-17 02:23:19 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/hoppscotch/hoppscotch/pull/4657
Author: @SnazofSnaz
Created: 1/4/2025
Status: 🔄 Open

Base: nextHead: main


📝 Commits (5)

  • 0781baf chore(cli): update files to utilize vitest syntax directly; improve readme for testing guide
  • f930a24 test: enable CLI unit tests in CI
  • ab4787e Merge branch 'next' into main
  • 4b6b975 Merge branch 'next' into main
  • 149a9ff Merge branch 'next' into main

📊 Changes

19 files changed (+179 additions, -132 deletions)

View changed files

📝 packages/hoppscotch-cli/README.md (+11 -1)
📝 packages/hoppscotch-cli/src/__tests__/functions/checks/isHoppCLIError.spec.ts (+5 -4)
📝 packages/hoppscotch-cli/src/__tests__/functions/checks/isHoppErrnoException.spec.ts (+9 -8)
📝 packages/hoppscotch-cli/src/__tests__/functions/collection/collectionsRunner.spec.ts (+12 -12)
📝 packages/hoppscotch-cli/src/__tests__/functions/collection/collectionsRunnerResult.spec.ts (+8 -6)
📝 packages/hoppscotch-cli/src/__tests__/functions/getters/getDurationInSeconds.spec.ts (+2 -1)
📝 packages/hoppscotch-cli/src/__tests__/functions/getters/getEffectiveFinalMetaData.spec.ts (+10 -10)
📝 packages/hoppscotch-cli/src/__tests__/functions/mutators/parseCollectionData.spec.ts (+13 -10)
📝 packages/hoppscotch-cli/src/__tests__/functions/pre-request/getEffectiveRESTRequest.spec.ts (+5 -5)
📝 packages/hoppscotch-cli/src/__tests__/functions/pre-request/getPreRequestMetrics.spec.ts (+4 -2)
📝 packages/hoppscotch-cli/src/__tests__/functions/pre-request/preRequestScriptRunner.spec.ts (+5 -4)
📝 packages/hoppscotch-cli/src/__tests__/functions/request/delayPromiseFunction.spec.ts (+2 -0)
📝 packages/hoppscotch-cli/src/__tests__/functions/request/getRequestMetrics.spec.ts (+1 -0)
📝 packages/hoppscotch-cli/src/__tests__/functions/request/processRequest.spec.ts (+30 -21)
📝 packages/hoppscotch-cli/src/__tests__/functions/request/requestRunner.spec.ts (+50 -36)
📝 packages/hoppscotch-cli/src/__tests__/functions/test/getTestMetrics.spec.ts (+7 -6)
📝 packages/hoppscotch-cli/src/__tests__/functions/test/testDescriptorParser.spec.ts (+2 -0)
📝 packages/hoppscotch-cli/src/__tests__/functions/test/testRunner.spec.ts (+2 -1)
📝 packages/hoppscotch-cli/vitest.config.ts (+1 -5)

📄 Description

Update files to utilize Vitest syntax directly; improve readme for testing guide.

Closes #4136

Vitest dependency tested - changed the syntax of many unit tests to directly align with Vitest logic to reduce the reliance of Vitest compatibility layer transforming Jest syntax to Vitest syntax-

What's changed

  • src/tests/functions/checks/isHoppCLIError.spec.ts
  • src/tests/functions/checks/isHoppErrnoException.spec.ts
  • src/tests/functions/collection/collectionsRunner.spec.ts
  • src/tests/functions/collection/collectionsRunnerResult.spec.ts
  • src/tests/functions/getters/getDurationInSeconds.spec.ts
  • src/tests/functions/getters/getEffectiveFinalMetaData.spec.ts
  • src/tests/functions/mutators/parseCollectionData.spec.ts
  • src/tests/functions/pre-request/getEffectiveRESTRequest.spec.ts
  • src/tests/functions/pre-request/getPreRequestMetrics.spec.ts
  • src/tests/functions/pre-request/preRequestScriptRunner.spec.ts
  • src/tests/functions/request/delayPromiseFunction.spec.ts
  • src/tests/functions/request/getRequestMetrics.spec.ts
  • src/tests/functions/request/processRequest.spec.ts
  • src/tests/functions/request/requestRunner.spec.ts
  • src/tests/functions/test/getTestMetrics.spec.ts
  • src/tests/functions/test/testDescriptorParser.spec.ts
  • src/tests/functions/test/testRunner.spec.ts
  • readme file

Notes to reviewers

Some of these listed files will still show error if selected though have been updated, would require more effort in terms of "synchronicity" like setting a default parameter, to completely remedy - tested as are pass all tests but, could offer some improvement going forward. Appears risk of flaky tests could be further reduced within the unit test files directly if addressing from what I read as "synchronicity".


🔄 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/4657 **Author:** [@SnazofSnaz](https://github.com/SnazofSnaz) **Created:** 1/4/2025 **Status:** 🔄 Open **Base:** `next` ← **Head:** `main` --- ### 📝 Commits (5) - [`0781baf`](https://github.com/hoppscotch/hoppscotch/commit/0781baf025deb5dd019bb18c4c1f0473bfacd6dc) chore(cli): update files to utilize vitest syntax directly; improve readme for testing guide - [`f930a24`](https://github.com/hoppscotch/hoppscotch/commit/f930a242b607c67a18481b337cf27a1facee20e6) test: enable CLI unit tests in CI - [`ab4787e`](https://github.com/hoppscotch/hoppscotch/commit/ab4787e970e932217fd095c70e9316bd1ddfe6dd) Merge branch 'next' into main - [`4b6b975`](https://github.com/hoppscotch/hoppscotch/commit/4b6b975b7adaf79a27195ce16988ae7a25cadf87) Merge branch 'next' into main - [`149a9ff`](https://github.com/hoppscotch/hoppscotch/commit/149a9ff3139a857f80fb05114c7ce8fd4dbba97a) Merge branch 'next' into main ### 📊 Changes **19 files changed** (+179 additions, -132 deletions) <details> <summary>View changed files</summary> 📝 `packages/hoppscotch-cli/README.md` (+11 -1) 📝 `packages/hoppscotch-cli/src/__tests__/functions/checks/isHoppCLIError.spec.ts` (+5 -4) 📝 `packages/hoppscotch-cli/src/__tests__/functions/checks/isHoppErrnoException.spec.ts` (+9 -8) 📝 `packages/hoppscotch-cli/src/__tests__/functions/collection/collectionsRunner.spec.ts` (+12 -12) 📝 `packages/hoppscotch-cli/src/__tests__/functions/collection/collectionsRunnerResult.spec.ts` (+8 -6) 📝 `packages/hoppscotch-cli/src/__tests__/functions/getters/getDurationInSeconds.spec.ts` (+2 -1) 📝 `packages/hoppscotch-cli/src/__tests__/functions/getters/getEffectiveFinalMetaData.spec.ts` (+10 -10) 📝 `packages/hoppscotch-cli/src/__tests__/functions/mutators/parseCollectionData.spec.ts` (+13 -10) 📝 `packages/hoppscotch-cli/src/__tests__/functions/pre-request/getEffectiveRESTRequest.spec.ts` (+5 -5) 📝 `packages/hoppscotch-cli/src/__tests__/functions/pre-request/getPreRequestMetrics.spec.ts` (+4 -2) 📝 `packages/hoppscotch-cli/src/__tests__/functions/pre-request/preRequestScriptRunner.spec.ts` (+5 -4) 📝 `packages/hoppscotch-cli/src/__tests__/functions/request/delayPromiseFunction.spec.ts` (+2 -0) 📝 `packages/hoppscotch-cli/src/__tests__/functions/request/getRequestMetrics.spec.ts` (+1 -0) 📝 `packages/hoppscotch-cli/src/__tests__/functions/request/processRequest.spec.ts` (+30 -21) 📝 `packages/hoppscotch-cli/src/__tests__/functions/request/requestRunner.spec.ts` (+50 -36) 📝 `packages/hoppscotch-cli/src/__tests__/functions/test/getTestMetrics.spec.ts` (+7 -6) 📝 `packages/hoppscotch-cli/src/__tests__/functions/test/testDescriptorParser.spec.ts` (+2 -0) 📝 `packages/hoppscotch-cli/src/__tests__/functions/test/testRunner.spec.ts` (+2 -1) 📝 `packages/hoppscotch-cli/vitest.config.ts` (+1 -5) </details> ### 📄 Description Update files to utilize Vitest syntax directly; improve readme for testing guide. <!-- Thanks for creating this pull request 🤗 Please make sure that the pull request is limited to one type (docs, feature, etc.) and keep it as small as possible. You can open multiple prs instead of opening a huge one. --> <!-- If this pull request closes an issue, please mention the issue number below --> Closes #4136 Vitest dependency tested - changed the syntax of many unit tests to directly align with Vitest logic to reduce the reliance of Vitest compatibility layer transforming Jest syntax to Vitest syntax- ### What's changed - src/__tests__/functions/checks/isHoppCLIError.spec.ts - src/__tests__/functions/checks/isHoppErrnoException.spec.ts - src/__tests__/functions/collection/collectionsRunner.spec.ts - src/__tests__/functions/collection/collectionsRunnerResult.spec.ts - src/__tests__/functions/getters/getDurationInSeconds.spec.ts - src/__tests__/functions/getters/getEffectiveFinalMetaData.spec.ts - src/__tests__/functions/mutators/parseCollectionData.spec.ts - src/__tests__/functions/pre-request/getEffectiveRESTRequest.spec.ts - src/__tests__/functions/pre-request/getPreRequestMetrics.spec.ts - src/__tests__/functions/pre-request/preRequestScriptRunner.spec.ts - src/__tests__/functions/request/delayPromiseFunction.spec.ts - src/__tests__/functions/request/getRequestMetrics.spec.ts - src/__tests__/functions/request/processRequest.spec.ts - src/__tests__/functions/request/requestRunner.spec.ts - src/__tests__/functions/test/getTestMetrics.spec.ts - src/__tests__/functions/test/testDescriptorParser.spec.ts - src/__tests__/functions/test/testRunner.spec.ts - readme file ### Notes to reviewers Some of these listed files will still show error if selected though have been updated, would require more effort in terms of "synchronicity" like setting a default parameter, to completely remedy - tested as are pass all tests but, could offer some improvement going forward. Appears risk of flaky tests could be further reduced within the unit test files directly if addressing from what I read as "synchronicity". --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#4895
No description provided.