@nx/jest 19.6.0-beta.0 → 19.6.0-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 CHANGED
@@ -45,6 +45,43 @@
45
45
  "alwaysAddToPackageJson": false
46
46
  }
47
47
  }
48
+ },
49
+ "19.6.0": {
50
+ "version": "19.6.0-beta.1",
51
+ "packages": {
52
+ "jest": {
53
+ "version": "~29.7.0",
54
+ "alwaysAddToPackageJson": false
55
+ },
56
+ "@types/jest": {
57
+ "version": "~29.5.12",
58
+ "alwaysAddToPackageJson": false
59
+ },
60
+ "expect": {
61
+ "version": "~29.7.0",
62
+ "alwaysAddToPackageJson": false
63
+ },
64
+ "@jest/globals": {
65
+ "version": "~29.7.0",
66
+ "alwaysAddToPackageJson": false
67
+ },
68
+ "jest-jasmine2": {
69
+ "version": "~29.7.0",
70
+ "alwaysAddToPackageJson": false
71
+ },
72
+ "jest-environment-jsdom": {
73
+ "version": "~29.7.0",
74
+ "alwaysAddToPackageJson": false
75
+ },
76
+ "ts-jest": {
77
+ "version": "~29.2.4",
78
+ "alwaysAddToPackageJson": false
79
+ },
80
+ "babel-jest": {
81
+ "version": "~29.7.0",
82
+ "alwaysAddToPackageJson": false
83
+ }
84
+ }
48
85
  }
49
86
  }
50
87
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/jest",
3
- "version": "19.6.0-beta.0",
3
+ "version": "19.6.0-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": "^29.4.1",
39
39
  "@jest/test-result": "^29.4.1",
40
- "@nx/devkit": "19.6.0-beta.0",
41
- "@nx/js": "19.6.0-beta.0",
40
+ "@nx/devkit": "19.6.0-beta.2",
41
+ "@nx/js": "19.6.0-beta.2",
42
42
  "@phenomnomnominal/tsquery": "~5.0.1",
43
43
  "chalk": "^4.1.0",
44
44
  "identity-obj-proxy": "3.0.0",
@@ -47,9 +47,10 @@
47
47
  "jest-util": "^29.4.1",
48
48
  "minimatch": "9.0.3",
49
49
  "resolve.exports": "1.1.0",
50
+ "semver": "^7.5.3",
50
51
  "tslib": "^2.3.0",
51
52
  "yargs-parser": "21.1.1",
52
- "@nrwl/jest": "19.6.0-beta.0"
53
+ "@nrwl/jest": "19.6.0-beta.2"
53
54
  },
54
55
  "publishConfig": {
55
56
  "access": "public"
@@ -2,18 +2,17 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createNodes = exports.createNodesV2 = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
- const path_1 = require("path");
6
- const get_named_inputs_1 = require("@nx/devkit/src/utils/get-named-inputs");
7
- const fs_1 = require("fs");
8
- const jest_config_1 = require("jest-config");
9
- const jest_resolve_1 = require("jest-resolve");
10
- const cache_directory_1 = require("nx/src/utils/cache-directory");
11
5
  const calculate_hash_for_create_nodes_1 = require("@nx/devkit/src/utils/calculate-hash-for-create-nodes");
12
6
  const config_utils_1 = require("@nx/devkit/src/utils/config-utils");
13
- const package_json_1 = require("nx/src/plugins/package-json");
14
- const globs_1 = require("nx/src/utils/globs");
7
+ const get_named_inputs_1 = require("@nx/devkit/src/utils/get-named-inputs");
8
+ const fs_1 = require("fs");
15
9
  const minimatch_1 = require("minimatch");
16
10
  const devkit_internals_1 = require("nx/src/devkit-internals");
11
+ const package_json_1 = require("nx/src/plugins/package-json");
12
+ const cache_directory_1 = require("nx/src/utils/cache-directory");
13
+ const globs_1 = require("nx/src/utils/globs");
14
+ const path_1 = require("path");
15
+ const version_utils_1 = require("../utils/version-utils");
17
16
  const pmc = (0, devkit_1.getPackageManagerCommand)();
18
17
  function readTargetsCache(cachePath) {
19
18
  return (0, fs_1.existsSync)(cachePath) ? (0, devkit_1.readJsonFile)(cachePath) : {};
@@ -91,7 +90,8 @@ async function buildJestTargets(configFilePath, projectRoot, options, context) {
91
90
  (0, config_utils_1.clearRequireCache)();
92
91
  }
93
92
  const rawConfig = await (0, config_utils_1.loadConfigFile)(absConfigFilePath);
94
- const config = await (0, jest_config_1.readConfig)({
93
+ const { readConfig } = requireJestUtil('jest-config', projectRoot, context.workspaceRoot);
94
+ const config = await readConfig({
95
95
  _: [],
96
96
  $0: undefined,
97
97
  }, rawConfig, undefined, (0, path_1.dirname)(absConfigFilePath));
@@ -120,20 +120,19 @@ async function buildJestTargets(configFilePath, projectRoot, options, context) {
120
120
  const outputs = (target.outputs = getOutputs(projectRoot, config, context));
121
121
  let metadata;
122
122
  if (options?.ciTargetName) {
123
- // Resolve the version of `jest-runtime` that `jest` is using.
124
- const jestPath = require.resolve('jest');
125
- const jest = require(jestPath);
126
123
  // nx-ignore-next-line
127
- const { default: Runtime } = require(require.resolve('jest-runtime', {
128
- paths: [(0, path_1.dirname)(jestPath)],
129
- // nx-ignore-next-line
130
- }));
124
+ const { default: Runtime } = requireJestUtil('jest-runtime', projectRoot, context.workspaceRoot);
131
125
  const jestContext = await Runtime.createContext(config.projectConfig, {
132
126
  maxWorkers: 1,
133
127
  watchman: false,
134
128
  });
129
+ const jest = require(resolveJestPath(projectRoot, context.workspaceRoot));
135
130
  const source = new jest.SearchSource(jestContext);
136
- const specs = await source.getTestPaths(config.globalConfig);
131
+ const jestVersion = (0, version_utils_1.getInstalledJestMajorVersion)();
132
+ const specs = jestVersion >= 30
133
+ ? // @ts-expect-error Jest 30+ expects the project config as the second argument
134
+ await source.getTestPaths(config.globalConfig, config.projectConfig)
135
+ : await source.getTestPaths(config.globalConfig);
137
136
  const testPaths = new Set(specs.tests.map(({ path }) => path));
138
137
  if (testPaths.size > 0) {
139
138
  const groupName = 'E2E (CI)';
@@ -222,12 +221,14 @@ function resolvePresetInput(presetValue, projectRoot, workspaceRoot) {
222
221
  if (!presetValue) {
223
222
  return null;
224
223
  }
225
- let presetPath = (0, jest_config_1.replaceRootDirInPath)(projectRoot, presetValue);
224
+ const { replaceRootDirInPath } = requireJestUtil('jest-config', projectRoot, workspaceRoot);
225
+ let presetPath = replaceRootDirInPath(projectRoot, presetValue);
226
226
  const isNpmPackage = !presetValue.startsWith('.') && !(0, path_1.isAbsolute)(presetPath);
227
227
  presetPath = presetPath.startsWith('.')
228
228
  ? presetPath
229
229
  : (0, path_1.join)(presetPath, 'jest-preset');
230
- const presetModule = jest_resolve_1.default.findNodeModule(presetPath, {
230
+ const { default: jestResolve } = requireJestUtil('jest-resolve', projectRoot, workspaceRoot);
231
+ const presetModule = jestResolve.findNodeModule(presetPath, {
231
232
  basedir: projectRoot,
232
233
  extensions: ['.json', '.js', '.cjs', '.mjs'],
233
234
  });
@@ -268,3 +269,20 @@ function normalizeOptions(options) {
268
269
  options.targetName ??= 'test';
269
270
  return options;
270
271
  }
272
+ let resolvedJestPaths;
273
+ function resolveJestPath(projectRoot, workspaceRoot) {
274
+ resolvedJestPaths ??= {};
275
+ if (resolvedJestPaths[projectRoot]) {
276
+ return resolvedJestPaths[projectRoot];
277
+ }
278
+ return require.resolve('jest', {
279
+ paths: [projectRoot, workspaceRoot, __dirname],
280
+ });
281
+ }
282
+ /**
283
+ * Resolves a jest util package version that `jest` is using.
284
+ */
285
+ function requireJestUtil(packageName, projectRoot, workspaceRoot) {
286
+ const jestPath = resolveJestPath(projectRoot, workspaceRoot);
287
+ return require(require.resolve(packageName, { paths: [(0, path_1.dirname)(jestPath)] }));
288
+ }
@@ -0,0 +1,2 @@
1
+ export declare function getInstalledJestVersion(): string | null;
2
+ export declare function getInstalledJestMajorVersion(): number | null;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getInstalledJestVersion = getInstalledJestVersion;
4
+ exports.getInstalledJestMajorVersion = getInstalledJestMajorVersion;
5
+ const semver_1 = require("semver");
6
+ function getInstalledJestVersion() {
7
+ try {
8
+ return require('jest/package.json').version;
9
+ }
10
+ catch {
11
+ return null;
12
+ }
13
+ }
14
+ function getInstalledJestMajorVersion() {
15
+ const installedVersion = getInstalledJestVersion();
16
+ return installedVersion ? (0, semver_1.major)(installedVersion) : null;
17
+ }
@@ -1,8 +1,8 @@
1
1
  export declare const nxVersion: any;
2
- export declare const jestVersion = "^29.4.1";
3
- export declare const babelJestVersion = "^29.4.1";
4
- export declare const jestTypesVersion = "^29.4.0";
5
- export declare const tsJestVersion = "^29.1.0";
2
+ export declare const jestVersion = "^29.7.0";
3
+ export declare const babelJestVersion = "^29.7.0";
4
+ export declare const jestTypesVersion = "^29.5.12";
5
+ export declare const tsJestVersion = "^29.2.4";
6
6
  export declare const tslibVersion = "^2.3.0";
7
7
  export declare const swcJestVersion = "~0.2.36";
8
8
  export declare const typesNodeVersion = "18.16.9";
@@ -2,10 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.tsNodeVersion = exports.typesNodeVersion = exports.swcJestVersion = exports.tslibVersion = exports.tsJestVersion = exports.jestTypesVersion = exports.babelJestVersion = exports.jestVersion = exports.nxVersion = void 0;
4
4
  exports.nxVersion = require('../../package.json').version;
5
- exports.jestVersion = '^29.4.1';
6
- exports.babelJestVersion = '^29.4.1';
7
- exports.jestTypesVersion = '^29.4.0';
8
- exports.tsJestVersion = '^29.1.0';
5
+ exports.jestVersion = '^29.7.0';
6
+ exports.babelJestVersion = '^29.7.0';
7
+ exports.jestTypesVersion = '^29.5.12';
8
+ exports.tsJestVersion = '^29.2.4';
9
9
  exports.tslibVersion = '^2.3.0';
10
10
  exports.swcJestVersion = '~0.2.36';
11
11
  exports.typesNodeVersion = '18.16.9';