Skip to content

Commit addf107

Browse files
feat(testing): add option ciGroupName to @nx/jest/plugin (#29365)
Add option `ciGroupName` to the `@nx/jest/plugin` to allow customizing the `Jest` atomized taks group on CI. <!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> <!-- If this is a particularly complex change or feature addition, you can request a dedicated Nx release for this pull request branch. Mention someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they will confirm if the PR warrants its own release for testing purposes, and generate it for you if appropriate. --> ## Current Behavior <!-- This is the behavior we have today --> When using Atomizer on Jest for **unit tests** (via the `"ciTargetName": "test-ci"`), the atomized tasks will be grouped under the misleading name **"E2E (CI)"**. Worst, if Atomizer is enabled for both **unit** and **e2e** tests, it will result on E2E atomized tasks being overwritten by the one from unit tests... when run on Nx Cloud. ## Expected Behavior <!-- This is the behavior we should expect with the changes in this PR --> Allow customizing the name of the atomized tasks group. The group name can be derived from the `ciTargetName` , when not explicitly provided. ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #28066 Co-authored-by: Leosvel Pérez Espinosa <[email protected]>
1 parent 0edd110 commit addf107

File tree

4 files changed

+741
-218
lines changed

4 files changed

+741
-218
lines changed

docs/generated/packages/jest/documents/overview.md

+21
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,27 @@ target with that name which can be used in CI to run the tests for each file in
9191
}
9292
```
9393

94+
### Customizing atomized unit/e2e tasks group name
95+
96+
By default, the atomized tasks group name is derived from the `ciTargetName`. For example, atomized tasks for the `e2e-ci` target will be grouped under the name "E2E (CI)" when displayed in Nx Cloud or `nx show project <project> --web` UI.
97+
You can customize that name by explicitly providing the optional `ciGroupName` plugin option as such:
98+
99+
```json {% fileName="nx.json" %}
100+
{
101+
"plugins": [
102+
{
103+
"plugin": "@nx/jest/plugin",
104+
"include": ["e2e/**/*"],
105+
"options": {
106+
"targetName": "e2e-local",
107+
"ciTargetName": "e2e-ci",
108+
"ciGroupname": "My E2E tests (CI)"
109+
}
110+
}
111+
]
112+
}
113+
```
114+
94115
### How @nx/jest Infers Tasks
95116

96117
{% callout type="note" title="Inferred Tasks" %}

docs/shared/packages/jest/jest-plugin.md

+21
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,27 @@ target with that name which can be used in CI to run the tests for each file in
9191
}
9292
```
9393

94+
### Customizing atomized unit/e2e tasks group name
95+
96+
By default, the atomized tasks group name is derived from the `ciTargetName`. For example, atomized tasks for the `e2e-ci` target will be grouped under the name "E2E (CI)" when displayed in Nx Cloud or `nx show project <project> --web` UI.
97+
You can customize that name by explicitly providing the optional `ciGroupName` plugin option as such:
98+
99+
```json {% fileName="nx.json" %}
100+
{
101+
"plugins": [
102+
{
103+
"plugin": "@nx/jest/plugin",
104+
"include": ["e2e/**/*"],
105+
"options": {
106+
"targetName": "e2e-local",
107+
"ciTargetName": "e2e-ci",
108+
"ciGroupname": "My E2E tests (CI)"
109+
}
110+
}
111+
]
112+
}
113+
```
114+
94115
### How @nx/jest Infers Tasks
95116

96117
{% callout type="note" title="Inferred Tasks" %}

0 commit comments

Comments
 (0)