-
Notifications
You must be signed in to change notification settings - Fork 34
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
refactor(tests): Migrate caravan-bitcoin
tests from Jest to Vitest
#135
Conversation
- Convert test suite to use Vitest syntax and APIs - Reorganising to test directory - Resolve empty test suite issues in convertExtendedPublicKey tests
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Thanks to the work and config file setup that @DhairyaMajmudar did the conversion process was pretty smooth ... :) Just had to rewrite |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes done
There was a problem hiding this 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.
* 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. | ||
*/ |
There was a problem hiding this comment.
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:
* 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 | |
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion
There was a problem hiding this comment.
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"; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changes done
There was a problem hiding this comment.
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)?
There was a problem hiding this comment.
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"; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changes done
Related to #115
cc: @bucko13 @DhairyaMajmudar