-
Notifications
You must be signed in to change notification settings - Fork 112
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
Vitest #114
base: main
Are you sure you want to change the base?
Vitest #114
Conversation
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.
Great stuff! Excited for this work
@@ -2,3 +2,46 @@ export type Verification = { | |||
isValid: boolean; | |||
isPotentiallyValid: boolean; | |||
}; | |||
|
|||
export type CreditCardType = { |
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.
great catch on these
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.
A couple questions, and it looks like the tests are failing for what might be a Common.js issue?
Great stuff!
src/__tests__/tsconfig.json
Outdated
@@ -1,5 +1,6 @@ | |||
{ | |||
"compilerOptions": { | |||
"moduleResolution": "nodenext", |
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.
Curious, what does this do?
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.
It instructs TypeScript to use Node.js-style module resolution for the tests.
Changed to "node"
month: string | null; | ||
year: string | null; | ||
} | ||
import type { ExpirationDateVerification } from "./types"; |
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.
Love the renaming of this variable
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.
is this rename a breaking change?
@@ -19,4 +19,4 @@ const cardValidator = { | |||
postalCode, | |||
}; | |||
|
|||
export = cardValidator; | |||
export default cardValidator; |
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.
Does changing this to have a default export change the way consumers of this module import it?
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.
Yes, you can see the change in the __tests__/credit-card-type.ts
file
Before: import cardValidator = require("../")
After:import cardValidator from "../"
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.
Got it! Would this be a breaking change?
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.
same concern here, would this be a breaking change?
https://www.typescriptlang.org/tsconfig#moduleResolution
|
Quick PR Summary
Why
Vitest is a "blazingly fast" unit test framework, and allows us to leave the test suite running in a watch-mode environment while we continue to make changes to our code. Only the necessary tests will re-run depending on what files were changed, making it much quicker to make changes without having to wait for the entire test suite to re-run.
Vitest has also been designed with a Jest compatible API, in order to make the migration from Jest as simple as possible. The API is essentially the same as Jest with some very minor differences.