Skip to content

Conversation

Mararok
Copy link
Contributor

@Mararok Mararok commented Aug 29, 2024

Small fix for using jest-runner-groups(https://www.npmjs.com/package/jest-runner-groups) with Nx.

Current Behavior

When running jest executor with extra group argument like:

nx run app-nebula-explorer-api:test --group=unit

jest-runner-groups runs all tests, not only from selected group.

From my investigation, jest-runner-groups using process.argv to extract --group args
https://github.com/eugene-manuilov/jest-runner-groups/blob/3c9d3cf4cb3e595bdea733100f2bdc8d64f871d7/index.js#L57
and process.argv passed to runner contains:

[
 'M:\\programs\\nodejs\\22\\node.exe',
 'M:\\projects\\someproject\\node_modules\\.pnpm\\nx@19.3.2_@swc+core@1.6.6_@swc+helpers@0.5.11_\\node_modules\\nx\\bin\\run-executor.js'   
]

Expected Behavior

Running jest executor with jest-runner-groups runner and --group args should run only tests from group.

PR changes summary

I implemented fix as generic and any extra arg will be added to process.argv .

@Mararok Mararok requested a review from a team as a code owner August 29, 2024 21:14
@Mararok Mararok requested a review from FrozenPandaz August 29, 2024 21:14
Copy link

vercel bot commented Aug 29, 2024

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

1 Skipped Deployment
Name Status Preview Updated (UTC)
nx-dev ⬜️ Ignored (Inspect) Visit Preview Jan 29, 2025 2:00pm
Copy link
Contributor

nx-cloud bot commented Aug 29, 2024

View your CI Pipeline Execution ↗ for commit eaa7a54.

Command Status Duration Result
nx affected --targets=lint,test,build,e2e,e2e-c... ✅ Succeeded 33m 31s View ↗
nx run-many -t check-imports check-commit check... ✅ Succeeded 38s View ↗
nx-cloud record -- nx-cloud conformance:check ✅ Succeeded 1s View ↗
nx-cloud record -- nx format:check --base=13cbc... ✅ Succeeded 12s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded 11s View ↗
nx documentation --no-dte ✅ Succeeded 29s View ↗

☁️ Nx Cloud last updated this comment at 2025-01-29 15:17:20 UTC

@Mararok Mararok force-pushed the fix-testing-jest-extra-args-passing branch 4 times, most recently from 40d2e86 to 56e5336 Compare September 3, 2024 21:06
@Mararok Mararok force-pushed the fix-testing-jest-extra-args-passing branch 4 times, most recently from cb63dad to 039a471 Compare September 14, 2024 08:25
@Mararok Mararok force-pushed the fix-testing-jest-extra-args-passing branch 4 times, most recently from 46d3fac to 3f28c91 Compare September 26, 2024 15:40
@Mararok Mararok force-pushed the fix-testing-jest-extra-args-passing branch 2 times, most recently from ec6b727 to aea11b5 Compare October 4, 2024 17:59
@Mararok Mararok force-pushed the fix-testing-jest-extra-args-passing branch 2 times, most recently from 1e3f934 to ef55f09 Compare October 15, 2024 16:31
@Mararok Mararok force-pushed the fix-testing-jest-extra-args-passing branch from ef55f09 to d3015c8 Compare December 5, 2024 17:04
@Mararok Mararok force-pushed the fix-testing-jest-extra-args-passing branch from d3015c8 to f0f75a5 Compare December 13, 2024 21:52
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 the contribution!

@leosvelperez leosvelperez enabled auto-merge (squash) January 29, 2025 13:58
@leosvelperez leosvelperez changed the title fix(testing): fix passing extra args to Jest cli Jan 29, 2025
@leosvelperez leosvelperez changed the title fix(testing): forward extra args to the jest cli through theprocess.argv in jest executor Jan 29, 2025
@leosvelperez leosvelperez merged commit 8266785 into nrwl:master Jan 29, 2025
5 checks passed
@Mararok Mararok deleted the fix-testing-jest-extra-args-passing branch February 2, 2025 09:03
FrozenPandaz pushed a commit that referenced this pull request Feb 6, 2025
Small fix for using
jest-runner-groups(https://www.npmjs.com/package/jest-runner-groups)
with Nx.

## Current Behavior
When running jest executor with extra group argument like:
```
nx run app-nebula-explorer-api:test --group=unit
```
`jest-runner-groups` runs all tests, not only from selected group.

From my investigation, `jest-runner-groups` using process.argv to
extract `--group` args

https://github.com/eugene-manuilov/jest-runner-groups/blob/3c9d3cf4cb3e595bdea733100f2bdc8d64f871d7/index.js#L57
and  `process.argv` passed to runner contains:

```javascript
[
 'M:\\programs\\nodejs\\22\\node.exe',
 'M:\\projects\\someproject\\node_modules\\.pnpm\\nx@19.3.2_@swc+core@1.6.6_@swc+helpers@0.5.11_\\node_modules\\nx\\bin\\run-executor.js'
]
```

## Expected Behavior
Running jest executor with jest-runner-groups runner and `--group` args
should run only tests from group.

## PR changes summary
I implemented fix as generic and any extra arg will be added to
`process.argv` .

---------

Co-authored-by: Leosvel Pérez Espinosa <leosvel.perez.espinosa@gmail.com>
(cherry picked from commit 8266785)
Copy link
Contributor

github-actions bot commented Feb 8, 2025

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 8, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

2 participants