@nx/jest 23.0.0-beta.21 → 23.0.0-beta.23

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.
Files changed (25) hide show
  1. package/dist/src/executors/jest/jest.impl.js +0 -10
  2. package/dist/src/executors/jest/schema.d.ts +0 -7
  3. package/dist/src/executors/jest/schema.json +0 -5
  4. package/dist/src/generators/configuration/configuration.js +2 -5
  5. package/dist/src/generators/configuration/lib/ensure-dependencies.js +1 -1
  6. package/dist/src/generators/configuration/schema.d.ts +0 -4
  7. package/dist/src/generators/configuration/schema.json +0 -6
  8. package/dist/src/generators/convert-to-inferred/convert-to-inferred.js +2 -0
  9. package/dist/src/generators/init/init.js +3 -5
  10. package/dist/src/generators/init/schema.json +1 -1
  11. package/dist/src/migrations/update-23-0-0/migrate-jest-configuration-skip-setup-file.d.ts +2 -0
  12. package/dist/src/migrations/update-23-0-0/migrate-jest-configuration-skip-setup-file.js +62 -0
  13. package/dist/src/migrations/update-23-0-0/migrate-jest-configuration-skip-setup-file.md +91 -0
  14. package/dist/src/migrations/update-23-0-0/migrate-jest-executor-setup-file.d.ts +2 -0
  15. package/dist/src/migrations/update-23-0-0/migrate-jest-executor-setup-file.js +476 -0
  16. package/dist/src/migrations/update-23-0-0/migrate-jest-executor-setup-file.md +169 -0
  17. package/dist/src/plugins/plugin.d.ts +3 -3
  18. package/dist/src/utils/assert-supported-jest-version.d.ts +2 -0
  19. package/dist/src/utils/assert-supported-jest-version.js +11 -0
  20. package/dist/src/utils/versions.d.ts +13 -2
  21. package/dist/src/utils/versions.js +26 -46
  22. package/migrations.json +29 -8
  23. package/package.json +16 -4
  24. package/dist/src/utils/version-utils.d.ts +0 -2
  25. package/dist/src/utils/version-utils.js +0 -18
@@ -1,4 +1,6 @@
1
1
  import { type Tree } from '@nx/devkit';
2
+ export declare const minSupportedJestVersion = "29.0.0";
3
+ export declare const minSupportedTsJestVersion = "29.0.0";
2
4
  export declare const latestVersions: {
3
5
  nxVersion: any;
4
6
  jestVersion: string;
@@ -17,12 +19,21 @@ export type VersionMap = {
17
19
  [key in SupportedVersions]: Record<PackageVersionNames, string>;
18
20
  };
19
21
  export declare const versionMap: VersionMap;
20
- export declare function versions(tree: Tree): any;
22
+ export declare function versions(tree: Tree): {
23
+ nxVersion: any;
24
+ jestVersion: string;
25
+ babelJestVersion: string;
26
+ jestTypesVersion: string;
27
+ tsJestVersion: string;
28
+ tslibVersion: string;
29
+ swcJestVersion: string;
30
+ typesNodeVersion: string;
31
+ tsNodeVersion: string;
32
+ };
21
33
  export declare function getInstalledJestVersion(tree?: Tree): string | null;
22
34
  export declare function getInstalledJestVersionInfo(tree?: Tree): {
23
35
  version: string | null;
24
36
  major: number | null;
25
37
  };
26
38
  export declare function getInstalledJestMajorVersion(tree?: Tree): number | null;
27
- export declare function validateInstalledJestVersion(tree?: Tree): void;
28
39
  export {};
@@ -1,15 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.versionMap = exports.latestVersions = void 0;
3
+ exports.versionMap = exports.latestVersions = exports.minSupportedTsJestVersion = exports.minSupportedJestVersion = void 0;
4
4
  exports.versions = versions;
5
5
  exports.getInstalledJestVersion = getInstalledJestVersion;
6
6
  exports.getInstalledJestVersionInfo = getInstalledJestVersionInfo;
7
7
  exports.getInstalledJestMajorVersion = getInstalledJestMajorVersion;
8
- exports.validateInstalledJestVersion = validateInstalledJestVersion;
9
8
  const devkit_1 = require("@nx/devkit");
9
+ const internal_1 = require("@nx/devkit/internal");
10
10
  const path_1 = require("path");
11
11
  const semver_1 = require("semver");
12
12
  const nxVersion = require((0, path_1.join)('@nx/jest', 'package.json')).version;
13
+ exports.minSupportedJestVersion = '29.0.0';
14
+ exports.minSupportedTsJestVersion = '29.0.0';
13
15
  // Jest is pinned to 30.3.x because jest-runtime@30.4.0 added a call to
14
16
  // `_moduleMocker.clearMocksOnScope()`, which doesn't exist on the
15
17
  // jest-mock@29 ModuleMocker that React Native's preset still feeds in
@@ -20,6 +22,9 @@ exports.latestVersions = {
20
22
  jestVersion: '~30.3.0',
21
23
  babelJestVersion: '~30.3.0',
22
24
  jestTypesVersion: '~30.0.0',
25
+ // ts-jest has not shipped a v30 — 29.x is its latest line and its peers
26
+ // already span jest 29 and 30 (`jest: '^29.0.0 || ^30.0.0'`), so a jest-30
27
+ // workspace correctly stays on ts-jest 29.x.
23
28
  tsJestVersion: '^29.4.0',
24
29
  tslibVersion: '^2.3.0',
25
30
  swcJestVersion: '~0.2.38',
@@ -27,8 +32,6 @@ exports.latestVersions = {
27
32
  tsNodeVersion: '10.9.1',
28
33
  };
29
34
  const supportedMajorVersions = [29, 30];
30
- const minSupportedMajorVersion = Math.min(...supportedMajorVersions);
31
- const currentMajorVersion = Math.max(...supportedMajorVersions);
32
35
  exports.versionMap = {
33
36
  29: {
34
37
  nxVersion,
@@ -49,22 +52,28 @@ function versions(tree) {
49
52
  return exports.latestVersions;
50
53
  }
51
54
  const jestMajorVersion = (0, semver_1.major)(installedJestVersion);
52
- if (exports.versionMap[jestMajorVersion]) {
53
- return exports.versionMap[jestMajorVersion];
54
- }
55
- const backwardCompatibleVersions = supportedMajorVersions.slice(0, -1);
56
- throw new Error(`You're currently using an unsupported Jest version: ${installedJestVersion}. Supported major versions are ${backwardCompatibleVersions.join(', ')} and ${currentMajorVersion}.`);
55
+ return exports.versionMap[jestMajorVersion] ?? exports.latestVersions;
57
56
  }
58
57
  function getInstalledJestVersion(tree) {
58
+ if (!tree) {
59
+ // Fall back to `@nx/jest`'s own jest when the workspace cwd can't resolve
60
+ // one (e.g. inferred-plugin createNodes runs against an empty workspace).
61
+ return (0, internal_1.getInstalledPackageVersion)('jest') ?? getJestVersionFromRequire();
62
+ }
63
+ const installedVersion = (0, devkit_1.getDependencyVersionFromPackageJson)(tree, 'jest');
64
+ if (!installedVersion) {
65
+ return null;
66
+ }
67
+ if (installedVersion === 'latest' || installedVersion === 'next') {
68
+ return ((0, semver_1.clean)(exports.latestVersions.jestVersion) ??
69
+ (0, semver_1.coerce)(exports.latestVersions.jestVersion)?.version ??
70
+ null);
71
+ }
72
+ return (0, semver_1.clean)(installedVersion) ?? (0, semver_1.coerce)(installedVersion)?.version ?? null;
73
+ }
74
+ function getJestVersionFromRequire() {
59
75
  try {
60
- let version;
61
- if (tree) {
62
- version = getJestVersionFromTree(tree);
63
- }
64
- else {
65
- version = getJestVersionFromFileSystem();
66
- }
67
- return version;
76
+ return require('jest').getVersion();
68
77
  }
69
78
  catch {
70
79
  return null;
@@ -80,32 +89,3 @@ function getInstalledJestMajorVersion(tree) {
80
89
  const installedJestVersion = getInstalledJestVersion(tree);
81
90
  return installedJestVersion ? (0, semver_1.major)(installedJestVersion) : null;
82
91
  }
83
- function validateInstalledJestVersion(tree) {
84
- const { version, major } = getInstalledJestVersionInfo(tree);
85
- if (!version) {
86
- return;
87
- }
88
- if (major < minSupportedMajorVersion || major > currentMajorVersion) {
89
- const backwardCompatibleVersions = supportedMajorVersions.slice(0, -1);
90
- throw new Error(`You're currently using an unsupported Jest version: ${version}. Supported major versions are ${backwardCompatibleVersions.join(', ')} and ${currentMajorVersion}.`);
91
- }
92
- }
93
- function getJestVersionFromTree(tree) {
94
- const installedVersion = (0, devkit_1.getDependencyVersionFromPackageJson)(tree, 'jest');
95
- if (!installedVersion) {
96
- return null;
97
- }
98
- if (installedVersion === 'latest' || installedVersion === 'next') {
99
- return ((0, semver_1.clean)(exports.latestVersions.jestVersion) ??
100
- (0, semver_1.coerce)(exports.latestVersions.jestVersion)?.version);
101
- }
102
- return (0, semver_1.clean)(installedVersion) ?? (0, semver_1.coerce)(installedVersion)?.version;
103
- }
104
- function getJestVersionFromFileSystem() {
105
- try {
106
- const { getVersion } = require('jest');
107
- return getVersion();
108
- }
109
- catch { }
110
- return null;
111
- }
package/migrations.json CHANGED
@@ -4,23 +4,27 @@
4
4
  "cli": "nx",
5
5
  "version": "20.0.0-beta.5",
6
6
  "description": "Replace usage of `getJestProjects` with `getJestProjectsAsync`.",
7
- "implementation": "./dist/src/migrations/update-20-0-0/replace-getJestProjects-with-getJestProjectsAsync"
7
+ "implementation": "./dist/src/migrations/update-20-0-0/replace-getJestProjects-with-getJestProjectsAsync",
8
+ "documentation": "./dist/src/migrations/update-20-0-0/replace-getJestProjects-with-getJestProjectsAsync.md"
8
9
  },
9
10
  "replace-getJestProjects-with-getJestProjectsAsync-v21": {
10
11
  "cli": "nx",
11
12
  "version": "21.0.0-beta.9",
12
13
  "description": "Replace usage of `getJestProjects` with `getJestProjectsAsync`.",
13
- "implementation": "./dist/src/migrations/update-21-0-0/replace-getJestProjects-with-getJestProjectsAsync"
14
+ "implementation": "./dist/src/migrations/update-21-0-0/replace-getJestProjects-with-getJestProjectsAsync",
15
+ "documentation": "./dist/src/migrations/update-21-0-0/replace-getJestProjects-with-getJestProjectsAsync.md"
14
16
  },
15
17
  "remove-tsconfig-option-from-jest-executor": {
16
18
  "version": "21.0.0-beta.10",
17
19
  "description": "Remove the previously deprecated and unused `tsConfig` option from the `@nx/jest:jest` executor.",
18
- "implementation": "./dist/src/migrations/update-21-0-0/remove-tsconfig-option-from-jest-executor"
20
+ "implementation": "./dist/src/migrations/update-21-0-0/remove-tsconfig-option-from-jest-executor",
21
+ "documentation": "./dist/src/migrations/update-21-0-0/remove-tsconfig-option-from-jest-executor.md"
19
22
  },
20
23
  "rename-test-path-pattern": {
21
24
  "version": "21.3.0-beta.3",
22
25
  "description": "Rename the CLI option `testPathPattern` to `testPathPatterns`.",
23
- "implementation": "./dist/src/migrations/update-21-3-0/rename-test-path-pattern"
26
+ "implementation": "./dist/src/migrations/update-21-3-0/rename-test-path-pattern",
27
+ "documentation": "./dist/src/migrations/update-21-3-0/rename-test-path-pattern.md"
24
28
  },
25
29
  "replace-removed-matcher-aliases": {
26
30
  "version": "21.3.0-beta.3",
@@ -28,12 +32,14 @@
28
32
  "jest": ">=30.0.0"
29
33
  },
30
34
  "description": "Replace removed matcher aliases in Jest v30 with their corresponding matcher",
31
- "implementation": "./dist/src/migrations/update-21-3-0/replace-removed-matcher-aliases"
35
+ "implementation": "./dist/src/migrations/update-21-3-0/replace-removed-matcher-aliases",
36
+ "documentation": "./dist/src/migrations/update-21-3-0/replace-removed-matcher-aliases.md"
32
37
  },
33
38
  "convert-jest-config-to-cjs": {
34
39
  "version": "22.2.0-beta.2",
35
40
  "description": "Convert jest.config.ts files from ESM to CJS syntax (export default -> module.exports, import -> require) for projects using CommonJS resolution to ensure correct loading under Node.js type-stripping.",
36
- "implementation": "./dist/src/migrations/update-22-2-0/convert-jest-config-to-cjs"
41
+ "implementation": "./dist/src/migrations/update-22-2-0/convert-jest-config-to-cjs",
42
+ "documentation": "./dist/src/migrations/update-22-2-0/convert-jest-config-to-cjs.md"
37
43
  },
38
44
  "replace-removed-matcher-aliases-v22-3": {
39
45
  "version": "22.3.2-beta.0",
@@ -41,7 +47,8 @@
41
47
  "jest": ">=30.0.0"
42
48
  },
43
49
  "description": "Replace removed matcher aliases in Jest v30 with their corresponding matcher",
44
- "implementation": "./dist/src/migrations/update-21-3-0/replace-removed-matcher-aliases"
50
+ "implementation": "./dist/src/migrations/update-21-3-0/replace-removed-matcher-aliases",
51
+ "documentation": "./dist/src/migrations/update-21-3-0/replace-removed-matcher-aliases.md"
45
52
  },
46
53
  "update-snapshot-guide-link": {
47
54
  "version": "23.0.0-beta.10",
@@ -49,7 +56,8 @@
49
56
  "jest": ">=30.0.0"
50
57
  },
51
58
  "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": "./dist/src/migrations/update-23-0-0/update-snapshot-guide-link"
59
+ "implementation": "./dist/src/migrations/update-23-0-0/update-snapshot-guide-link",
60
+ "documentation": "./dist/src/migrations/update-23-0-0/update-snapshot-guide-link.md"
53
61
  },
54
62
  "rewrite-jest-internal-subpath-imports": {
55
63
  "version": "23.0.0-beta.16",
@@ -60,6 +68,16 @@
60
68
  "version": "23.0.0-beta.16",
61
69
  "description": "Replaces the removed `jestProjectGenerator` export from `@nx/jest` with its replacement `configurationGenerator`.",
62
70
  "implementation": "./dist/src/migrations/update-23-0-0/rewrite-jest-project-generator"
71
+ },
72
+ "migrate-jest-executor-setup-file": {
73
+ "version": "23.0.0-beta.22",
74
+ "description": "Migrate the deprecated `setupFile` option of the `@nx/jest:jest` executor: push the file path into `setupFilesAfterEnv` in the project's Jest config and remove the option from `project.json` and `nx.json` target defaults.",
75
+ "implementation": "./dist/src/migrations/update-23-0-0/migrate-jest-executor-setup-file"
76
+ },
77
+ "migrate-jest-configuration-skip-setup-file": {
78
+ "version": "23.0.0-beta.22",
79
+ "description": "Migrate the deprecated `skipSetupFile` option of the `@nx/jest:configuration` generator stored as a default in `nx.json` or per-project `project.json` to `setupFile: 'none'` (when `true`) or remove it (when `false`).",
80
+ "implementation": "./dist/src/migrations/update-23-0-0/migrate-jest-configuration-skip-setup-file"
63
81
  }
64
82
  },
65
83
  "packageJsonUpdates": {
@@ -69,6 +87,9 @@
69
87
  "incompatibleWith": {
70
88
  "@angular-devkit/build-angular": "< 21.0.0"
71
89
  },
90
+ "requires": {
91
+ "jest": ">=29.0.0 <30.0.0"
92
+ },
72
93
  "packages": {
73
94
  "jest": {
74
95
  "version": "~30.0.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/jest",
3
- "version": "23.0.0-beta.21",
3
+ "version": "23.0.0-beta.23",
4
4
  "private": false,
5
5
  "type": "commonjs",
6
6
  "files": [
@@ -90,6 +90,18 @@
90
90
  "default": "./dist/internal.js"
91
91
  }
92
92
  },
93
+ "peerDependencies": {
94
+ "jest": "^29.0.0 || ^30.0.0",
95
+ "ts-jest": "^29.0.0"
96
+ },
97
+ "peerDependenciesMeta": {
98
+ "jest": {
99
+ "optional": true
100
+ },
101
+ "ts-jest": {
102
+ "optional": true
103
+ }
104
+ },
93
105
  "dependencies": {
94
106
  "@jest/reporters": "^30.0.2",
95
107
  "@jest/test-result": "^30.0.2",
@@ -104,11 +116,11 @@
104
116
  "semver": "^7.6.3",
105
117
  "tslib": "^2.3.0",
106
118
  "yargs-parser": "21.1.1",
107
- "@nx/devkit": "23.0.0-beta.21",
108
- "@nx/js": "23.0.0-beta.21"
119
+ "@nx/devkit": "23.0.0-beta.23",
120
+ "@nx/js": "23.0.0-beta.23"
109
121
  },
110
122
  "devDependencies": {
111
- "nx": "23.0.0-beta.21"
123
+ "nx": "23.0.0-beta.23"
112
124
  },
113
125
  "publishConfig": {
114
126
  "access": "public"
@@ -1,2 +0,0 @@
1
- export declare function getInstalledJestVersion(): string | null;
2
- export declare function getInstalledJestMajorVersion(): number | null;
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getInstalledJestVersion = getInstalledJestVersion;
4
- exports.getInstalledJestMajorVersion = getInstalledJestMajorVersion;
5
- const jest_1 = require("jest");
6
- const semver_1 = require("semver");
7
- function getInstalledJestVersion() {
8
- try {
9
- return (0, jest_1.getVersion)();
10
- }
11
- catch {
12
- return null;
13
- }
14
- }
15
- function getInstalledJestMajorVersion() {
16
- const installedVersion = getInstalledJestVersion();
17
- return installedVersion ? (0, semver_1.major)(installedVersion) : null;
18
- }