@nx/jest 23.0.0-beta.2 → 23.0.0-beta.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{index.d.ts → dist/index.d.ts} +0 -5
- package/{index.js → dist/index.js} +1 -6
- package/dist/internal.d.ts +2 -0
- package/dist/internal.js +13 -0
- package/{plugin.d.ts → dist/plugin.d.ts} +0 -1
- package/dist/plugins/resolver.d.ts +1 -0
- package/{plugins → dist/plugins}/resolver.js +1 -1
- package/{preset → dist/preset}/index.d.ts +0 -1
- package/{preset → dist/preset}/jest-preset.d.ts +0 -1
- package/{preset → dist/preset}/jest-preset.js +1 -0
- package/{preset.d.ts → dist/preset.d.ts} +0 -1
- package/{src → dist/src}/executors/jest/jest.impl.d.ts +0 -1
- package/{src → dist/src}/executors/jest/jest.impl.js +4 -2
- package/{src → dist/src}/executors/jest/schema.json +1 -0
- package/{src → dist/src}/executors/jest/summary.d.ts +0 -1
- package/{src → dist/src}/generators/configuration/configuration.d.ts +0 -1
- package/{src → dist/src}/generators/configuration/configuration.js +22 -8
- package/{src → dist/src}/generators/configuration/lib/check-for-test-target.d.ts +0 -1
- package/{src → dist/src}/generators/configuration/lib/create-files.d.ts +0 -1
- package/{src → dist/src}/generators/configuration/lib/create-files.js +2 -2
- package/{src → dist/src}/generators/configuration/lib/create-jest-config.d.ts +0 -1
- package/{src → dist/src}/generators/configuration/lib/create-jest-config.js +2 -2
- package/{src → dist/src}/generators/configuration/lib/ensure-dependencies.d.ts +0 -1
- package/{src → dist/src}/generators/configuration/lib/update-tsconfig.d.ts +0 -1
- package/{src → dist/src}/generators/configuration/lib/update-tsconfig.js +2 -2
- package/{src → dist/src}/generators/configuration/lib/update-vscode-recommended-extensions.d.ts +0 -1
- package/{src → dist/src}/generators/configuration/lib/update-workspace.d.ts +0 -1
- package/{src → dist/src}/generators/convert-to-inferred/convert-to-inferred.d.ts +0 -1
- package/{src → dist/src}/generators/convert-to-inferred/convert-to-inferred.js +13 -14
- package/{src → dist/src}/generators/init/init.d.ts +0 -1
- package/{src → dist/src}/generators/init/init.js +60 -21
- package/{src → dist/src}/migrations/update-20-0-0/replace-getJestProjects-with-getJestProjectsAsync.d.ts +0 -1
- package/{src/migrations/update-21-0-0 → dist/src/migrations/update-20-0-0}/replace-getJestProjects-with-getJestProjectsAsync.js +2 -2
- package/dist/src/migrations/update-20-0-0/replace-getJestProjects-with-getJestProjectsAsync.md +25 -0
- package/{src → dist/src}/migrations/update-21-0-0/remove-tsconfig-option-from-jest-executor.d.ts +0 -1
- package/dist/src/migrations/update-21-0-0/remove-tsconfig-option-from-jest-executor.js +97 -0
- package/dist/src/migrations/update-21-0-0/remove-tsconfig-option-from-jest-executor.md +102 -0
- package/{src → dist/src}/migrations/update-21-0-0/replace-getJestProjects-with-getJestProjectsAsync.d.ts +0 -1
- package/{src/migrations/update-20-0-0 → dist/src/migrations/update-21-0-0}/replace-getJestProjects-with-getJestProjectsAsync.js +2 -2
- package/dist/src/migrations/update-21-0-0/replace-getJestProjects-with-getJestProjectsAsync.md +25 -0
- package/{src → dist/src}/migrations/update-21-3-0/rename-test-path-pattern.d.ts +0 -1
- package/{src → dist/src}/migrations/update-21-3-0/rename-test-path-pattern.js +27 -11
- package/dist/src/migrations/update-21-3-0/rename-test-path-pattern.md +147 -0
- package/{src → dist/src}/migrations/update-21-3-0/replace-removed-matcher-aliases.d.ts +0 -1
- package/dist/src/migrations/update-21-3-0/replace-removed-matcher-aliases.md +51 -0
- package/{src → dist/src}/migrations/update-22-2-0/convert-jest-config-to-cjs.d.ts +0 -1
- package/dist/src/migrations/update-22-2-0/convert-jest-config-to-cjs.md +33 -0
- package/dist/src/migrations/update-23-0-0/rewrite-internal-subpath-imports.d.ts +3 -0
- package/dist/src/migrations/update-23-0-0/rewrite-internal-subpath-imports.js +201 -0
- package/dist/src/migrations/update-23-0-0/rewrite-jest-project-generator.d.ts +3 -0
- package/dist/src/migrations/update-23-0-0/rewrite-jest-project-generator.js +121 -0
- package/dist/src/migrations/update-23-0-0/update-snapshot-guide-link.d.ts +2 -0
- package/dist/src/migrations/update-23-0-0/update-snapshot-guide-link.js +28 -0
- package/dist/src/migrations/update-23-0-0/update-snapshot-guide-link.md +21 -0
- package/{src → dist/src}/plugins/plugin.d.ts +0 -1
- package/{src → dist/src}/plugins/plugin.js +18 -25
- package/{src → dist/src}/utils/ast-utils.d.ts +0 -1
- package/{src → dist/src}/utils/config/config-file.d.ts +0 -1
- package/{src → dist/src}/utils/config/functions.d.ts +0 -1
- package/{src → dist/src}/utils/config/functions.js +7 -7
- package/{src → dist/src}/utils/config/get-jest-projects.d.ts +0 -1
- package/{src → dist/src}/utils/config/get-jest-projects.js +2 -2
- package/{src → dist/src}/utils/config/update-config.d.ts +0 -1
- package/dist/src/utils/deprecation.d.ts +3 -0
- package/dist/src/utils/deprecation.js +15 -0
- package/{src → dist/src}/utils/version-utils.d.ts +0 -1
- package/{src → dist/src}/utils/versions.d.ts +0 -1
- package/{src → dist/src}/utils/versions.js +11 -5
- package/executors.json +3 -3
- package/generators.json +6 -6
- package/migrations.json +45 -7
- package/package.json +65 -10
- package/index.d.ts.map +0 -1
- package/plugin.d.ts.map +0 -1
- package/plugins/resolver.d.ts +0 -2
- package/plugins/resolver.d.ts.map +0 -1
- package/preset/index.d.ts.map +0 -1
- package/preset/jest-preset.d.ts.map +0 -1
- package/preset.d.ts.map +0 -1
- package/src/executors/jest/jest.impl.d.ts.map +0 -1
- package/src/executors/jest/summary.d.ts.map +0 -1
- package/src/generators/configuration/configuration.d.ts.map +0 -1
- package/src/generators/configuration/lib/check-for-test-target.d.ts.map +0 -1
- package/src/generators/configuration/lib/create-files.d.ts.map +0 -1
- package/src/generators/configuration/lib/create-jest-config.d.ts.map +0 -1
- package/src/generators/configuration/lib/ensure-dependencies.d.ts.map +0 -1
- package/src/generators/configuration/lib/update-tsconfig.d.ts.map +0 -1
- package/src/generators/configuration/lib/update-vscode-recommended-extensions.d.ts.map +0 -1
- package/src/generators/configuration/lib/update-workspace.d.ts.map +0 -1
- package/src/generators/convert-to-inferred/convert-to-inferred.d.ts.map +0 -1
- package/src/generators/init/init.d.ts.map +0 -1
- package/src/migrations/update-20-0-0/replace-getJestProjects-with-getJestProjectsAsync.d.ts.map +0 -1
- package/src/migrations/update-21-0-0/remove-tsconfig-option-from-jest-executor.d.ts.map +0 -1
- package/src/migrations/update-21-0-0/remove-tsconfig-option-from-jest-executor.js +0 -65
- package/src/migrations/update-21-0-0/replace-getJestProjects-with-getJestProjectsAsync.d.ts.map +0 -1
- package/src/migrations/update-21-3-0/rename-test-path-pattern.d.ts.map +0 -1
- package/src/migrations/update-21-3-0/replace-removed-matcher-aliases.d.ts.map +0 -1
- package/src/migrations/update-22-2-0/convert-jest-config-to-cjs.d.ts.map +0 -1
- package/src/plugins/plugin.d.ts.map +0 -1
- package/src/utils/ast-utils.d.ts.map +0 -1
- package/src/utils/config/config-file.d.ts.map +0 -1
- package/src/utils/config/functions.d.ts.map +0 -1
- package/src/utils/config/get-jest-projects.d.ts.map +0 -1
- package/src/utils/config/update-config.d.ts.map +0 -1
- package/src/utils/version-utils.d.ts.map +0 -1
- package/src/utils/versions.d.ts.map +0 -1
- /package/{LICENSE → dist/LICENSE} +0 -0
- /package/{PLUGIN.md → dist/PLUGIN.md} +0 -0
- /package/{plugin.js → dist/plugin.js} +0 -0
- /package/{preset → dist/preset}/index.js +0 -0
- /package/{preset.js → dist/preset.js} +0 -0
- /package/{src → dist/src}/executors/jest/schema.d.ts +0 -0
- /package/{src → dist/src}/executors/jest/summary.js +0 -0
- /package/{src → dist/src}/generators/configuration/files/common/src/test-setup.ts__tmpl__ +0 -0
- /package/{src → dist/src}/generators/configuration/files/common/tsconfig.spec.json__tmpl__ +0 -0
- /package/{src → dist/src}/generators/configuration/files/jest-config-non-ts-solution/jest.config.ts__tmpl__ +0 -0
- /package/{src → dist/src}/generators/configuration/files/jest-config-ts-solution/jest.config.ts__tmpl__ +0 -0
- /package/{src → dist/src}/generators/configuration/files-angular/jest.config.ts__tmpl__ +0 -0
- /package/{src → dist/src}/generators/configuration/files-angular/src/test-setup.ts__tmpl__ +0 -0
- /package/{src → dist/src}/generators/configuration/files-angular/tsconfig.spec.json__tmpl__ +0 -0
- /package/{src → dist/src}/generators/configuration/lib/check-for-test-target.js +0 -0
- /package/{src → dist/src}/generators/configuration/lib/ensure-dependencies.js +0 -0
- /package/{src → dist/src}/generators/configuration/lib/update-vscode-recommended-extensions.js +0 -0
- /package/{src → dist/src}/generators/configuration/lib/update-workspace.js +0 -0
- /package/{src → dist/src}/generators/configuration/schema.d.ts +0 -0
- /package/{src → dist/src}/generators/configuration/schema.json +0 -0
- /package/{src → dist/src}/generators/convert-to-inferred/schema.json +0 -0
- /package/{src → dist/src}/generators/init/schema.d.ts +0 -0
- /package/{src → dist/src}/generators/init/schema.json +0 -0
- /package/{src → dist/src}/migrations/update-21-3-0/replace-removed-matcher-aliases.js +0 -0
- /package/{src → dist/src}/migrations/update-22-2-0/convert-jest-config-to-cjs.js +0 -0
- /package/{src → dist/src}/utils/ast-utils.js +0 -0
- /package/{src → dist/src}/utils/config/config-file.js +0 -0
- /package/{src → dist/src}/utils/config/update-config.js +0 -0
- /package/{src → dist/src}/utils/version-utils.js +0 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = default_1;
|
|
4
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const EXECUTOR_TO_MIGRATE = '@nx/jest:jest';
|
|
7
|
+
const ENTRY_META_KEYS = new Set(['target', 'executor', 'projects', 'plugin']);
|
|
8
|
+
async function default_1(tree) {
|
|
9
|
+
// update options from project configs
|
|
10
|
+
(0, internal_1.forEachExecutorOptions)(tree, EXECUTOR_TO_MIGRATE, (options, project, target, configuration) => {
|
|
11
|
+
if (options.tsConfig === undefined) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const projectConfiguration = (0, devkit_1.readProjectConfiguration)(tree, project);
|
|
15
|
+
if (configuration) {
|
|
16
|
+
updateConfiguration(projectConfiguration.targets[target], configuration);
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
updateOptions(projectConfiguration.targets[target]);
|
|
20
|
+
}
|
|
21
|
+
(0, devkit_1.updateProjectConfiguration)(tree, project, projectConfiguration);
|
|
22
|
+
});
|
|
23
|
+
// update options from nx.json target defaults
|
|
24
|
+
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
25
|
+
if (nxJson.targetDefaults) {
|
|
26
|
+
if (Array.isArray(nxJson.targetDefaults)) {
|
|
27
|
+
const next = [];
|
|
28
|
+
for (const entry of nxJson.targetDefaults) {
|
|
29
|
+
if (entry.target !== EXECUTOR_TO_MIGRATE &&
|
|
30
|
+
entry.executor !== EXECUTOR_TO_MIGRATE) {
|
|
31
|
+
next.push(entry);
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
if (entry.options)
|
|
35
|
+
updateOptions(entry);
|
|
36
|
+
Object.keys(entry.configurations ?? {}).forEach((config) => {
|
|
37
|
+
updateConfiguration(entry, config);
|
|
38
|
+
});
|
|
39
|
+
if (!isEntryEmpty(entry)) {
|
|
40
|
+
next.push(entry);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (next.length === 0) {
|
|
44
|
+
delete nxJson.targetDefaults;
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
nxJson.targetDefaults = next;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
for (const [targetOrExecutor, targetConfig] of Object.entries(nxJson.targetDefaults)) {
|
|
52
|
+
if (targetOrExecutor !== EXECUTOR_TO_MIGRATE &&
|
|
53
|
+
targetConfig.executor !== EXECUTOR_TO_MIGRATE) {
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
if (targetConfig.options) {
|
|
57
|
+
updateOptions(targetConfig);
|
|
58
|
+
}
|
|
59
|
+
Object.keys(targetConfig.configurations ?? {}).forEach((config) => {
|
|
60
|
+
updateConfiguration(targetConfig, config);
|
|
61
|
+
});
|
|
62
|
+
if (!Object.keys(targetConfig).length ||
|
|
63
|
+
(Object.keys(targetConfig).length === 1 &&
|
|
64
|
+
Object.keys(targetConfig)[0] === 'executor')) {
|
|
65
|
+
delete nxJson.targetDefaults[targetOrExecutor];
|
|
66
|
+
}
|
|
67
|
+
if (!Object.keys(nxJson.targetDefaults).length) {
|
|
68
|
+
delete nxJson.targetDefaults;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
73
|
+
}
|
|
74
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
75
|
+
}
|
|
76
|
+
// An entry is "empty" once only filter/meta keys remain (target, executor,
|
|
77
|
+
// projects, plugin) — nothing else worth keeping around.
|
|
78
|
+
function isEntryEmpty(entry) {
|
|
79
|
+
return Object.keys(entry).every((k) => ENTRY_META_KEYS.has(k));
|
|
80
|
+
}
|
|
81
|
+
function updateOptions(target) {
|
|
82
|
+
delete target.options.tsConfig;
|
|
83
|
+
if (!Object.keys(target.options).length) {
|
|
84
|
+
delete target.options;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
function updateConfiguration(target, configuration) {
|
|
88
|
+
delete target.configurations[configuration].tsConfig;
|
|
89
|
+
if (!Object.keys(target.configurations[configuration]).length &&
|
|
90
|
+
(!target.defaultConfiguration ||
|
|
91
|
+
target.defaultConfiguration !== configuration)) {
|
|
92
|
+
delete target.configurations[configuration];
|
|
93
|
+
}
|
|
94
|
+
if (!Object.keys(target.configurations).length) {
|
|
95
|
+
delete target.configurations;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
#### Remove `tsConfig` Option from Jest Executor
|
|
2
|
+
|
|
3
|
+
Removes the previously deprecated and unused `tsConfig` option from the `@nx/jest:jest` executor configuration in all projects.
|
|
4
|
+
|
|
5
|
+
#### Examples
|
|
6
|
+
|
|
7
|
+
Remove the option from the project configuration:
|
|
8
|
+
|
|
9
|
+
##### Before
|
|
10
|
+
|
|
11
|
+
```json title="apps/myapp/project.json" {7}
|
|
12
|
+
{
|
|
13
|
+
"targets": {
|
|
14
|
+
"test": {
|
|
15
|
+
"executor": "@nx/jest:jest",
|
|
16
|
+
"options": {
|
|
17
|
+
"jestConfig": "apps/myapp/jest.config.ts",
|
|
18
|
+
"tsConfig": "apps/myapp/tsconfig.spec.json"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
##### After
|
|
26
|
+
|
|
27
|
+
```json title="apps/myapp/project.json"
|
|
28
|
+
{
|
|
29
|
+
"targets": {
|
|
30
|
+
"test": {
|
|
31
|
+
"executor": "@nx/jest:jest",
|
|
32
|
+
"options": {
|
|
33
|
+
"jestConfig": "apps/myapp/jest.config.ts"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Remove the option from a target default using the `@nx/jest:jest` executor:
|
|
41
|
+
|
|
42
|
+
##### Before
|
|
43
|
+
|
|
44
|
+
```json title="nx.json" {7}
|
|
45
|
+
{
|
|
46
|
+
"targetDefaults": {
|
|
47
|
+
"test": {
|
|
48
|
+
"executor": "@nx/jest:jest",
|
|
49
|
+
"options": {
|
|
50
|
+
"jestConfig": "{projectRoot}/jest.config.ts",
|
|
51
|
+
"tsConfig": "{projectRoot}/tsconfig.spec.json"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
##### After
|
|
59
|
+
|
|
60
|
+
```json title="nx.json"
|
|
61
|
+
{
|
|
62
|
+
"targetDefaults": {
|
|
63
|
+
"test": {
|
|
64
|
+
"executor": "@nx/jest:jest",
|
|
65
|
+
"options": {
|
|
66
|
+
"jestConfig": "{projectRoot}/jest.config.ts"
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Remove the option from a target default using the `@nx/jest:jest` executor as the key:
|
|
74
|
+
|
|
75
|
+
##### Before
|
|
76
|
+
|
|
77
|
+
```json title="nx.json" {6}
|
|
78
|
+
{
|
|
79
|
+
"targetDefaults": {
|
|
80
|
+
"@nx/jest:jest": {
|
|
81
|
+
"options": {
|
|
82
|
+
"jestConfig": "{projectRoot}/jest.config.ts",
|
|
83
|
+
"tsConfig": "{projectRoot}/tsconfig.spec.json"
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
##### After
|
|
91
|
+
|
|
92
|
+
```json title="nx.json"
|
|
93
|
+
{
|
|
94
|
+
"targetDefaults": {
|
|
95
|
+
"@nx/jest:jest": {
|
|
96
|
+
"options": {
|
|
97
|
+
"jestConfig": "{projectRoot}/jest.config.ts"
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
```
|
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.default = update;
|
|
7
7
|
const devkit_1 = require("@nx/devkit");
|
|
8
|
-
const
|
|
8
|
+
const internal_1 = require("@nx/js/internal");
|
|
9
9
|
let tsModule;
|
|
10
10
|
async function update(tree) {
|
|
11
11
|
if (!tsModule) {
|
|
12
|
-
tsModule = (0,
|
|
12
|
+
tsModule = (0, internal_1.ensureTypescript)();
|
|
13
13
|
}
|
|
14
14
|
const jestConfigPaths = await (0, devkit_1.globAsync)(tree, [
|
|
15
15
|
'**/jest.config.{cjs,mjs,js,cts,mts,ts}',
|
package/dist/src/migrations/update-21-0-0/replace-getJestProjects-with-getJestProjectsAsync.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#### Replace Usage of `getJestProjects` with `getJestProjectsAsync`
|
|
2
|
+
|
|
3
|
+
Replaces the usage of the removed `getJestProjects` function with the `getJestProjectsAsync` function.
|
|
4
|
+
|
|
5
|
+
#### Sample Code Changes
|
|
6
|
+
|
|
7
|
+
##### Before
|
|
8
|
+
|
|
9
|
+
```ts title="jest.config.ts"
|
|
10
|
+
import { getJestProjects } from '@nx/jest';
|
|
11
|
+
|
|
12
|
+
export default {
|
|
13
|
+
projects: getJestProjects(),
|
|
14
|
+
};
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
##### After
|
|
18
|
+
|
|
19
|
+
```ts title="jest.config.ts"
|
|
20
|
+
import { getJestProjectsAsync } from '@nx/jest';
|
|
21
|
+
|
|
22
|
+
export default async () => ({
|
|
23
|
+
projects: await getJestProjectsAsync(),
|
|
24
|
+
});
|
|
25
|
+
```
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = default_1;
|
|
4
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
4
5
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
|
|
6
6
|
// migration for https://github.com/jestjs/jest/commit/41133b526d2c17bc9758f90d6026b25301cf0552
|
|
7
7
|
async function default_1(tree) {
|
|
8
8
|
// update options from project configs
|
|
9
|
-
(0,
|
|
9
|
+
(0, internal_1.forEachExecutorOptions)(tree, '@nx/jest:jest', (_, project, target, configuration) => {
|
|
10
10
|
const projectConfiguration = (0, devkit_1.readProjectConfiguration)(tree, project);
|
|
11
11
|
const config = configuration
|
|
12
12
|
? projectConfiguration.targets[target].configurations[configuration]
|
|
@@ -19,17 +19,33 @@ async function default_1(tree) {
|
|
|
19
19
|
if (!nxJson.targetDefaults) {
|
|
20
20
|
return;
|
|
21
21
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
if (Array.isArray(nxJson.targetDefaults)) {
|
|
23
|
+
for (const entry of nxJson.targetDefaults) {
|
|
24
|
+
if (entry.target !== '@nx/jest:jest' &&
|
|
25
|
+
entry.executor !== '@nx/jest:jest') {
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
if (entry.options) {
|
|
29
|
+
renameTestPathPattern(entry.options);
|
|
30
|
+
}
|
|
31
|
+
Object.values(entry.configurations ?? {}).forEach((config) => {
|
|
32
|
+
renameTestPathPattern(config);
|
|
33
|
+
});
|
|
26
34
|
}
|
|
27
|
-
|
|
28
|
-
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
for (const [targetOrExecutor, targetConfig] of Object.entries(nxJson.targetDefaults)) {
|
|
38
|
+
if (targetOrExecutor !== '@nx/jest:jest' &&
|
|
39
|
+
targetConfig.executor !== '@nx/jest:jest') {
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
if (targetConfig.options) {
|
|
43
|
+
renameTestPathPattern(targetConfig.options);
|
|
44
|
+
}
|
|
45
|
+
Object.values(targetConfig.configurations ?? {}).forEach((config) => {
|
|
46
|
+
renameTestPathPattern(config);
|
|
47
|
+
});
|
|
29
48
|
}
|
|
30
|
-
Object.values(targetConfig.configurations ?? {}).forEach((config) => {
|
|
31
|
-
renameTestPathPattern(config);
|
|
32
|
-
});
|
|
33
49
|
}
|
|
34
50
|
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
35
51
|
await (0, devkit_1.formatFiles)(tree);
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
#### Rename `testPathPattern` to `testPathPatterns`
|
|
2
|
+
|
|
3
|
+
Renames the `testPathPattern` option to `testPathPatterns` in the `@nx/jest:jest` executor configuration to align with Jest v30 CLI changes. Read more at the [Jest v30 migration notes](https://jestjs.io/docs/upgrading-to-jest30#--testpathpattern-was-renamed-to---testpathpatterns).
|
|
4
|
+
|
|
5
|
+
#### Examples
|
|
6
|
+
|
|
7
|
+
Rename the option in project configuration:
|
|
8
|
+
|
|
9
|
+
##### Before
|
|
10
|
+
|
|
11
|
+
```json title="apps/myapp/project.json" {7}
|
|
12
|
+
{
|
|
13
|
+
"targets": {
|
|
14
|
+
"test": {
|
|
15
|
+
"executor": "@nx/jest:jest",
|
|
16
|
+
"options": {
|
|
17
|
+
"jestConfig": "apps/myapp/jest.config.ts",
|
|
18
|
+
"testPathPattern": "some-regex"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
##### After
|
|
26
|
+
|
|
27
|
+
```json title="apps/myapp/project.json" {7}
|
|
28
|
+
{
|
|
29
|
+
"targets": {
|
|
30
|
+
"test": {
|
|
31
|
+
"executor": "@nx/jest:jest",
|
|
32
|
+
"options": {
|
|
33
|
+
"jestConfig": "apps/myapp/jest.config.ts",
|
|
34
|
+
"testPathPatterns": "some-regex"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Rename the option in project configuration with configurations:
|
|
42
|
+
|
|
43
|
+
##### Before
|
|
44
|
+
|
|
45
|
+
```json title="apps/myapp/project.json" {7,10,11}
|
|
46
|
+
{
|
|
47
|
+
"targets": {
|
|
48
|
+
"test": {
|
|
49
|
+
"executor": "@nx/jest:jest",
|
|
50
|
+
"options": {
|
|
51
|
+
"jestConfig": "apps/myapp/jest.config.ts",
|
|
52
|
+
"testPathPattern": "some-regex"
|
|
53
|
+
},
|
|
54
|
+
"configurations": {
|
|
55
|
+
"development": { "testPathPattern": "regex-dev" },
|
|
56
|
+
"production": { "testPathPattern": "regex-prod" }
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
##### After
|
|
64
|
+
|
|
65
|
+
```json title="apps/myapp/project.json" {7,10,11}
|
|
66
|
+
{
|
|
67
|
+
"targets": {
|
|
68
|
+
"test": {
|
|
69
|
+
"executor": "@nx/jest:jest",
|
|
70
|
+
"options": {
|
|
71
|
+
"jestConfig": "apps/myapp/jest.config.ts",
|
|
72
|
+
"testPathPatterns": "some-regex"
|
|
73
|
+
},
|
|
74
|
+
"configurations": {
|
|
75
|
+
"development": { "testPathPatterns": "regex-dev" },
|
|
76
|
+
"production": { "testPathPatterns": "regex-prod" }
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Rename the option in a target default using the `@nx/jest:jest` executor:
|
|
84
|
+
|
|
85
|
+
##### Before
|
|
86
|
+
|
|
87
|
+
```json title="nx.json" {7}
|
|
88
|
+
{
|
|
89
|
+
"targetDefaults": {
|
|
90
|
+
"test": {
|
|
91
|
+
"executor": "@nx/jest:jest",
|
|
92
|
+
"options": {
|
|
93
|
+
"jestConfig": "{projectRoot}/jest.config.ts",
|
|
94
|
+
"testPathPattern": "some-regex"
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
##### After
|
|
102
|
+
|
|
103
|
+
```json title="nx.json" {7}
|
|
104
|
+
{
|
|
105
|
+
"targetDefaults": {
|
|
106
|
+
"test": {
|
|
107
|
+
"executor": "@nx/jest:jest",
|
|
108
|
+
"options": {
|
|
109
|
+
"jestConfig": "{projectRoot}/jest.config.ts",
|
|
110
|
+
"testPathPatterns": "some-regex"
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Rename the option in a target default using the `@nx/jest:jest` executor as the key:
|
|
118
|
+
|
|
119
|
+
##### Before
|
|
120
|
+
|
|
121
|
+
```json title="nx.json" {6}
|
|
122
|
+
{
|
|
123
|
+
"targetDefaults": {
|
|
124
|
+
"@nx/jest:jest": {
|
|
125
|
+
"options": {
|
|
126
|
+
"jestConfig": "{projectRoot}/jest.config.ts",
|
|
127
|
+
"testPathPattern": "some-regex"
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
##### After
|
|
135
|
+
|
|
136
|
+
```json title="nx.json" {6}
|
|
137
|
+
{
|
|
138
|
+
"targetDefaults": {
|
|
139
|
+
"@nx/jest:jest": {
|
|
140
|
+
"options": {
|
|
141
|
+
"jestConfig": "{projectRoot}/jest.config.ts",
|
|
142
|
+
"testPathPatterns": "some-regex"
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
```
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
#### Replace Removed Matcher Aliases
|
|
2
|
+
|
|
3
|
+
Replaces removed Jest matcher aliases in test files with their corresponding matchers to align with Jest v30 changes. Read more at the [Jest v30 migration notes](https://jestjs.io/docs/upgrading-to-jest30#jest-expect--matchers).
|
|
4
|
+
|
|
5
|
+
#### Examples
|
|
6
|
+
|
|
7
|
+
##### Before
|
|
8
|
+
|
|
9
|
+
```typescript title="apps/myapp/src/app.spec.ts"
|
|
10
|
+
describe('test', () => {
|
|
11
|
+
it('should pass', async () => {
|
|
12
|
+
expect(mockFn).toBeCalled();
|
|
13
|
+
expect(mockFn).toBeCalledTimes(1);
|
|
14
|
+
expect(mockFn).toBeCalledWith(arg);
|
|
15
|
+
expect(mockFn).lastCalledWith(arg);
|
|
16
|
+
expect(mockFn).nthCalledWith(1, arg);
|
|
17
|
+
expect(mockFn).toReturn();
|
|
18
|
+
expect(mockFn).toReturnTimes(1);
|
|
19
|
+
expect(mockFn).toReturnWith(value);
|
|
20
|
+
expect(mockFn).lastReturnedWith(value);
|
|
21
|
+
expect(mockFn).nthReturnedWith(1, value);
|
|
22
|
+
expect(() => someFn()).toThrowError();
|
|
23
|
+
expect(() => someFn()).not.toThrowError();
|
|
24
|
+
await expect(someAsyncFn()).rejects.toThrowError();
|
|
25
|
+
await expect(someAsyncFn()).resolves.not.toThrowError();
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
##### After
|
|
31
|
+
|
|
32
|
+
```typescript title="apps/myapp/src/app.spec.ts"
|
|
33
|
+
describe('test', () => {
|
|
34
|
+
it('should pass', async () => {
|
|
35
|
+
expect(mockFn).toHaveBeenCalled();
|
|
36
|
+
expect(mockFn).toHaveBeenCalledTimes(1);
|
|
37
|
+
expect(mockFn).toHaveBeenCalledWith(arg);
|
|
38
|
+
expect(mockFn).toHaveBeenLastCalledWith(arg);
|
|
39
|
+
expect(mockFn).toHaveBeenNthCalledWith(1, arg);
|
|
40
|
+
expect(mockFn).toHaveReturned();
|
|
41
|
+
expect(mockFn).toHaveReturnedTimes(1);
|
|
42
|
+
expect(mockFn).toHaveReturnedWith(value);
|
|
43
|
+
expect(mockFn).toHaveLastReturnedWith(value);
|
|
44
|
+
expect(mockFn).toHaveNthReturnedWith(1, value);
|
|
45
|
+
expect(() => someFn()).toThrow();
|
|
46
|
+
expect(() => someFn()).not.toThrow();
|
|
47
|
+
await expect(someAsyncFn()).rejects.toThrow();
|
|
48
|
+
await expect(someAsyncFn()).resolves.not.toThrow();
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
```
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#### Convert Jest Config to CJS
|
|
2
|
+
|
|
3
|
+
Converts `jest.config.ts` files to `jest.config.cts`. This is needed because Node.js type-stripping in newer versions (22+, 24+) can cause issues with ESM syntax in `.ts` files when the project is configured for CommonJS.
|
|
4
|
+
|
|
5
|
+
This migration only runs if `@nx/jest/plugin` is registered in `nx.json`.
|
|
6
|
+
|
|
7
|
+
#### Examples
|
|
8
|
+
|
|
9
|
+
##### Before
|
|
10
|
+
|
|
11
|
+
```typescript title="jest.config.ts"
|
|
12
|
+
import { foo } from 'bar';
|
|
13
|
+
import baz from 'qux';
|
|
14
|
+
|
|
15
|
+
export default {
|
|
16
|
+
displayName: 'myapp',
|
|
17
|
+
preset: foo,
|
|
18
|
+
transform: baz,
|
|
19
|
+
};
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
##### After
|
|
23
|
+
|
|
24
|
+
```typescript title="jest.config.cts"
|
|
25
|
+
const { foo } = require('bar');
|
|
26
|
+
const baz = require('qux').default ?? require('qux');
|
|
27
|
+
|
|
28
|
+
module.exports = {
|
|
29
|
+
displayName: 'myapp',
|
|
30
|
+
preset: foo,
|
|
31
|
+
transform: baz,
|
|
32
|
+
};
|
|
33
|
+
```
|