Skip to content
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

fix(testing): allows getJestProjects to fetch config information from inferred plugins #21806

Closed
wants to merge 1 commit into from

Conversation

king0120
Copy link

After updating my codebase to use the new plugin inference system, I found that I could no longer run pnpm jest at the root of my repo.

This change allows the getJestProject methods to pull from retrieveProjectConfigurations in order to find all project config files.

Current Behavior

When running pnpm jest at the root of the application, getJestProjects returns empty if there is not an explicit test target in the project.json

Expected Behavior

Running pnpm jest should run all valid Jest projects in the repository.

This is my first contribution to NX, happy to make any changes necessary and would love feedback!

… inferred plugins

After updating my codebase to use the new plugin inference system, I found that I could no longer
run pnpm jest at the root of my repo.

This change allows the getJestProject methods to pull from retrieveProjectConfigurations in order to
find all project config files.
@king0120 king0120 requested a review from a team as a code owner February 13, 2024 23:18
Copy link

vercel bot commented Feb 13, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Updated (UTC)
nx-dev ⬜️ Ignored (Inspect) Visit Preview Feb 13, 2024 11:19pm

@leosvelperez leosvelperez self-assigned this Feb 14, 2024
@leosvelperez leosvelperez self-requested a review February 14, 2024 09:19
Copy link
Member

@leosvelperez leosvelperez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking the time to contribute!

These changes turn the getJestProjects function into an async function, so the generated jest.config.ts at the workspace root needs to account for that. It's currently expecting a sync function.

Also, these changes don't really address the issue you're trying to solve. The inferred targets for Jest don't use the @nx/jest:jest executor, so they wouldn't be collected because in this function, we only look for targets with that executor. Those inferred targets use the nx:run-commands executor, and they use the command jest. On top of that, users could also overwrite the command in the project configuration to provide some extra args (e.g. jest --runInBand).

@leosvelperez
Copy link
Member

Thanks again for contributing! I'm going to close this in favor of #21897. We're instead adding a separate function to not break existing usages.

@king0120
Copy link
Author

king0120 commented Feb 22, 2024 via email

Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants