-
Notifications
You must be signed in to change notification settings - Fork 16
refactor: common vitest configurations #1107
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
Conversation
|
View your CI Pipeline Execution ↗ for commit 2772f2b
☁️ Nx Cloud last updated this comment at |
@code-pushup/ci
@code-pushup/cli
@code-pushup/core
@code-pushup/create-cli
@code-pushup/models
@code-pushup/coverage-plugin
@code-pushup/nx-plugin
@code-pushup/eslint-plugin
@code-pushup/js-packages-plugin
@code-pushup/jsdocs-plugin
@code-pushup/lighthouse-plugin
@code-pushup/typescript-plugin
@code-pushup/utils
@code-pushup/models-transformers
commit: |
Code PushUp🤨 Code PushUp report has both improvements and regressions – compared current commit a7b988f with previous commit c4b025c. 🕵️ See full comparison in Code PushUp portal 🔍 🏷️ Categories👎 2 groups regressed, 👍 1 audit improved, 👎 7 audits regressed, 14 audits changed without impacting score🗃️ Groups
19 other groups are unchanged. 🛡️ Audits
588 other audits are unchanged. |
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 cleaning up our test config mess :)
I left some comments.
- please add a proper PR description that contains the scope and planned changes
- move the config code under a Nx project in
testing/vitest-setup. I updated the issue accordingly.
testing/test-setup-config/src/lib/vitest-setup-presets.unit.test.ts
Outdated
Show resolved
Hide resolved
testing/test-setup-config/src/lib/vitest-setup-presets.unit.test.ts
Outdated
Show resolved
Hide resolved
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 changes! Nice testing tool! There is Readme, and tests, lovely.
I left some first comments and will wait for one feedback on the override logic for further comments.
9433ca5 to
7008a48
Compare
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.
Hi, thanks for your contribution 🙂 I think it looks promising, but ...
I don't think this PR goes far enough towards unification. Ideally, only 2 parameters1 would determine the entire Vitest config:
- Nx project name (e.g.,
cli,plugin-eslint,ci-e2e) 2 - test kind (
'unit' | 'int' | 'e2e')
My main criticism of this PR is that it doesn't commit to unification over flexibility. I believe we need less flexibility than it may appear, so I would go all in on unification. If we find some exception, we should question whether that exception is justified and get rid of it if possible.
In the current implementation, some things are automatically inferred, but there are many (IMHO unnecessary) optional arguments, and anything can be overridden by providing a Vitest config object. To me, this is a leaky abstraction.
I've suggested specifics on what can be unified in my comments. Let me know if I can clarify anything 🙂 I realize you couldn't reasonably have known many of these things, so no worries.
Footnotes
-
By "parameter", I don't strictly mean a function parameter. Your approach of exporting different factory functions for each test kind also works, for example. ↩
-
It may turn out we also need something like
projectRoot(e.g.,'packages/core'). In that case, we could either derive it via@nx/devkit'screateProjectGraphAsync, provide the project folder instead and derive its name usingpath.basename, or add another parameter. ↩
a11d027 to
38b7a6e
Compare
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 think this is headed in the right direction. I also reviewed the internal implementation this time, where I have some minor suggestions.
However, I think the pattern is now fairly clear, so please go ahead and apply it to other Vitest configs. 🙏
testing/test-setup-config/src/lib/vitest-config-factory.unit.test.ts
Outdated
Show resolved
Hide resolved
testing/test-setup-config/src/lib/vitest-config-factory.unit.test.ts
Outdated
Show resolved
Hide resolved
testing/test-setup-config/src/lib/vitest-config-factory.unit.test.ts
Outdated
Show resolved
Hide resolved
026b301 to
11d7699
Compare
e57bec1 to
4a71c54
Compare
4a71c54 to
307217d
Compare
a455669 to
cef39d3
Compare
…pdate test expectations
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.
Almost there 🤞
packages/plugin-eslint/mocks/fixtures/nx-monorepo/package-lock.json
Outdated
Show resolved
Hide resolved
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.
All good, thanks for your persistence 👏
Centralize and Standardize Vitest Configurations
What Changed
Benefits
The new system provides
createUnitConfig,createIntConfig, andcreateE2eConfigfactory functions that automatically handle common configuration patterns while still allowing customization through override parameters.Relates to first part of #1065