@nx/jest 21.6.1-beta.0 → 21.6.1-beta.2
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 +3 -3
- package/package.json +4 -4
- package/plugins/resolver.js +2 -1
- package/preset/jest-preset.d.ts +1 -1
- package/preset/jest-preset.d.ts.map +1 -1
- package/preset/jest-preset.js +14 -3
- package/src/generators/configuration/lib/ensure-dependencies.d.ts.map +1 -1
- package/src/generators/configuration/lib/ensure-dependencies.js +11 -10
- package/src/generators/convert-to-inferred/convert-to-inferred.d.ts.map +1 -1
- package/src/generators/convert-to-inferred/convert-to-inferred.js +9 -9
- package/src/generators/init/init.d.ts.map +1 -1
- package/src/generators/init/init.js +7 -2
- package/src/plugins/plugin.d.ts.map +1 -1
- package/src/plugins/plugin.js +6 -1
- package/src/utils/versions.d.ts +28 -9
- package/src/utils/versions.d.ts.map +1 -1
- package/src/utils/versions.js +104 -10
package/migrations.json
CHANGED
|
@@ -19,9 +19,6 @@
|
|
|
19
19
|
},
|
|
20
20
|
"rename-test-path-pattern": {
|
|
21
21
|
"version": "21.3.0-beta.3",
|
|
22
|
-
"requires": {
|
|
23
|
-
"jest": ">=30.0.0"
|
|
24
|
-
},
|
|
25
22
|
"description": "Rename the CLI option `testPathPattern` to `testPathPatterns`.",
|
|
26
23
|
"implementation": "./src/migrations/update-21-3-0/rename-test-path-pattern"
|
|
27
24
|
},
|
|
@@ -80,6 +77,9 @@
|
|
|
80
77
|
"21.3.0": {
|
|
81
78
|
"version": "21.3.0-beta.3",
|
|
82
79
|
"x-prompt": "Do you want to update the Jest version to v30?",
|
|
80
|
+
"incompatibleWith": {
|
|
81
|
+
"@angular-devkit/build-angular": "*"
|
|
82
|
+
},
|
|
83
83
|
"packages": {
|
|
84
84
|
"jest": {
|
|
85
85
|
"version": "~30.0.0",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/jest",
|
|
3
|
-
"version": "21.6.1-beta.
|
|
3
|
+
"version": "21.6.1-beta.2",
|
|
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": {
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@jest/reporters": "^30.0.2",
|
|
39
39
|
"@jest/test-result": "^30.0.2",
|
|
40
|
-
"@nx/devkit": "21.6.1-beta.
|
|
41
|
-
"@nx/js": "21.6.1-beta.
|
|
40
|
+
"@nx/devkit": "21.6.1-beta.2",
|
|
41
|
+
"@nx/js": "21.6.1-beta.2",
|
|
42
42
|
"@phenomnomnominal/tsquery": "~5.0.1",
|
|
43
43
|
"identity-obj-proxy": "3.0.0",
|
|
44
44
|
"jest-config": "^30.0.2",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"yargs-parser": "21.1.1"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"nx": "21.6.1-beta.
|
|
55
|
+
"nx": "21.6.1-beta.2"
|
|
56
56
|
},
|
|
57
57
|
"publishConfig": {
|
|
58
58
|
"access": "public"
|
package/plugins/resolver.js
CHANGED
|
@@ -3,9 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const path_1 = require("path");
|
|
4
4
|
const resolve_exports_1 = require("resolve.exports");
|
|
5
5
|
const jest_1 = require("jest");
|
|
6
|
+
const semver_1 = require("semver");
|
|
6
7
|
let compilerSetup;
|
|
7
8
|
let ts;
|
|
8
|
-
const jestMajorVersion =
|
|
9
|
+
const jestMajorVersion = (0, semver_1.major)((0, jest_1.getVersion)());
|
|
9
10
|
function getCompilerSetup(rootDir) {
|
|
10
11
|
const tsConfigPath = ts.findConfigFile(rootDir, ts.sys.fileExists, 'tsconfig.spec.json') ||
|
|
11
12
|
ts.findConfigFile(rootDir, ts.sys.fileExists, 'tsconfig.test.json') ||
|
package/preset/jest-preset.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jest-preset.d.ts","sourceRoot":"","sources":["../../../../packages/jest/preset/jest-preset.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
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,MAsCtB,CAAC"}
|
package/preset/jest-preset.js
CHANGED
|
@@ -1,14 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.nxPreset = void 0;
|
|
4
|
+
const jest_1 = require("jest");
|
|
5
|
+
const semver_1 = require("semver");
|
|
6
|
+
const jestMajorVersion = (0, semver_1.major)((0, jest_1.getVersion)());
|
|
4
7
|
exports.nxPreset = {
|
|
5
8
|
// This is one of the patterns that jest finds by default https://jestjs.io/docs/configuration#testmatch-arraystring
|
|
6
|
-
testMatch: [
|
|
9
|
+
testMatch: [
|
|
10
|
+
jestMajorVersion >= 30
|
|
11
|
+
? '**/?(*.)+(spec|test).?([mc])[jt]s?(x)'
|
|
12
|
+
: '**/?(*.)+(spec|test).[jt]s?(x)',
|
|
13
|
+
],
|
|
7
14
|
resolver: '@nx/jest/plugins/resolver',
|
|
8
|
-
moduleFileExtensions:
|
|
15
|
+
moduleFileExtensions: jestMajorVersion >= 30
|
|
16
|
+
? ['ts', 'js', 'mts', 'mjs', 'cts', 'cjs', 'html']
|
|
17
|
+
: ['ts', 'js', 'mjs', 'html'],
|
|
9
18
|
coverageReporters: ['html'],
|
|
10
19
|
transform: {
|
|
11
|
-
|
|
20
|
+
[jestMajorVersion >= 30
|
|
21
|
+
? '^.+\\.(ts|js|mts|mjs|cts|cjs|html)$'
|
|
22
|
+
: '^.+\\.(ts|js|html)$']: [
|
|
12
23
|
'ts-jest',
|
|
13
24
|
{ tsconfig: '<rootDir>/tsconfig.spec.json' },
|
|
14
25
|
],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ensure-dependencies.d.ts","sourceRoot":"","sources":["../../../../../../../packages/jest/src/generators/configuration/lib/ensure-dependencies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgC,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"ensure-dependencies.d.ts","sourceRoot":"","sources":["../../../../../../../packages/jest/src/generators/configuration/lib/ensure-dependencies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgC,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC;AAErE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,WAAW,CAAC;AAE7D,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,OAAO,CAAC,2BAA2B,CAAC,0CAmD9C"}
|
|
@@ -4,32 +4,33 @@ exports.ensureDependencies = ensureDependencies;
|
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const versions_1 = require("../../../utils/versions");
|
|
6
6
|
function ensureDependencies(tree, options) {
|
|
7
|
+
const { babelJestVersion, jestTypesVersion, jestVersion, nxVersion, swcJestVersion, tsJestVersion, tslibVersion, tsNodeVersion, typesNodeVersion, } = (0, versions_1.versions)(tree);
|
|
7
8
|
const dependencies = {
|
|
8
|
-
tslib:
|
|
9
|
+
tslib: tslibVersion,
|
|
9
10
|
};
|
|
10
11
|
const devDeps = {
|
|
11
12
|
// because the default jest-preset uses ts-jest,
|
|
12
13
|
// jest will throw an error if it's not installed
|
|
13
14
|
// even if not using it in overriding transformers
|
|
14
|
-
'ts-jest':
|
|
15
|
+
'ts-jest': tsJestVersion,
|
|
15
16
|
// peer dependency of ts-jest
|
|
16
|
-
'jest-util':
|
|
17
|
+
'jest-util': jestVersion,
|
|
17
18
|
};
|
|
18
19
|
if (options.testEnvironment !== 'none') {
|
|
19
|
-
devDeps[`jest-environment-${options.testEnvironment}`] =
|
|
20
|
+
devDeps[`jest-environment-${options.testEnvironment}`] = jestVersion;
|
|
20
21
|
}
|
|
21
22
|
if (!options.js) {
|
|
22
|
-
devDeps['ts-node'] =
|
|
23
|
-
devDeps['@types/jest'] =
|
|
24
|
-
devDeps['@types/node'] =
|
|
23
|
+
devDeps['ts-node'] = tsNodeVersion;
|
|
24
|
+
devDeps['@types/jest'] = jestTypesVersion;
|
|
25
|
+
devDeps['@types/node'] = typesNodeVersion;
|
|
25
26
|
}
|
|
26
27
|
if (options.compiler === 'babel' || options.babelJest) {
|
|
27
|
-
devDeps['babel-jest'] =
|
|
28
|
+
devDeps['babel-jest'] = babelJestVersion;
|
|
28
29
|
// in some cases @nx/js will not already be present i.e. node only projects
|
|
29
|
-
devDeps['@nx/js'] =
|
|
30
|
+
devDeps['@nx/js'] = nxVersion;
|
|
30
31
|
}
|
|
31
32
|
else if (options.compiler === 'swc') {
|
|
32
|
-
devDeps['@swc/jest'] =
|
|
33
|
+
devDeps['@swc/jest'] = swcJestVersion;
|
|
33
34
|
}
|
|
34
35
|
return (0, devkit_1.addDependenciesToPackageJson)(tree, dependencies, devDeps, undefined, options.keepExistingVersions);
|
|
35
36
|
}
|
|
@@ -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":"AACA,OAAO,EAIL,KAAK,IAAI,EACV,MAAM,YAAY,CAAC;AAepB,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;
|
|
1
|
+
{"version":3,"file":"convert-to-inferred.d.ts","sourceRoot":"","sources":["../../../../../../packages/jest/src/generators/convert-to-inferred/convert-to-inferred.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,IAAI,EACV,MAAM,YAAY,CAAC;AAepB,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"}
|
|
@@ -8,7 +8,7 @@ const jest_config_1 = require("jest-config");
|
|
|
8
8
|
const node_path_1 = require("node:path");
|
|
9
9
|
const plugin_1 = require("../../plugins/plugin");
|
|
10
10
|
const config_file_1 = require("../../utils/config/config-file");
|
|
11
|
-
const
|
|
11
|
+
const versions_1 = require("../../utils/versions");
|
|
12
12
|
async function convertToInferred(tree, options) {
|
|
13
13
|
const projectGraph = await (0, devkit_1.createProjectGraphAsync)();
|
|
14
14
|
const migratedProjects = await (0, executor_to_plugin_migrator_1.migrateProjectExecutorsToPlugin)(tree, projectGraph, '@nx/jest/plugin', plugin_1.createNodesV2, { targetName: 'test' }, [
|
|
@@ -30,11 +30,11 @@ async function postTargetTransformer(target, tree, projectDetails, inferredTarge
|
|
|
30
30
|
.map((ext) => `jest.config.${ext}`)
|
|
31
31
|
.find((configFileName) => tree.exists(node_path_1.posix.join(projectDetails.root, configFileName)));
|
|
32
32
|
if (target.options) {
|
|
33
|
-
await updateOptionsObject(target.options, projectDetails.root, tree.root, jestConfigPath);
|
|
33
|
+
await updateOptionsObject(tree, target.options, projectDetails.root, tree.root, jestConfigPath);
|
|
34
34
|
}
|
|
35
35
|
if (target.configurations) {
|
|
36
36
|
for (const [configName, config] of Object.entries(target.configurations)) {
|
|
37
|
-
await updateConfigurationObject(config, projectDetails.root, tree.root, jestConfigPath);
|
|
37
|
+
await updateConfigurationObject(tree, config, projectDetails.root, tree.root, jestConfigPath);
|
|
38
38
|
if (!Object.keys(config).length) {
|
|
39
39
|
delete target.configurations[configName];
|
|
40
40
|
}
|
|
@@ -57,15 +57,15 @@ async function postTargetTransformer(target, tree, projectDetails, inferredTarge
|
|
|
57
57
|
return target;
|
|
58
58
|
}
|
|
59
59
|
exports.default = convertToInferred;
|
|
60
|
-
async function updateOptionsObject(targetOptions, projectRoot, workspaceRoot, defaultJestConfigPath) {
|
|
60
|
+
async function updateOptionsObject(tree, targetOptions, projectRoot, workspaceRoot, defaultJestConfigPath) {
|
|
61
61
|
const jestConfigPath = targetOptions.jestConfig ?? defaultJestConfigPath;
|
|
62
62
|
// inferred targets are only identified after known files that Jest would
|
|
63
63
|
// pick up, so we can safely remove the config options
|
|
64
64
|
delete targetOptions.jestConfig;
|
|
65
65
|
delete targetOptions.config;
|
|
66
|
-
await updateOptions(targetOptions, projectRoot, workspaceRoot, jestConfigPath);
|
|
66
|
+
await updateOptions(tree, targetOptions, projectRoot, workspaceRoot, jestConfigPath);
|
|
67
67
|
}
|
|
68
|
-
async function updateConfigurationObject(targetOptions, projectRoot, workspaceRoot, defaultJestConfigPath) {
|
|
68
|
+
async function updateConfigurationObject(tree, targetOptions, projectRoot, workspaceRoot, defaultJestConfigPath) {
|
|
69
69
|
const jestConfigPath = targetOptions.jestConfig ?? defaultJestConfigPath;
|
|
70
70
|
if (targetOptions.jestConfig) {
|
|
71
71
|
targetOptions.config = (0, plugin_migration_utils_1.toProjectRelativePath)(targetOptions.jestConfig, projectRoot);
|
|
@@ -74,9 +74,9 @@ async function updateConfigurationObject(targetOptions, projectRoot, workspaceRo
|
|
|
74
74
|
else if (targetOptions.config) {
|
|
75
75
|
targetOptions.config = (0, plugin_migration_utils_1.toProjectRelativePath)(targetOptions.config, projectRoot);
|
|
76
76
|
}
|
|
77
|
-
await updateOptions(targetOptions, projectRoot, workspaceRoot, jestConfigPath);
|
|
77
|
+
await updateOptions(tree, targetOptions, projectRoot, workspaceRoot, jestConfigPath);
|
|
78
78
|
}
|
|
79
|
-
async function updateOptions(targetOptions, projectRoot, workspaceRoot, jestConfigPath) {
|
|
79
|
+
async function updateOptions(tree, targetOptions, projectRoot, workspaceRoot, jestConfigPath) {
|
|
80
80
|
// deprecated and unused
|
|
81
81
|
delete targetOptions.tsConfig;
|
|
82
82
|
if ('codeCoverage' in targetOptions) {
|
|
@@ -98,7 +98,7 @@ async function updateOptions(targetOptions, projectRoot, workspaceRoot, jestConf
|
|
|
98
98
|
testPathPatterns.push(...targetOptions.testPathPatterns.map((pattern) => toProjectRelativeRegexPath(pattern, projectRoot)));
|
|
99
99
|
}
|
|
100
100
|
else {
|
|
101
|
-
const jestMajorVersion = (0,
|
|
101
|
+
const jestMajorVersion = (0, versions_1.getInstalledJestMajorVersion)(tree);
|
|
102
102
|
testPathPatternsOptionName =
|
|
103
103
|
jestMajorVersion >= 30 ? 'testPathPatterns' : 'testPathPattern';
|
|
104
104
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../../../../packages/jest/src/generators/init/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAQL,KAAK,iBAAiB,EACtB,KAAK,IAAI,EACV,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../../../../packages/jest/src/generators/init/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAQL,KAAK,iBAAiB,EACtB,KAAK,IAAI,EACV,MAAM,YAAY,CAAC;AAYpB,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"}
|
|
@@ -51,15 +51,20 @@ function addJestTargetDefaults(tree, presetExt) {
|
|
|
51
51
|
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
52
52
|
}
|
|
53
53
|
function updateDependencies(tree, options) {
|
|
54
|
+
const { jestVersion, nxVersion } = (0, versions_1.versions)(tree);
|
|
54
55
|
return (0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
|
|
55
|
-
'@nx/jest':
|
|
56
|
-
jest:
|
|
56
|
+
'@nx/jest': nxVersion,
|
|
57
|
+
jest: jestVersion,
|
|
57
58
|
}, undefined, options.keepExistingVersions);
|
|
58
59
|
}
|
|
59
60
|
function jestInitGenerator(tree, options) {
|
|
60
61
|
return jestInitGeneratorInternal(tree, { addPlugin: false, ...options });
|
|
61
62
|
}
|
|
62
63
|
async function jestInitGeneratorInternal(tree, options) {
|
|
64
|
+
const installedJestVersion = (0, versions_1.getInstalledJestVersion)(tree);
|
|
65
|
+
if (installedJestVersion) {
|
|
66
|
+
(0, versions_1.validateInstalledJestVersion)(tree);
|
|
67
|
+
}
|
|
63
68
|
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
64
69
|
const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' &&
|
|
65
70
|
nxJson.useInferencePlugins !== false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../../packages/jest/src/plugins/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EAIX,aAAa,EAUd,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../../packages/jest/src/plugins/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EAIX,aAAa,EAUd,MAAM,YAAY,CAAC;AAsBpB,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;CAC9B;AAmBD,eAAO,MAAM,aAAa,EAAE,aAAa,CAAC,iBAAiB,CAiF1D,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,WAAW,EAAE,WAAW,CAAC,iBAAiB,CA4CtD,CAAC"}
|
package/src/plugins/plugin.js
CHANGED
|
@@ -16,6 +16,7 @@ const workspace_context_1 = require("nx/src/utils/workspace-context");
|
|
|
16
16
|
const node_path_1 = require("node:path");
|
|
17
17
|
const installation_directory_1 = require("nx/src/utils/installation-directory");
|
|
18
18
|
const semver_1 = require("semver");
|
|
19
|
+
const versions_1 = require("../utils/versions");
|
|
19
20
|
const pmc = (0, devkit_1.getPackageManagerCommand)();
|
|
20
21
|
function readTargetsCache(cachePath) {
|
|
21
22
|
return process.env.NX_CACHE_PROJECT_GRAPH !== 'false' && (0, fs_1.existsSync)(cachePath)
|
|
@@ -289,7 +290,11 @@ async function buildJestTargets(configFilePath, projectRoot, options, context, p
|
|
|
289
290
|
});
|
|
290
291
|
const jest = require(resolveJestPath(projectRoot, context.workspaceRoot));
|
|
291
292
|
const source = new jest.SearchSource(jestContext);
|
|
292
|
-
const
|
|
293
|
+
const jestVersion = (0, versions_1.getInstalledJestMajorVersion)();
|
|
294
|
+
const specs = jestVersion >= 30
|
|
295
|
+
? await source.getTestPaths(config.globalConfig, config.projectConfig)
|
|
296
|
+
: // @ts-expect-error Jest v29 doesn't have the projectConfig parameter
|
|
297
|
+
await source.getTestPaths(config.globalConfig);
|
|
293
298
|
const testPaths = new Set(specs.tests.map(({ path }) => path));
|
|
294
299
|
if (testPaths.size > 0) {
|
|
295
300
|
const targetGroup = [];
|
package/src/utils/versions.d.ts
CHANGED
|
@@ -1,10 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { type Tree } from '@nx/devkit';
|
|
2
|
+
export declare const latestVersions: {
|
|
3
|
+
nxVersion: any;
|
|
4
|
+
jestVersion: string;
|
|
5
|
+
babelJestVersion: string;
|
|
6
|
+
jestTypesVersion: string;
|
|
7
|
+
tsJestVersion: string;
|
|
8
|
+
tslibVersion: string;
|
|
9
|
+
swcJestVersion: string;
|
|
10
|
+
typesNodeVersion: string;
|
|
11
|
+
tsNodeVersion: string;
|
|
12
|
+
};
|
|
13
|
+
declare const supportedMajorVersions: readonly [29, 30];
|
|
14
|
+
type SupportedVersions = (typeof supportedMajorVersions)[number];
|
|
15
|
+
type PackageVersionNames = keyof typeof latestVersions;
|
|
16
|
+
export type VersionMap = {
|
|
17
|
+
[key in SupportedVersions]: Record<PackageVersionNames, string>;
|
|
18
|
+
};
|
|
19
|
+
export declare const versionMap: VersionMap;
|
|
20
|
+
export declare function versions(tree: Tree): any;
|
|
21
|
+
export declare function getInstalledJestVersion(tree?: Tree): string | null;
|
|
22
|
+
export declare function getInstalledJestVersionInfo(tree?: Tree): {
|
|
23
|
+
version: string | null;
|
|
24
|
+
major: number | null;
|
|
25
|
+
};
|
|
26
|
+
export declare function getInstalledJestMajorVersion(tree?: Tree): number | null;
|
|
27
|
+
export declare function validateInstalledJestVersion(tree?: Tree): void;
|
|
28
|
+
export {};
|
|
10
29
|
//# sourceMappingURL=versions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"versions.d.ts","sourceRoot":"","sources":["../../../../../packages/jest/src/utils/versions.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"versions.d.ts","sourceRoot":"","sources":["../../../../../packages/jest/src/utils/versions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC;AAKjD,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
|
@@ -1,12 +1,106 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.
|
|
5
|
-
exports.
|
|
6
|
-
exports.
|
|
7
|
-
exports.
|
|
8
|
-
exports.
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
exports.
|
|
3
|
+
exports.versionMap = exports.latestVersions = void 0;
|
|
4
|
+
exports.versions = versions;
|
|
5
|
+
exports.getInstalledJestVersion = getInstalledJestVersion;
|
|
6
|
+
exports.getInstalledJestVersionInfo = getInstalledJestVersionInfo;
|
|
7
|
+
exports.getInstalledJestMajorVersion = getInstalledJestMajorVersion;
|
|
8
|
+
exports.validateInstalledJestVersion = validateInstalledJestVersion;
|
|
9
|
+
const devkit_1 = require("@nx/devkit");
|
|
10
|
+
const semver_1 = require("semver");
|
|
11
|
+
const nxVersion = require('../../package.json').version;
|
|
12
|
+
exports.latestVersions = {
|
|
13
|
+
nxVersion,
|
|
14
|
+
jestVersion: '^30.0.2',
|
|
15
|
+
babelJestVersion: '^30.0.2',
|
|
16
|
+
jestTypesVersion: '^30.0.0',
|
|
17
|
+
tsJestVersion: '^29.4.0',
|
|
18
|
+
tslibVersion: '^2.3.0',
|
|
19
|
+
swcJestVersion: '~0.2.38',
|
|
20
|
+
typesNodeVersion: '20.19.9',
|
|
21
|
+
tsNodeVersion: '10.9.1',
|
|
22
|
+
};
|
|
23
|
+
const supportedMajorVersions = [29, 30];
|
|
24
|
+
const minSupportedMajorVersion = Math.min(...supportedMajorVersions);
|
|
25
|
+
const currentMajorVersion = Math.max(...supportedMajorVersions);
|
|
26
|
+
exports.versionMap = {
|
|
27
|
+
29: {
|
|
28
|
+
nxVersion,
|
|
29
|
+
jestVersion: '^29.7.0',
|
|
30
|
+
babelJestVersion: '^29.7.0',
|
|
31
|
+
jestTypesVersion: '^29.5.12',
|
|
32
|
+
tsJestVersion: '^29.1.0',
|
|
33
|
+
tslibVersion: '^2.3.0',
|
|
34
|
+
swcJestVersion: '~0.2.36',
|
|
35
|
+
typesNodeVersion: '18.16.9',
|
|
36
|
+
tsNodeVersion: '10.9.1',
|
|
37
|
+
},
|
|
38
|
+
30: exports.latestVersions,
|
|
39
|
+
};
|
|
40
|
+
function versions(tree) {
|
|
41
|
+
const installedJestVersion = getInstalledJestVersion(tree);
|
|
42
|
+
if (!installedJestVersion) {
|
|
43
|
+
return exports.latestVersions;
|
|
44
|
+
}
|
|
45
|
+
const jestMajorVersion = (0, semver_1.major)(installedJestVersion);
|
|
46
|
+
if (exports.versionMap[jestMajorVersion]) {
|
|
47
|
+
return exports.versionMap[jestMajorVersion];
|
|
48
|
+
}
|
|
49
|
+
const backwardCompatibleVersions = supportedMajorVersions.slice(0, -1);
|
|
50
|
+
throw new Error(`You're currently using an unsupported Jest version: ${installedJestVersion}. Supported major versions are ${backwardCompatibleVersions.join(', ')} and ${currentMajorVersion}.`);
|
|
51
|
+
}
|
|
52
|
+
function getInstalledJestVersion(tree) {
|
|
53
|
+
try {
|
|
54
|
+
let version;
|
|
55
|
+
if (tree) {
|
|
56
|
+
version = getJestVersionFromTree(tree);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
version = getJestVersionFromFileSystem();
|
|
60
|
+
}
|
|
61
|
+
return version;
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function getInstalledJestVersionInfo(tree) {
|
|
68
|
+
const version = getInstalledJestVersion(tree);
|
|
69
|
+
return version
|
|
70
|
+
? { version, major: (0, semver_1.major)(version) }
|
|
71
|
+
: { version: null, major: null };
|
|
72
|
+
}
|
|
73
|
+
function getInstalledJestMajorVersion(tree) {
|
|
74
|
+
const installedJestVersion = getInstalledJestVersion(tree);
|
|
75
|
+
return installedJestVersion ? (0, semver_1.major)(installedJestVersion) : null;
|
|
76
|
+
}
|
|
77
|
+
function validateInstalledJestVersion(tree) {
|
|
78
|
+
const { version, major } = getInstalledJestVersionInfo(tree);
|
|
79
|
+
if (!version) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
if (major < minSupportedMajorVersion || major > currentMajorVersion) {
|
|
83
|
+
const backwardCompatibleVersions = supportedMajorVersions.slice(0, -1);
|
|
84
|
+
throw new Error(`You're currently using an unsupported Jest version: ${version}. Supported major versions are ${backwardCompatibleVersions.join(', ')} and ${currentMajorVersion}.`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
function getJestVersionFromTree(tree) {
|
|
88
|
+
const packageJson = (0, devkit_1.readJson)(tree, 'package.json');
|
|
89
|
+
const installedVersion = packageJson.devDependencies?.jest ?? packageJson.dependencies?.jest;
|
|
90
|
+
if (!installedVersion) {
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
if (installedVersion === 'latest' || installedVersion === 'next') {
|
|
94
|
+
return ((0, semver_1.clean)(exports.latestVersions.jestVersion) ??
|
|
95
|
+
(0, semver_1.coerce)(exports.latestVersions.jestVersion)?.version);
|
|
96
|
+
}
|
|
97
|
+
return (0, semver_1.clean)(installedVersion) ?? (0, semver_1.coerce)(installedVersion)?.version;
|
|
98
|
+
}
|
|
99
|
+
function getJestVersionFromFileSystem() {
|
|
100
|
+
try {
|
|
101
|
+
const { getVersion } = require('jest');
|
|
102
|
+
return getVersion();
|
|
103
|
+
}
|
|
104
|
+
catch { }
|
|
105
|
+
return null;
|
|
106
|
+
}
|