refactor: common vitest configurations#1107
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. |
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
9433ca5 to
7008a48
Compare
matejchalk
left a comment
There was a problem hiding this comment.
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
matejchalk
left a comment
There was a problem hiding this comment.
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
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