fix(core): make unit tests pass locally regardless of invoking package manager#35994
Open
FrozenPandaz wants to merge 3 commits into
Open
fix(core): make unit tests pass locally regardless of invoking package manager#35994FrozenPandaz wants to merge 3 commits into
FrozenPandaz wants to merge 3 commits into
Conversation
…orkspace-rooted resolution fails
…rministic package manager detection
✅ Deploy Preview for nx-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for nx-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
|
View your CI Pipeline Execution ↗ for commit f62aa24
☁️ Nx Cloud last updated this comment at |
…rministic package manager detection [Self-Healing CI Rerun]
Contributor
There was a problem hiding this comment.
Nx Cloud has identified a flaky task in your failed CI:
🔂 Since the failure was identified as flaky, we triggered a CI rerun by adding an empty commit to this branch.
🎓 Learn more about Self-Healing CI on nx.dev
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Current Behavior
Two classes of unit tests fail when run locally but pass on CI:
Running tests via
pnpm nx test <project>injectsnpm_config_user_agent=pnpm/...into the jest processes.detectPackageManagerfalls back to that variable when the test tree has no lockfile (the common case for in-memory trees), so package-manager-dependent generator tests behave differently than their snapshots expect. CI agents start vianpx nx-cloud, so the same tests see an npm user agent and pass.readNxJsonExtendsresolvesnx.jsonextendswithrequire.resolve(extendsPath, { paths: [tree.root] }). For in-memory test trees the root is/virtual, which has nonode_modules, and jest 30 throws after exhausting the given paths instead of falling back. Any test that reads an nx.json withextends(e.g.@nx/eslint:lint-projectpreset tests) fails with a cold jest cache.Expected Behavior
scripts/unit-test-setup.jsremovesnpm_config_user_agentso package manager detection in tests is deterministic and matches CI. Tests that exercise a specific package manager already force it explicitly (lockfile/pnpm-workspace.yaml in the tree, or setting the variable themselves).readNxJsonExtendsfalls back to resolving from the running nx package when workspace-rooted resolution fails.pnpm nx test eslintpasses fully locally with these changes (20/20 suites).Related Issue(s)