-
Notifications
You must be signed in to change notification settings - Fork 29
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
ci: vitest workspaces #868
Conversation
@@ -29,12 +29,12 @@ | |||
"content": { | |||
"application/json": { | |||
"schema": { | |||
"$ref": "./test/__fixtures__/bundle/pet.json" | |||
"$ref": "./packages/oas-normalize/test/__fixtures__/bundle/pet.json" |
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 running npm test
from inside packages/oas-normalize
still work with this?
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.
nope 😕
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 mentioned this in the PR description — not sure which is better
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.
can probably change this file from definition.json
to definition.js
and have it export the def + change this ref to use require.resolve('oas-normalize/test/__fixtures__/bundle/pet.json')
. wonder if that'd work. it wouldn't be a relative import anymore but i don't think that matters too much since relative file refs are tested in json-schema-ref-parse
and openapi-parser
anyways.
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.
cool with this as-is tho
@erunion mind taking another look? tried out a new approach, see this chunk of the updated PR description:
|
vitest.workspace.ts
Outdated
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.
should oas-normalize
have its own workspace config so if you run vitest
from inside that package it'll run the chdir test too?
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.
oooh i hadn't thought of that - let me play around!
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 in eebc72b — works like a charm ✨
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 dislike how we have four config files now, but i can't seem to think of a simpler approach here that addresses everything)
🧰 Changes
Messing around with Vitest Workspaces and it seems pretty great. Previously, we had to
cd
into the correct subpackage in order to runnpx vitest [path to file]
but now we can just do it from the root 😌I forked a test in
oas-normalize
into its own config + test file and made it so it useschdir
as part of the test. That way, we can run tests from the both the root and from the subpackages and it'll ✨ just work ✨(no longer applicable)
the downside here is that in
oas-normalize
there's one test that will now fail unless it's being run from the project root. Feels like a worthy trade-off, but let me know if you disagree.As part of this, I also upgraded our Vitest deps to the latest and added coverage into the mix.
🧬 QA & Testing
If tests (which should be faster now?) pass, we should be in good shape!