-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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(testing): add migration for moving test target defaults #19993
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Ignored Deployment
|
☁️ Nx Cloud ReportCI is running/has finished running commands for commit 25c540e. 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. |
59c4ee3
to
452443e
Compare
c9757e5
to
e47b7c0
Compare
export default async function update(tree: Tree) { | ||
const nxJson = readNxJson(tree); | ||
|
||
// Don't override anything if there are already target defaults for jest |
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.
Nit: s/jest/vitest/
)) { | ||
// If every target in every project does not use the target default anymore, it can be removed. | ||
if ( | ||
Object.values(projects).every((p) => |
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.
Minor: It's a migration so not too worried about maintenance, but I find the long, nested every
hard to grok. Would it better to use nested for-loops?
for (const [targetDefaultKey, targetDefault] of Object.entries(
nxJson.targetDefaults
)) {
let isDefaultUsed = false;
for (const p of Object.values(projects)) {
for (const targetName of Object.keys(p.data?.targets ?? {})) {
const defaults = readTargetDefaultsForTarget(
targetName,
nxJson.targetDefaults,
projectMap.get(p.name).targets?.[targetName]?.executor
);
if (defaults === targetDefault) {
isDefaultUsed = true;
break;
}
}
}
if (!isDefaultUsed) {
delete nxJson.targetDefaults[targetDefaultKey];
}
}
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.
Yes, I agree.
if (value.passWithNoTests === jestDefaults.options.passWithNoTests) { | ||
delete projConfig.targets[targetName].options.passWithNoTests; | ||
} else { | ||
projConfig.targets[targetName].options.passWithNoTests ??= false; |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
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.
Good catch. Now I don't change the value when one was set in target defaults.
e47b7c0
to
57ac58d
Compare
57ac58d
to
25c540e
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
There is no migration for the changes in #19963. New projects will be created without the settings without a
targetDefault
set.Expected Behavior
There is a migration to move the target defaults and options to the target defaults. New projects will still have those settings set. A lot of configuration will be removed from
project.json
files in the process. 🎉Related Issue(s)
Fixes #