@nx/jest 19.6.0-beta.1 → 19.6.0-beta.3
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/package.json +5 -4
- package/src/plugins/plugin.js +24 -18
- package/src/utils/version-utils.d.ts +2 -0
- package/src/utils/version-utils.js +17 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/jest",
|
|
3
|
-
"version": "19.6.0-beta.
|
|
3
|
+
"version": "19.6.0-beta.3",
|
|
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.
|
|
41
|
-
"@nx/js": "19.6.0-beta.
|
|
40
|
+
"@nx/devkit": "19.6.0-beta.3",
|
|
41
|
+
"@nx/js": "19.6.0-beta.3",
|
|
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.
|
|
53
|
+
"@nrwl/jest": "19.6.0-beta.3"
|
|
53
54
|
},
|
|
54
55
|
"publishConfig": {
|
|
55
56
|
"access": "public"
|
package/src/plugins/plugin.js
CHANGED
|
@@ -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
|
|
14
|
-
const
|
|
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
|
|
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));
|
|
@@ -121,14 +121,18 @@ async function buildJestTargets(configFilePath, projectRoot, options, context) {
|
|
|
121
121
|
let metadata;
|
|
122
122
|
if (options?.ciTargetName) {
|
|
123
123
|
// nx-ignore-next-line
|
|
124
|
-
const { default: Runtime } = requireJestUtil('jest-runtime', projectRoot, context);
|
|
124
|
+
const { default: Runtime } = requireJestUtil('jest-runtime', projectRoot, context.workspaceRoot);
|
|
125
125
|
const jestContext = await Runtime.createContext(config.projectConfig, {
|
|
126
126
|
maxWorkers: 1,
|
|
127
127
|
watchman: false,
|
|
128
128
|
});
|
|
129
|
-
const jest = require(resolveJestPath(projectRoot, context));
|
|
129
|
+
const jest = require(resolveJestPath(projectRoot, context.workspaceRoot));
|
|
130
130
|
const source = new jest.SearchSource(jestContext);
|
|
131
|
-
const
|
|
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);
|
|
132
136
|
const testPaths = new Set(specs.tests.map(({ path }) => path));
|
|
133
137
|
if (testPaths.size > 0) {
|
|
134
138
|
const groupName = 'E2E (CI)';
|
|
@@ -217,12 +221,14 @@ function resolvePresetInput(presetValue, projectRoot, workspaceRoot) {
|
|
|
217
221
|
if (!presetValue) {
|
|
218
222
|
return null;
|
|
219
223
|
}
|
|
220
|
-
|
|
224
|
+
const { replaceRootDirInPath } = requireJestUtil('jest-config', projectRoot, workspaceRoot);
|
|
225
|
+
let presetPath = replaceRootDirInPath(projectRoot, presetValue);
|
|
221
226
|
const isNpmPackage = !presetValue.startsWith('.') && !(0, path_1.isAbsolute)(presetPath);
|
|
222
227
|
presetPath = presetPath.startsWith('.')
|
|
223
228
|
? presetPath
|
|
224
229
|
: (0, path_1.join)(presetPath, 'jest-preset');
|
|
225
|
-
const
|
|
230
|
+
const { default: jestResolve } = requireJestUtil('jest-resolve', projectRoot, workspaceRoot);
|
|
231
|
+
const presetModule = jestResolve.findNodeModule(presetPath, {
|
|
226
232
|
basedir: projectRoot,
|
|
227
233
|
extensions: ['.json', '.js', '.cjs', '.mjs'],
|
|
228
234
|
});
|
|
@@ -264,19 +270,19 @@ function normalizeOptions(options) {
|
|
|
264
270
|
return options;
|
|
265
271
|
}
|
|
266
272
|
let resolvedJestPaths;
|
|
267
|
-
function resolveJestPath(projectRoot,
|
|
273
|
+
function resolveJestPath(projectRoot, workspaceRoot) {
|
|
268
274
|
resolvedJestPaths ??= {};
|
|
269
275
|
if (resolvedJestPaths[projectRoot]) {
|
|
270
276
|
return resolvedJestPaths[projectRoot];
|
|
271
277
|
}
|
|
272
278
|
return require.resolve('jest', {
|
|
273
|
-
paths: [projectRoot,
|
|
279
|
+
paths: [projectRoot, workspaceRoot, __dirname],
|
|
274
280
|
});
|
|
275
281
|
}
|
|
276
282
|
/**
|
|
277
283
|
* Resolves a jest util package version that `jest` is using.
|
|
278
284
|
*/
|
|
279
|
-
function requireJestUtil(packageName, projectRoot,
|
|
280
|
-
const jestPath = resolveJestPath(projectRoot,
|
|
285
|
+
function requireJestUtil(packageName, projectRoot, workspaceRoot) {
|
|
286
|
+
const jestPath = resolveJestPath(projectRoot, workspaceRoot);
|
|
281
287
|
return require(require.resolve(packageName, { paths: [(0, path_1.dirname)(jestPath)] }));
|
|
282
288
|
}
|
|
@@ -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
|
+
}
|