-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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(vite): add angular option to vitest generator #29055
feat(vite): add angular option to vitest generator #29055
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
☁️ Nx Cloud ReportCI is running/has finished running commands for commit 578b0b1. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this CI Pipeline Execution ✅ Successfully ran 6 targets
Sent with 💌 from NxCloud. |
|
In order to improve tests maintainability and symmetry to production, I would love to replace fixtures like these: https://github.com/nrwl/nx/blob/8738d10446f17df7f9f30e3c94e509062feb0df2/packages/vite/src/utils/test-utils.ts with reusable "object mothers" in testing utils: const workspace = workspaceMother.withInferenceDisabled().build();
const app = angularAppMother.withName('my-app').withJestSetup().withSomeTests().build();
const lib = angularLibMother.withName('my-lib').build(); // no test config & no tests
createWorkspace(workspace);
createProjects([app, lib]) What do you think? |
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.
Docs changes approved
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.
Looks good, and testing it out locally worked fine.
One addressable comment, another is more thought-provoking but doesn't need to be solved.
project.targets[target].executor = '@nx/vite:test'; | ||
delete project.targets[target].options?.jestConfig; | ||
if (hasPlugin) { | ||
delete project.targets[target]; |
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.
This seems to be a new behavior. AFAICT, we currently don't delete a potentially previously existing target. Is this intended?
I don't think the generator should silently delete the target. It should error so the user knows there's an existing target that will override the inferred task and make the appropriate 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.
I think that I've implemented the generator a bit too much like a migration.
I'll turn this into an error.
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 just fixed this.
What should we do when vite plugin is enabled?
Should it error too if an existing target is shadowing vitest's test target?
While it is straightforward to handle this for vite plugin, what should we do for other plugins, like Nuxt?
5bfa2ec
to
87be47e
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.
Thanks for the changes! LGTM
34fd8a9
to
a479740
Compare
eb05588
to
7f95785
Compare
test(vitest): reorganize tests chore(vite): move angular plugin install to vitest generators chore(vite): move angular vite setup to vitest generator chore(vite): vite configuration generator does not handle angular because vitest generator does feat(vite): add angular option to vitest generator chore(vite): fix internal typing chore(vite): do not generate superfluous vite config chore(vite): tidy up chore(vite): add test ideas for vitest test target chore(vite): add tests for vitest test targets feat(vite): remove previous test target if inference is enabled chore(vite): refactor test to let the default addPlugin behavor express itself chore(vite): align tests with default coverage provider chore(vite): resurrect mistakenly removed option Revert "chore(vite): refactor test to let the default addPlugin behavor express itself" This reverts commit 3003325. chore(angular): remove old mentions of analogVitestAngular version feat(vite): do not overwrite test target if it already exists feat(vite): add angular detection to vitest configuration generator feat(vite): add react detection to vitest configuration generator feat(vite): improve angular/react framework detection docs(vite): remove default value for uiFramework in vitest configuration feat(vite): update analogjs vitest angular in correct location
7f95785
to
578b0b1
Compare
This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request. |
Current Behavior
@nx/vite:vitest
generator does not provide Angular support in theuiFramework
options.Expected Behavior
angular
option should generate the vitest configuration just like@nx/angular:application
and@nx/angular/library
do.