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

refactor(tests): Migrate caravan-bitcoin tests from Jest to Vitest #135

Merged
merged 2 commits into from
Oct 10, 2024

Conversation

Legend101Zz
Copy link
Contributor

Related to #115

  • Convert test suite to use Vitest syntax and APIs
  • Reorganising to test directory
  • Resolve empty test suite issues in convertExtendedPublicKey tests

cc: @bucko13 @DhairyaMajmudar

- Convert test suite to use Vitest syntax and APIs
- Reorganising to test directory
- Resolve empty test suite issues in convertExtendedPublicKey tests
Copy link

changeset-bot bot commented Sep 13, 2024

⚠️ No Changeset found

Latest commit: f2bb57f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

vercel bot commented Sep 13, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
caravan-coordinator ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 9, 2024 8:20pm

@Legend101Zz
Copy link
Contributor Author

Thanks to the work and config file setup that @DhairyaMajmudar did the conversion process was pretty smooth ... :)

Just had to rewrite convertExtendedPublicKey test of keys.test.ts a little ... explained the reason here

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pls. remove vitest config file from the individual packages since they are managed globally by one vitest config file for every package.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes done

Copy link
Contributor

@bucko13 bucko13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly looks good! Couple comments and small cleanup items.

Comment on lines 399 to 405
* Dev Note:
* This flat structure using test.each() is used differences between Jest and Vitest in handling empty test suites:
* differences between Jest and Vitest in handling empty test suites:
* 1. Vitest treats empty describe blocks as errors, while Jest ignores them.
* 2. The previous nested forEach structure could create empty describe blocks
* for key types not present in extendedPubKeyNode.
*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need to reference the old version here, but maybe still useful to explain why using flatMap. Something like:

Suggested change
* Dev Note:
* This flat structure using test.each() is used differences between Jest and Vitest in handling empty test suites:
* differences between Jest and Vitest in handling empty test suites:
* 1. Vitest treats empty describe blocks as errors, while Jest ignores them.
* 2. The previous nested forEach structure could create empty describe blocks
* for key types not present in extendedPubKeyNode.
*/
* NOTE: vitest's `test.each()` treats empty describe
* blocks as errors, in contrast to jest which just ignores
* them. Using flatMap instead of forEach avoids
* potentially creating empty describe blocks for key types
* not present in extended pubkey nodes
*/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes done

@@ -1,5 +1,6 @@
import { scriptToOps, scriptToHex } from "./script";
import { TEST_FIXTURES } from "./fixtures";
import { describe, it, expect } from "vitest";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these shouldn't be necessary with the globals.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changes done

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strange. Any idea why the diffs for all the other test files mark them as moved, but this one shows as a new file (and the old one deleted)?

Copy link
Contributor Author

@Legend101Zz Legend101Zz Oct 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not completely sure as it's been a while since I pushed this code ... but I guess I did accidentaly create a new file in tests dir , so maybe that's why the diff shows a new file

@@ -0,0 +1,63 @@
import { describe, it, expect, beforeAll } from "vitest";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't be needed with globals for vitest declared.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changes done

@bucko13 bucko13 merged commit 130e309 into caravan-bitcoin:vite-migration Oct 10, 2024
3 checks 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.

3 participants