-
Notifications
You must be signed in to change notification settings - Fork 282
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
feat(backend): Migrate to vitest #4296
Conversation
🦋 Changeset detectedLatest commit: 01e60b6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 0 packagesWhen changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
d33a518
to
c70d74d
Compare
@@ -88,7 +88,7 @@ export function buildRequest(options: BuildRequestOptions) { | |||
let res: Response | undefined; | |||
try { | |||
if (formData) { | |||
res = await runtime.fetch(finalUrl.href, { | |||
res = await (process.env.NODE_ENV === 'test' ? fetch : runtime.fetch)(finalUrl.href, { |
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.
Will need to think about a more ergonomic way of accomplishing this. With the way fetch
is handled in the package, msw
can't intercept requests without it for now
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.
@BRKalow Any thoughts on how you would like to move forward here?
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.
@jacekradko can we try to consolidate into the runtime module? so at least usage of runtime.fetch doesn't need to be aware of the NODE_ENV
{ | ||
"name": "Debug Vitest", | ||
"type": "node", | ||
"request": "launch", | ||
"program": "${workspaceFolder}/scripts/vitest-debug.mjs", | ||
"args": ["${file}"], | ||
"cwd": "${workspaceFolder}", | ||
"console": "integratedTerminal", | ||
"internalConsoleOptions": "neverOpen", | ||
"autoAttachChildProcesses": true, | ||
"smartStep": true, | ||
"skipFiles": ["<node_internals>/**", "**/node_modules/**"] |
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.
Added a debug configuration for any vitest
spec
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.
Really nice work! Would be great to shift the NODE_ENV
fetch check into the runtime module. Left a few minor questions.
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.
52bb50b
to
5665e6e
Compare
5f074a9
to
53f6585
Compare
Description
Spiking out
vitest
test runner as a replacement forqunit
in@clerk/backend
.Changes
vitest
runnermsw
instead of mockingfetch
Related: https://linear.app/clerk/issue/SDKI-694/refactor-clerkbackend-to-use-vitest-instead-of-qunit
Checklist
npm test
runs as expected.npm run build
runs as expected.Type of change