@nx/jest 23.0.0-beta.1 → 23.0.0-beta.10
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/migrations.json +28 -0
- package/package.json +6 -6
- package/preset/jest-preset.d.ts.map +1 -1
- package/preset/jest-preset.js +1 -0
- package/src/executors/jest/jest.impl.d.ts.map +1 -1
- package/src/executors/jest/jest.impl.js +2 -0
- package/src/executors/jest/schema.json +1 -0
- package/src/generators/configuration/configuration.d.ts.map +1 -1
- package/src/generators/configuration/configuration.js +2 -0
- package/src/generators/convert-to-inferred/convert-to-inferred.d.ts.map +1 -1
- package/src/generators/convert-to-inferred/convert-to-inferred.js +13 -14
- package/src/generators/init/init.d.ts.map +1 -1
- package/src/generators/init/init.js +2 -2
- package/src/migrations/update-21-0-0/remove-tsconfig-option-from-jest-executor.d.ts.map +1 -1
- package/src/migrations/update-21-0-0/remove-tsconfig-option-from-jest-executor.js +2 -2
- package/src/migrations/update-21-3-0/rename-test-path-pattern.d.ts.map +1 -1
- package/src/migrations/update-21-3-0/rename-test-path-pattern.js +2 -2
- package/src/migrations/update-23-0-0/update-snapshot-guide-link.d.ts +3 -0
- package/src/migrations/update-23-0-0/update-snapshot-guide-link.d.ts.map +1 -0
- package/src/migrations/update-23-0-0/update-snapshot-guide-link.js +28 -0
- package/src/plugins/plugin.d.ts.map +1 -1
- package/src/plugins/plugin.js +14 -22
- package/src/utils/deprecation.d.ts +4 -0
- package/src/utils/deprecation.d.ts.map +1 -0
- package/src/utils/deprecation.js +15 -0
- package/src/utils/versions.d.ts.map +1 -1
- package/src/utils/versions.js +9 -4
package/migrations.json
CHANGED
|
@@ -42,6 +42,14 @@
|
|
|
42
42
|
},
|
|
43
43
|
"description": "Replace removed matcher aliases in Jest v30 with their corresponding matcher",
|
|
44
44
|
"implementation": "./src/migrations/update-21-3-0/replace-removed-matcher-aliases"
|
|
45
|
+
},
|
|
46
|
+
"update-snapshot-guide-link": {
|
|
47
|
+
"version": "23.0.0-beta.10",
|
|
48
|
+
"requires": {
|
|
49
|
+
"jest": ">=30.0.0"
|
|
50
|
+
},
|
|
51
|
+
"description": "Update the Jest snapshot guide link in `.snap` files from the legacy `https://goo.gl/fbAQLP` URL to `https://jestjs.io/docs/snapshot-testing`, which Jest v30 now requires.",
|
|
52
|
+
"implementation": "./src/migrations/update-23-0-0/update-snapshot-guide-link"
|
|
45
53
|
}
|
|
46
54
|
},
|
|
47
55
|
"packageJsonUpdates": {
|
|
@@ -171,6 +179,26 @@
|
|
|
171
179
|
"alwaysAddToPackageJson": false
|
|
172
180
|
}
|
|
173
181
|
}
|
|
182
|
+
},
|
|
183
|
+
"23.0.0-pin-jest-30-3-for-rn-compat": {
|
|
184
|
+
"version": "23.0.0-beta.9",
|
|
185
|
+
"requires": {
|
|
186
|
+
"jest": ">=30.0.0"
|
|
187
|
+
},
|
|
188
|
+
"packages": {
|
|
189
|
+
"jest": {
|
|
190
|
+
"version": "~30.3.0",
|
|
191
|
+
"alwaysAddToPackageJson": false
|
|
192
|
+
},
|
|
193
|
+
"babel-jest": {
|
|
194
|
+
"version": "~30.3.0",
|
|
195
|
+
"alwaysAddToPackageJson": false
|
|
196
|
+
},
|
|
197
|
+
"@types/jest": {
|
|
198
|
+
"version": "~30.0.0",
|
|
199
|
+
"alwaysAddToPackageJson": false
|
|
200
|
+
}
|
|
201
|
+
}
|
|
174
202
|
}
|
|
175
203
|
}
|
|
176
204
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/jest",
|
|
3
|
-
"version": "23.0.0-beta.
|
|
3
|
+
"version": "23.0.0-beta.10",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The Nx Plugin for Jest contains executors and generators allowing your workspace to use the powerful Jest testing capabilities.",
|
|
6
6
|
"repository": {
|
|
@@ -38,14 +38,14 @@
|
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@jest/reporters": "^30.0.2",
|
|
40
40
|
"@jest/test-result": "^30.0.2",
|
|
41
|
-
"@nx/devkit": "23.0.0-beta.
|
|
42
|
-
"@nx/js": "23.0.0-beta.
|
|
43
|
-
"@phenomnomnominal/tsquery": "~6.
|
|
41
|
+
"@nx/devkit": "23.0.0-beta.10",
|
|
42
|
+
"@nx/js": "23.0.0-beta.10",
|
|
43
|
+
"@phenomnomnominal/tsquery": "~6.2.0",
|
|
44
44
|
"identity-obj-proxy": "3.0.0",
|
|
45
45
|
"jest-config": "^30.0.2",
|
|
46
46
|
"jest-resolve": "^30.0.2",
|
|
47
47
|
"jest-util": "^30.0.2",
|
|
48
|
-
"minimatch": "10.2.
|
|
48
|
+
"minimatch": "10.2.5",
|
|
49
49
|
"picocolors": "^1.1.0",
|
|
50
50
|
"resolve.exports": "2.0.3",
|
|
51
51
|
"semver": "^7.6.3",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"yargs-parser": "21.1.1"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"nx": "23.0.0-beta.
|
|
56
|
+
"nx": "23.0.0-beta.10"
|
|
57
57
|
},
|
|
58
58
|
"publishConfig": {
|
|
59
59
|
"access": "public"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jest-preset.d.ts","sourceRoot":"","sources":["../../../../packages/jest/preset/jest-preset.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAc,MAAM,MAAM,CAAC;AAK1C,eAAO,MAAM,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"jest-preset.d.ts","sourceRoot":"","sources":["../../../../packages/jest/preset/jest-preset.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAc,MAAM,MAAM,CAAC;AAK1C,eAAO,MAAM,QAAQ,EAAE,MAuCtB,CAAC"}
|
package/preset/jest-preset.js
CHANGED
|
@@ -25,6 +25,7 @@ exports.nxPreset = {
|
|
|
25
25
|
],
|
|
26
26
|
},
|
|
27
27
|
testEnvironment: 'jsdom',
|
|
28
|
+
modulePathIgnorePatterns: ['<rootDir>/dist/', '<rootDir>/out-tsc/'],
|
|
28
29
|
/**
|
|
29
30
|
* manually set the exports names to load in common js, to mimic the behaviors of jest 27
|
|
30
31
|
* before jest didn't fully support package exports and would load in common js code (typically via main field). now jest 28+ will load in the browser esm code, but jest esm support is not fully supported.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jest.impl.d.ts","sourceRoot":"","sources":["../../../../../../packages/jest/src/executors/jest/jest.impl.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EACL,eAAe,EAEf,SAAS,EAEV,MAAM,YAAY,CAAC;AAGpB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;
|
|
1
|
+
{"version":3,"file":"jest.impl.d.ts","sourceRoot":"","sources":["../../../../../../packages/jest/src/executors/jest/jest.impl.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EACL,eAAe,EAEf,SAAS,EAEV,MAAM,YAAY,CAAC;AAGpB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AAI7E,wBAAsB,YAAY,CAChC,OAAO,EAAE,mBAAmB,EAC5B,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CAiB/B;AAiBD,wBAAsB,eAAe,CACnC,OAAO,EAAE,mBAAmB,EAC5B,OAAO,EAAE,eAAe,EACxB,aAAa,UAAQ,GACpB,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAqGtB;AAED,eAAe,YAAY,CAAC;AAE5B,wBAAsB,SAAS,CAC7B,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,EAC3C,SAAS,EAAE,mBAAmB,EAC9B,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,YAAY,CAAC,CA8FvB"}
|
|
@@ -13,8 +13,10 @@ const path_1 = require("path");
|
|
|
13
13
|
const devkit_1 = require("@nx/devkit");
|
|
14
14
|
const summary_1 = require("./summary");
|
|
15
15
|
const fs_1 = require("fs");
|
|
16
|
+
const deprecation_1 = require("../../utils/deprecation");
|
|
16
17
|
process.env.NODE_ENV ??= 'test';
|
|
17
18
|
async function jestExecutor(options, context) {
|
|
19
|
+
(0, deprecation_1.warnJestExecutorDeprecation)();
|
|
18
20
|
// Jest registers ts-node with module CJS https://github.com/SimenB/jest/blob/v29.6.4/packages/jest-config/src/readConfigFileAndSetRootDir.ts#L117-L119
|
|
19
21
|
// We want to support of ESM via 'module':'nodenext', we need to override the resolution until Jest supports it.
|
|
20
22
|
const existingValue = process.env['TS_NODE_COMPILER_OPTIONS'];
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
"description": "Jest target options for Build Facade.",
|
|
6
6
|
"cli": "nx",
|
|
7
7
|
"type": "object",
|
|
8
|
+
"x-deprecated": "The `@nx/jest:jest` executor is deprecated and will be removed in Nx v24. Run `nx g @nx/jest:convert-to-inferred` to migrate to the `@nx/jest/plugin` inferred plugin. See https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.",
|
|
8
9
|
"presets": [
|
|
9
10
|
{
|
|
10
11
|
"name": "Pass Without Tests",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configuration.d.ts","sourceRoot":"","sources":["../../../../../../packages/jest/src/generators/configuration/configuration.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EAKjB,IAAI,EAEL,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"configuration.d.ts","sourceRoot":"","sources":["../../../../../../packages/jest/src/generators/configuration/configuration.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EAKjB,IAAI,EAEL,MAAM,YAAY,CAAC;AAiBpB,OAAO,EAAE,iBAAiB,EAA+B,MAAM,UAAU,CAAC;AAyD1E,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,iBAAiB,8BAE3E;AAED,wBAAsB,8BAA8B,CAClD,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,iBAAiB,GACxB,OAAO,CAAC,iBAAiB,CAAC,CAkE5B;AAgBD,eAAe,sBAAsB,CAAC"}
|
|
@@ -7,6 +7,7 @@ const js_1 = require("@nx/js");
|
|
|
7
7
|
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
8
8
|
const config_file_1 = require("../../utils/config/config-file");
|
|
9
9
|
const init_1 = require("../init/init");
|
|
10
|
+
const deprecation_1 = require("../../utils/deprecation");
|
|
10
11
|
const check_for_test_target_1 = require("./lib/check-for-test-target");
|
|
11
12
|
const create_files_1 = require("./lib/create-files");
|
|
12
13
|
const create_jest_config_1 = require("./lib/create-jest-config");
|
|
@@ -88,6 +89,7 @@ async function configurationGeneratorInternal(tree, schema) {
|
|
|
88
89
|
}
|
|
89
90
|
});
|
|
90
91
|
if (!hasPlugin || options.addExplicitTargets) {
|
|
92
|
+
(0, deprecation_1.warnJestExecutorGenerating)();
|
|
91
93
|
(0, update_workspace_1.updateWorkspace)(tree, options);
|
|
92
94
|
}
|
|
93
95
|
if (options.isTsSolutionSetup) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convert-to-inferred.d.ts","sourceRoot":"","sources":["../../../../../../packages/jest/src/generators/convert-to-inferred/convert-to-inferred.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"convert-to-inferred.d.ts","sourceRoot":"","sources":["../../../../../../packages/jest/src/generators/convert-to-inferred/convert-to-inferred.ts"],"names":[],"mappings":"AAOA,OAAO,EAIL,KAAK,IAAI,EACV,MAAM,YAAY,CAAC;AAOpB,UAAU,MAAM;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,iBA0BlE;AA8DD,eAAe,iBAAiB,CAAC"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.convertToInferred = convertToInferred;
|
|
4
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
4
5
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const executor_to_plugin_migrator_1 = require("@nx/devkit/src/generators/plugin-migrations/executor-to-plugin-migrator");
|
|
6
|
-
const plugin_migration_utils_1 = require("@nx/devkit/src/generators/plugin-migrations/plugin-migration-utils");
|
|
7
6
|
const jest_config_1 = require("jest-config");
|
|
8
7
|
const node_path_1 = require("node:path");
|
|
9
8
|
const plugin_1 = require("../../plugins/plugin");
|
|
@@ -11,7 +10,7 @@ const config_file_1 = require("../../utils/config/config-file");
|
|
|
11
10
|
const versions_1 = require("../../utils/versions");
|
|
12
11
|
async function convertToInferred(tree, options) {
|
|
13
12
|
const projectGraph = await (0, devkit_1.createProjectGraphAsync)();
|
|
14
|
-
const migratedProjects = await (0,
|
|
13
|
+
const migratedProjects = await (0, internal_1.migrateProjectExecutorsToPlugin)(tree, projectGraph, '@nx/jest/plugin', plugin_1.createNodesV2, { targetName: 'test' }, [
|
|
15
14
|
{
|
|
16
15
|
executors: ['@nx/jest:jest', '@nrwl/jest:jest'],
|
|
17
16
|
postTargetTransformer,
|
|
@@ -19,7 +18,7 @@ async function convertToInferred(tree, options) {
|
|
|
19
18
|
},
|
|
20
19
|
], options.project);
|
|
21
20
|
if (migratedProjects.size === 0) {
|
|
22
|
-
throw new
|
|
21
|
+
throw new internal_1.NoTargetsToMigrateError();
|
|
23
22
|
}
|
|
24
23
|
if (!options.skipFormat) {
|
|
25
24
|
await (0, devkit_1.formatFiles)(tree);
|
|
@@ -49,7 +48,7 @@ async function postTargetTransformer(target, tree, projectDetails, inferredTarge
|
|
|
49
48
|
}
|
|
50
49
|
}
|
|
51
50
|
if (target.outputs) {
|
|
52
|
-
(0,
|
|
51
|
+
(0, internal_1.processTargetOutputs)(target, [], inferredTarget, {
|
|
53
52
|
projectName: projectDetails.projectName,
|
|
54
53
|
projectRoot: projectDetails.root,
|
|
55
54
|
});
|
|
@@ -68,11 +67,11 @@ async function updateOptionsObject(tree, targetOptions, projectRoot, workspaceRo
|
|
|
68
67
|
async function updateConfigurationObject(tree, targetOptions, projectRoot, workspaceRoot, defaultJestConfigPath) {
|
|
69
68
|
const jestConfigPath = targetOptions.jestConfig ?? defaultJestConfigPath;
|
|
70
69
|
if (targetOptions.jestConfig) {
|
|
71
|
-
targetOptions.config = (0,
|
|
70
|
+
targetOptions.config = (0, internal_1.toProjectRelativePath)(targetOptions.jestConfig, projectRoot);
|
|
72
71
|
delete targetOptions.jestConfig;
|
|
73
72
|
}
|
|
74
73
|
else if (targetOptions.config) {
|
|
75
|
-
targetOptions.config = (0,
|
|
74
|
+
targetOptions.config = (0, internal_1.toProjectRelativePath)(targetOptions.config, projectRoot);
|
|
76
75
|
}
|
|
77
76
|
await updateOptions(tree, targetOptions, projectRoot, workspaceRoot, jestConfigPath);
|
|
78
77
|
}
|
|
@@ -127,7 +126,7 @@ async function updateOptions(tree, targetOptions, projectRoot, workspaceRoot, je
|
|
|
127
126
|
// the executor accepts a comma-separated string, while jest accepts a space-separated string
|
|
128
127
|
const parsedSourceFiles = targetOptions.findRelatedTests
|
|
129
128
|
.split(',')
|
|
130
|
-
.map((s) => (0,
|
|
129
|
+
.map((s) => (0, internal_1.toProjectRelativePath)(s.trim(), projectRoot))
|
|
131
130
|
.join(' ');
|
|
132
131
|
targetOptions.args = [`--findRelatedTests ${parsedSourceFiles}`];
|
|
133
132
|
delete targetOptions.findRelatedTests;
|
|
@@ -151,11 +150,11 @@ async function updateOptions(tree, targetOptions, projectRoot, workspaceRoot, je
|
|
|
151
150
|
}
|
|
152
151
|
if ('outputFile' in targetOptions) {
|
|
153
152
|
// update the output file to be relative to the project root
|
|
154
|
-
targetOptions.outputFile = (0,
|
|
153
|
+
targetOptions.outputFile = (0, internal_1.toProjectRelativePath)(targetOptions.outputFile, projectRoot);
|
|
155
154
|
}
|
|
156
155
|
if ('coverageDirectory' in targetOptions) {
|
|
157
156
|
// update the coverage directory to be relative to the project root
|
|
158
|
-
targetOptions.coverageDirectory = (0,
|
|
157
|
+
targetOptions.coverageDirectory = (0, internal_1.toProjectRelativePath)(targetOptions.coverageDirectory, projectRoot);
|
|
159
158
|
}
|
|
160
159
|
}
|
|
161
160
|
async function processSetupFiles(setupFile, setupFilesAfterEnv, projectRoot, workspaceRoot, jestConfigPath) {
|
|
@@ -167,11 +166,11 @@ async function processSetupFiles(setupFile, setupFilesAfterEnv, projectRoot, wor
|
|
|
167
166
|
if (jestConfigPath) {
|
|
168
167
|
const jestConfig = await (0, jest_config_1.readConfig)({ setupFilesAfterEnv }, (0, node_path_1.join)(workspaceRoot, jestConfigPath));
|
|
169
168
|
if (jestConfig.projectConfig.setupFilesAfterEnv) {
|
|
170
|
-
configSetupFilesAfterEnv.push(...jestConfig.projectConfig.setupFilesAfterEnv.map((file) => (0,
|
|
169
|
+
configSetupFilesAfterEnv.push(...jestConfig.projectConfig.setupFilesAfterEnv.map((file) => (0, internal_1.toProjectRelativePath)(file, projectRoot)));
|
|
171
170
|
}
|
|
172
171
|
}
|
|
173
172
|
if (!configSetupFilesAfterEnv.length) {
|
|
174
|
-
return [(0,
|
|
173
|
+
return [(0, internal_1.toProjectRelativePath)(setupFile, projectRoot)];
|
|
175
174
|
}
|
|
176
175
|
if (isSetupFileInConfig(configSetupFilesAfterEnv, setupFile, projectRoot, workspaceRoot)) {
|
|
177
176
|
// the setupFile is already included in the setupFilesAfterEnv
|
|
@@ -179,7 +178,7 @@ async function processSetupFiles(setupFile, setupFilesAfterEnv, projectRoot, wor
|
|
|
179
178
|
}
|
|
180
179
|
return [
|
|
181
180
|
...configSetupFilesAfterEnv,
|
|
182
|
-
(0,
|
|
181
|
+
(0, internal_1.toProjectRelativePath)(setupFile, projectRoot),
|
|
183
182
|
];
|
|
184
183
|
}
|
|
185
184
|
function isSetupFileInConfig(setupFilesAfterEnv, setupFile, projectRoot, workspaceRoot) {
|
|
@@ -187,7 +186,7 @@ function isSetupFileInConfig(setupFilesAfterEnv, setupFile, projectRoot, workspa
|
|
|
187
186
|
? node_path_1.posix.join(workspaceRoot, projectRoot, f.slice('<rootDir>'.length))
|
|
188
187
|
: node_path_1.posix.join(workspaceRoot, projectRoot, f);
|
|
189
188
|
const normalizedSetupFiles = new Set(setupFilesAfterEnv.map(normalizePath));
|
|
190
|
-
return normalizedSetupFiles.has(normalizePath((0,
|
|
189
|
+
return normalizedSetupFiles.has(normalizePath((0, internal_1.toProjectRelativePath)(setupFile, projectRoot)));
|
|
191
190
|
}
|
|
192
191
|
function toProjectRelativeRegexPath(path, projectRoot) {
|
|
193
192
|
if (projectRoot === '.') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../../../../packages/jest/src/generators/init/init.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../../../../packages/jest/src/generators/init/init.ts"],"names":[],"mappings":"AACA,OAAO,EAQL,KAAK,iBAAiB,EACtB,KAAK,IAAI,EACV,MAAM,YAAY,CAAC;AAWpB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAuE/C,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,cAAc,8BAEpE;AAED,wBAAsB,yBAAyB,CAC7C,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,iBAAiB,CAAC,CA2C5B;AAED,eAAe,iBAAiB,CAAC"}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.jestInitGenerator = jestInitGenerator;
|
|
4
4
|
exports.jestInitGeneratorInternal = jestInitGeneratorInternal;
|
|
5
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
5
6
|
const devkit_1 = require("@nx/devkit");
|
|
6
|
-
const add_plugin_1 = require("@nx/devkit/src/utils/add-plugin");
|
|
7
7
|
const plugin_1 = require("../../plugins/plugin");
|
|
8
8
|
const config_file_1 = require("../../utils/config/config-file");
|
|
9
9
|
const versions_1 = require("../../utils/versions");
|
|
@@ -73,7 +73,7 @@ async function jestInitGeneratorInternal(tree, options) {
|
|
|
73
73
|
if (!tree.exists(`jest.preset.${presetExt}`)) {
|
|
74
74
|
updateProductionFileSet(tree);
|
|
75
75
|
if (options.addPlugin) {
|
|
76
|
-
await (0,
|
|
76
|
+
await (0, internal_1.addPlugin)(tree, await (0, devkit_1.createProjectGraphAsync)(), '@nx/jest/plugin', plugin_1.createNodesV2, {
|
|
77
77
|
targetName: ['test', 'jest:test', 'jest-test'],
|
|
78
78
|
}, options.updatePackageScripts);
|
|
79
79
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remove-tsconfig-option-from-jest-executor.d.ts","sourceRoot":"","sources":["../../../../../../packages/jest/src/migrations/update-21-0-0/remove-tsconfig-option-from-jest-executor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"remove-tsconfig-option-from-jest-executor.d.ts","sourceRoot":"","sources":["../../../../../../packages/jest/src/migrations/update-21-0-0/remove-tsconfig-option-from-jest-executor.ts"],"names":[],"mappings":"AACA,OAAO,EAKL,KAAK,IAAI,EAGV,MAAM,YAAY,CAAC;AAIpB,yBAA+B,IAAI,EAAE,IAAI,iBA8DxC"}
|
|
@@ -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
|
const EXECUTOR_TO_MIGRATE = '@nx/jest:jest';
|
|
7
7
|
async function default_1(tree) {
|
|
8
8
|
// update options from project configs
|
|
9
|
-
(0,
|
|
9
|
+
(0, internal_1.forEachExecutorOptions)(tree, EXECUTOR_TO_MIGRATE, (options, project, target, configuration) => {
|
|
10
10
|
if (options.tsConfig === undefined) {
|
|
11
11
|
return;
|
|
12
12
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rename-test-path-pattern.d.ts","sourceRoot":"","sources":["../../../../../../packages/jest/src/migrations/update-21-3-0/rename-test-path-pattern.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rename-test-path-pattern.d.ts","sourceRoot":"","sources":["../../../../../../packages/jest/src/migrations/update-21-3-0/rename-test-path-pattern.ts"],"names":[],"mappings":"AACA,OAAO,EAML,KAAK,IAAI,EACV,MAAM,YAAY,CAAC;AAIpB,yBAA+B,IAAI,EAAE,IAAI,iBA6CxC"}
|
|
@@ -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]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-snapshot-guide-link.d.ts","sourceRoot":"","sources":["../../../../../../packages/jest/src/migrations/update-23-0-0/update-snapshot-guide-link.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC;AAM/D,wBAA8B,uBAAuB,CAAC,IAAI,EAAE,IAAI,iBA2B/D"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = updateSnapshotGuideLink;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const OLD_HEADER = '// Jest Snapshot v1, https://goo.gl/fbAQLP';
|
|
6
|
+
const NEW_HEADER = '// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing';
|
|
7
|
+
async function updateSnapshotGuideLink(tree) {
|
|
8
|
+
const snapshotFiles = await (0, devkit_1.globAsync)(tree, ['**/__snapshots__/*.snap']);
|
|
9
|
+
for (const snapshotFile of snapshotFiles) {
|
|
10
|
+
const content = tree.read(snapshotFile, 'utf-8');
|
|
11
|
+
if (!content) {
|
|
12
|
+
continue;
|
|
13
|
+
}
|
|
14
|
+
const newlineMatch = content.match(/\r?\n/);
|
|
15
|
+
if (!newlineMatch) {
|
|
16
|
+
continue;
|
|
17
|
+
}
|
|
18
|
+
const newline = newlineMatch[0];
|
|
19
|
+
const firstNewlineIndex = content.indexOf(newline);
|
|
20
|
+
const firstLine = content.slice(0, firstNewlineIndex);
|
|
21
|
+
if (firstLine !== OLD_HEADER) {
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
const updated = NEW_HEADER + content.slice(firstNewlineIndex);
|
|
25
|
+
tree.write(snapshotFile, updated);
|
|
26
|
+
}
|
|
27
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
28
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../../packages/jest/src/plugins/plugin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../../packages/jest/src/plugins/plugin.ts"],"names":[],"mappings":"AAOA,OAAO,EAGL,aAAa,EAQd,MAAM,YAAY,CAAC;AA2BpB,MAAM,WAAW,iBAAiB;IAChC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B;;;;;;;;OAQG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAWD,eAAO,MAAM,WAAW,EAAE,aAAa,CAAC,iBAAiB,CAmJxD,CAAC;AAEF,eAAO,MAAM,aAAa,kCAAc,CAAC"}
|
package/src/plugins/plugin.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createNodesV2 = exports.createNodes = void 0;
|
|
4
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
4
5
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const calculate_hash_for_create_nodes_1 = require("@nx/devkit/src/utils/calculate-hash-for-create-nodes");
|
|
6
|
-
const config_utils_1 = require("@nx/devkit/src/utils/config-utils");
|
|
7
|
-
const get_named_inputs_1 = require("@nx/devkit/src/utils/get-named-inputs");
|
|
8
6
|
const minimatch_1 = require("minimatch");
|
|
9
7
|
const node_fs_1 = require("node:fs");
|
|
10
8
|
const node_path_1 = require("node:path");
|
|
@@ -16,24 +14,16 @@ const installation_directory_1 = require("nx/src/utils/installation-directory");
|
|
|
16
14
|
const plugins_1 = require("nx/src/utils/plugins");
|
|
17
15
|
const workspace_context_1 = require("nx/src/utils/workspace-context");
|
|
18
16
|
const js_1 = require("@nx/js");
|
|
19
|
-
const
|
|
17
|
+
const internal_2 = require("@nx/js/src/internal");
|
|
20
18
|
const versions_1 = require("../utils/versions");
|
|
21
19
|
const REPORTER_BUILTINS = new Set(['default', 'github-actions', 'summary']);
|
|
22
|
-
function readTargetsCache(cachePath) {
|
|
23
|
-
return process.env.NX_CACHE_PROJECT_GRAPH !== 'false' && (0, node_fs_1.existsSync)(cachePath)
|
|
24
|
-
? (0, devkit_1.readJsonFile)(cachePath)
|
|
25
|
-
: {};
|
|
26
|
-
}
|
|
27
|
-
function writeTargetsToCache(cachePath, results) {
|
|
28
|
-
(0, devkit_1.writeJsonFile)(cachePath, results);
|
|
29
|
-
}
|
|
30
20
|
const jestConfigGlob = '**/jest.config.{cjs,mjs,js,cts,mts,ts}';
|
|
31
21
|
exports.createNodes = [
|
|
32
22
|
jestConfigGlob,
|
|
33
23
|
async (configFiles, options, context) => {
|
|
34
24
|
const optionsHash = (0, devkit_internals_1.hashObject)(options);
|
|
35
25
|
const cachePath = (0, node_path_1.join)(cache_directory_1.workspaceDataDirectory, `jest-${optionsHash}.hash`);
|
|
36
|
-
const targetsCache =
|
|
26
|
+
const targetsCache = new internal_1.PluginCache(cachePath);
|
|
37
27
|
// Cache jest preset(s) to avoid penalties of module load times. Most of jest configs will use the same preset.
|
|
38
28
|
const presetCache = {};
|
|
39
29
|
// Cache tsconfig reads + isolatedModules resolution. Many projects share
|
|
@@ -70,10 +60,10 @@ exports.createNodes = [
|
|
|
70
60
|
const projectRoot = projectRoots[i];
|
|
71
61
|
const absConfigFilePath = (0, node_path_1.resolve)(context.workspaceRoot, configFilePath);
|
|
72
62
|
if (!requireCacheCleared && require.cache[absConfigFilePath]) {
|
|
73
|
-
(0,
|
|
63
|
+
(0, internal_1.clearRequireCache)();
|
|
74
64
|
requireCacheCleared = true;
|
|
75
65
|
}
|
|
76
|
-
const rawConfig = await (0,
|
|
66
|
+
const rawConfig = await (0, internal_1.loadConfigFile)(absConfigFilePath, [
|
|
77
67
|
'tsconfig.spec.json',
|
|
78
68
|
'tsconfig.test.json',
|
|
79
69
|
'tsconfig.jest.json',
|
|
@@ -87,7 +77,7 @@ exports.createNodes = [
|
|
|
87
77
|
});
|
|
88
78
|
return { rawConfig, externalFiles, needsDtsInputs };
|
|
89
79
|
}));
|
|
90
|
-
const hashes = await (0,
|
|
80
|
+
const hashes = await (0, internal_1.calculateHashesForCreateNodes)(projectRoots, options, context, loadedConfigs.map(({ externalFiles }) => [
|
|
91
81
|
lockFilePattern,
|
|
92
82
|
...externalFiles,
|
|
93
83
|
]));
|
|
@@ -96,8 +86,10 @@ exports.createNodes = [
|
|
|
96
86
|
const projectRoot = projectRoots[idx];
|
|
97
87
|
const hash = hashes[idx];
|
|
98
88
|
const { rawConfig, needsDtsInputs } = loadedConfigs[idx];
|
|
99
|
-
targetsCache
|
|
100
|
-
|
|
89
|
+
if (!targetsCache.has(hash)) {
|
|
90
|
+
targetsCache.set(hash, await buildJestTargets(rawConfig, needsDtsInputs, configFilePath, projectRoot, options, context, presetCache, pmc));
|
|
91
|
+
}
|
|
92
|
+
const { targets, metadata } = targetsCache.get(hash);
|
|
101
93
|
return {
|
|
102
94
|
projects: {
|
|
103
95
|
[projectRoot]: {
|
|
@@ -110,7 +102,7 @@ exports.createNodes = [
|
|
|
110
102
|
}, validConfigFiles, options, context);
|
|
111
103
|
}
|
|
112
104
|
finally {
|
|
113
|
-
|
|
105
|
+
targetsCache.writeToDisk();
|
|
114
106
|
}
|
|
115
107
|
},
|
|
116
108
|
];
|
|
@@ -149,7 +141,7 @@ function checkIfConfigFileShouldBeProject(configFilePath, projectRoot, isInPacka
|
|
|
149
141
|
async function buildJestTargets(rawConfig, needsDtsInputs, configFilePath, projectRoot, options, context, presetCache, pmc) {
|
|
150
142
|
const absConfigFilePath = (0, node_path_1.resolve)(context.workspaceRoot, configFilePath);
|
|
151
143
|
const targets = {};
|
|
152
|
-
const namedInputs = (0,
|
|
144
|
+
const namedInputs = (0, internal_1.getNamedInputs)(projectRoot, context);
|
|
153
145
|
const tsNodeCompilerOptions = JSON.stringify({
|
|
154
146
|
moduleResolution: 'node10',
|
|
155
147
|
module: 'commonjs',
|
|
@@ -721,7 +713,7 @@ async function loadPresetConfig(rawConfig, rootDir, presetCache) {
|
|
|
721
713
|
}
|
|
722
714
|
try {
|
|
723
715
|
if (!presetCache[presetPath]) {
|
|
724
|
-
presetCache[presetPath] = (0,
|
|
716
|
+
presetCache[presetPath] = (0, internal_1.loadConfigFile)(presetPath);
|
|
725
717
|
}
|
|
726
718
|
return (await presetCache[presetPath]);
|
|
727
719
|
}
|
|
@@ -885,7 +877,7 @@ function resolveIsolatedModules(tsconfigPath, jsonCache, resultCache) {
|
|
|
885
877
|
return cached;
|
|
886
878
|
let value;
|
|
887
879
|
const visitedFiles = new Set();
|
|
888
|
-
(0,
|
|
880
|
+
(0, internal_2.walkTsconfigExtendsChain)(tsconfigPath, (absPath, rawJson) => {
|
|
889
881
|
visitedFiles.add(absPath);
|
|
890
882
|
const opts = rawJson?.compilerOptions;
|
|
891
883
|
if (opts?.isolatedModules !== undefined) {
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const JEST_EXECUTOR_DEPRECATION_MESSAGE = "The `@nx/jest:jest` executor is deprecated and will be removed in Nx v24. Run `nx g @nx/jest:convert-to-inferred` to migrate to the `@nx/jest/plugin` inferred targets. See https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.";
|
|
2
|
+
export declare function warnJestExecutorDeprecation(): void;
|
|
3
|
+
export declare function warnJestExecutorGenerating(): void;
|
|
4
|
+
//# sourceMappingURL=deprecation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deprecation.d.ts","sourceRoot":"","sources":["../../../../../packages/jest/src/utils/deprecation.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,iCAAiC,2PAC4M,CAAC;AAE3P,wBAAgB,2BAA2B,IAAI,IAAI,CAElD;AAED,wBAAgB,0BAA0B,IAAI,IAAI,CAIjD"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.JEST_EXECUTOR_DEPRECATION_MESSAGE = void 0;
|
|
4
|
+
exports.warnJestExecutorDeprecation = warnJestExecutorDeprecation;
|
|
5
|
+
exports.warnJestExecutorGenerating = warnJestExecutorGenerating;
|
|
6
|
+
const devkit_1 = require("@nx/devkit");
|
|
7
|
+
// TODO(v24): Remove the @nx/jest:jest executor. The inferred plugin
|
|
8
|
+
// (@nx/jest/plugin) and the convert-to-inferred generator stay supported.
|
|
9
|
+
exports.JEST_EXECUTOR_DEPRECATION_MESSAGE = 'The `@nx/jest:jest` executor is deprecated and will be removed in Nx v24. Run `nx g @nx/jest:convert-to-inferred` to migrate to the `@nx/jest/plugin` inferred targets. See https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.';
|
|
10
|
+
function warnJestExecutorDeprecation() {
|
|
11
|
+
devkit_1.logger.warn(exports.JEST_EXECUTOR_DEPRECATION_MESSAGE);
|
|
12
|
+
}
|
|
13
|
+
function warnJestExecutorGenerating() {
|
|
14
|
+
devkit_1.logger.warn('Generating a target that uses the deprecated `@nx/jest:jest` executor. The executor will be removed in Nx v24. Run `nx g @nx/jest:convert-to-inferred` next to migrate this target to the `@nx/jest/plugin` inferred plugin and prevent future generators from emitting executor targets. See https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.');
|
|
15
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"versions.d.ts","sourceRoot":"","sources":["../../../../../packages/jest/src/utils/versions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuC,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"versions.d.ts","sourceRoot":"","sources":["../../../../../packages/jest/src/utils/versions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuC,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC;AAU5E,eAAO,MAAM,cAAc;;;;;;;;;;CAU1B,CAAC;AAEF,QAAA,MAAM,sBAAsB,mBAAoB,CAAC;AAIjD,KAAK,iBAAiB,GAAG,CAAC,OAAO,sBAAsB,CAAC,CAAC,MAAM,CAAC,CAAC;AACjE,KAAK,mBAAmB,GAAG,MAAM,OAAO,cAAc,CAAC;AACvD,MAAM,MAAM,UAAU,GAAG;KACtB,GAAG,IAAI,iBAAiB,GAAG,MAAM,CAAC,mBAAmB,EAAE,MAAM,CAAC;CAChE,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,UAaxB,CAAC;AAEF,wBAAgB,QAAQ,CAAC,IAAI,EAAE,IAAI,OAiBlC;AAED,wBAAgB,uBAAuB,CAAC,IAAI,CAAC,EAAE,IAAI,GAAG,MAAM,GAAG,IAAI,CAclE;AAED,wBAAgB,2BAA2B,CAAC,IAAI,CAAC,EAAE,IAAI,GAAG;IACxD,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB,CAMA;AAED,wBAAgB,4BAA4B,CAAC,IAAI,CAAC,EAAE,IAAI,GAAG,MAAM,GAAG,IAAI,CAIvE;AAED,wBAAgB,4BAA4B,CAAC,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAc9D"}
|
package/src/utils/versions.js
CHANGED
|
@@ -9,15 +9,20 @@ exports.validateInstalledJestVersion = validateInstalledJestVersion;
|
|
|
9
9
|
const devkit_1 = require("@nx/devkit");
|
|
10
10
|
const semver_1 = require("semver");
|
|
11
11
|
const nxVersion = require('../../package.json').version;
|
|
12
|
+
// Jest is pinned to 30.3.x because jest-runtime@30.4.0 added a call to
|
|
13
|
+
// `_moduleMocker.clearMocksOnScope()`, which doesn't exist on the
|
|
14
|
+
// jest-mock@29 ModuleMocker that React Native's preset still feeds in
|
|
15
|
+
// (via `@react-native/jest-preset`'s pinned `jest-environment-node@^29.7.0`).
|
|
16
|
+
// Lift this once Meta ships a Jest-30-aware preset on react-native.
|
|
12
17
|
exports.latestVersions = {
|
|
13
18
|
nxVersion,
|
|
14
|
-
jestVersion: '
|
|
15
|
-
babelJestVersion: '
|
|
16
|
-
jestTypesVersion: '
|
|
19
|
+
jestVersion: '~30.3.0',
|
|
20
|
+
babelJestVersion: '~30.3.0',
|
|
21
|
+
jestTypesVersion: '~30.0.0',
|
|
17
22
|
tsJestVersion: '^29.4.0',
|
|
18
23
|
tslibVersion: '^2.3.0',
|
|
19
24
|
swcJestVersion: '~0.2.38',
|
|
20
|
-
typesNodeVersion: '
|
|
25
|
+
typesNodeVersion: '^22.0.0',
|
|
21
26
|
tsNodeVersion: '10.9.1',
|
|
22
27
|
};
|
|
23
28
|
const supportedMajorVersions = [29, 30];
|