@nx/jest 23.2.0-beta.4 → 23.2.0-beta.5
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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { JestExecutorOptions } from './schema';
|
|
2
2
|
import { Config } from '@jest/types';
|
|
3
3
|
import { ExecutorContext, TaskGraph } from '@nx/devkit';
|
|
4
|
-
import type
|
|
4
|
+
import { type BatchResults } from '@nx/devkit/internal';
|
|
5
5
|
export declare function jestExecutor(options: JestExecutorOptions, context: ExecutorContext): Promise<{
|
|
6
6
|
success: boolean;
|
|
7
7
|
}>;
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createJestConfig = createJestConfig;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const project_configuration_utils_1 = require("nx/src/project-graph/utils/project-configuration-utils");
|
|
6
5
|
const config_file_1 = require("../../../utils/config/config-file");
|
|
7
6
|
const internal_1 = require("@nx/js/internal");
|
|
7
|
+
const internal_2 = require("@nx/devkit/internal");
|
|
8
8
|
async function createJestConfig(tree, options, presetExt) {
|
|
9
9
|
if (!tree.exists(`jest.preset.${presetExt}`)) {
|
|
10
10
|
if (presetExt === 'mjs') {
|
|
@@ -63,7 +63,7 @@ module.exports = { ...nxPreset };`);
|
|
|
63
63
|
: 'lib'}.${options.js ? 'js' : 'ts'}`;
|
|
64
64
|
tree.rename(rootJestPath, jestProjectConfig);
|
|
65
65
|
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
66
|
-
const targetDefaults = (0,
|
|
66
|
+
const targetDefaults = (0, internal_2.readTargetDefaultsForTarget)(jestTargetName, nxJson.targetDefaults, jestTargetConfigInGraph.executor);
|
|
67
67
|
const target = (rootProjectConfig.targets[jestTargetName] ??=
|
|
68
68
|
jestTargetConfigInGraph.executor === 'nx:run-commands'
|
|
69
69
|
? { command: `jest --config ${jestProjectConfig}` }
|
|
@@ -4,8 +4,6 @@ exports.default = default_1;
|
|
|
4
4
|
const internal_1 = require("@nx/devkit/internal");
|
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
|
6
6
|
const internal_2 = require("@nx/js/internal");
|
|
7
|
-
const devkit_internals_1 = require("nx/src/devkit-internals");
|
|
8
|
-
const project_configuration_utils_1 = require("nx/src/project-graph/utils/project-configuration-utils");
|
|
9
7
|
const path_1 = require("path");
|
|
10
8
|
const functions_1 = require("../../utils/config/functions");
|
|
11
9
|
const EXECUTOR_TO_MIGRATE = '@nx/jest:jest';
|
|
@@ -168,7 +166,7 @@ function migrateOneJestConfig(tree, jestConfigPath, setupFile, location, rewritt
|
|
|
168
166
|
function migrateInheritedSetupFile(tree, project, target, nxJson, projectConfigCache, rewrittenJestConfigs, warnLists) {
|
|
169
167
|
if (!nxJson?.targetDefaults)
|
|
170
168
|
return;
|
|
171
|
-
const matched = (0,
|
|
169
|
+
const matched = (0, internal_1.readTargetDefaultsForTarget)(target, nxJson.targetDefaults, EXECUTOR_TO_MIGRATE);
|
|
172
170
|
const inheritedSetupFile = matched?.options?.[SETUP_FILE];
|
|
173
171
|
if (inheritedSetupFile === undefined)
|
|
174
172
|
return;
|
|
@@ -308,14 +306,14 @@ function resolveJestConfigPath(callbackJestConfig, targetJestConfig, projectRoot
|
|
|
308
306
|
return expandWorkspaceRelativePath(explicit, projectRoot);
|
|
309
307
|
if (!nxJson?.targetDefaults)
|
|
310
308
|
return undefined;
|
|
311
|
-
const matched = (0,
|
|
309
|
+
const matched = (0, internal_1.readTargetDefaultsForTarget)(target, nxJson.targetDefaults, EXECUTOR_TO_MIGRATE);
|
|
312
310
|
const fromDefaults = matched?.options?.[JEST_CONFIG];
|
|
313
311
|
if (fromDefaults)
|
|
314
312
|
return expandWorkspaceRelativePath(fromDefaults, projectRoot);
|
|
315
313
|
return undefined;
|
|
316
314
|
}
|
|
317
315
|
function expandWorkspaceRelativePath(value, projectRoot) {
|
|
318
|
-
return path_1.posix.normalize((0,
|
|
316
|
+
return path_1.posix.normalize((0, internal_1.interpolate)(value, {
|
|
319
317
|
projectRoot: projectRoot || '.',
|
|
320
318
|
workspaceRoot: '.',
|
|
321
319
|
}));
|
|
@@ -6,13 +6,6 @@ const devkit_1 = require("@nx/devkit");
|
|
|
6
6
|
const minimatch_1 = require("minimatch");
|
|
7
7
|
const node_fs_1 = require("node:fs");
|
|
8
8
|
const node_path_1 = require("node:path");
|
|
9
|
-
const devkit_internals_1 = require("nx/src/devkit-internals");
|
|
10
|
-
const package_json_1 = require("nx/src/plugins/package-json");
|
|
11
|
-
const cache_directory_1 = require("nx/src/utils/cache-directory");
|
|
12
|
-
const globs_1 = require("nx/src/utils/globs");
|
|
13
|
-
const installation_directory_1 = require("nx/src/utils/installation-directory");
|
|
14
|
-
const plugins_1 = require("nx/src/utils/plugins");
|
|
15
|
-
const workspace_context_1 = require("nx/src/utils/workspace-context");
|
|
16
9
|
const js_1 = require("@nx/js");
|
|
17
10
|
const internal_2 = require("@nx/js/internal");
|
|
18
11
|
const versions_1 = require("../utils/versions");
|
|
@@ -21,8 +14,8 @@ const jestConfigGlob = '**/jest.config.{cjs,mjs,js,cts,mts,ts}';
|
|
|
21
14
|
exports.createNodes = [
|
|
22
15
|
jestConfigGlob,
|
|
23
16
|
async (configFiles, options, context) => {
|
|
24
|
-
const optionsHash = (0,
|
|
25
|
-
const cachePath = (0, node_path_1.join)(
|
|
17
|
+
const optionsHash = (0, internal_1.hashObject)(options);
|
|
18
|
+
const cachePath = (0, node_path_1.join)(internal_1.workspaceDataDirectory, `jest-${optionsHash}.hash`);
|
|
26
19
|
const targetsCache = new internal_1.PluginCache(cachePath);
|
|
27
20
|
// Cache jest preset(s) to avoid penalties of module load times. Most of jest configs will use the same preset.
|
|
28
21
|
const presetCache = {};
|
|
@@ -111,7 +104,7 @@ function buildPackageJsonWorkspacesMatcher(workspaceRoot) {
|
|
|
111
104
|
if (process.env.NX_INFER_ALL_PACKAGE_JSONS === 'true') {
|
|
112
105
|
return () => true;
|
|
113
106
|
}
|
|
114
|
-
const packageManagerWorkspacesGlob = (0,
|
|
107
|
+
const packageManagerWorkspacesGlob = (0, internal_1.combineGlobPatterns)((0, internal_1.getGlobPatternsFromPackageManagerWorkspaces)(workspaceRoot));
|
|
115
108
|
return (path) => (0, minimatch_1.minimatch)(path, packageManagerWorkspacesGlob);
|
|
116
109
|
}
|
|
117
110
|
function checkIfConfigFileShouldBeProject(configFilePath, projectRoot, isInPackageManagerWorkspaces, context) {
|
|
@@ -181,7 +174,7 @@ async function buildJestTargets(rawConfig, needsDtsInputs, configFilePath, proje
|
|
|
181
174
|
const cache = (target.cache = true);
|
|
182
175
|
const inputs = (target.inputs = await getInputs(namedInputs, rawConfig, rootDir, projectRoot, context.workspaceRoot, presetCache, needsDtsInputs, useJestResolver));
|
|
183
176
|
let metadata;
|
|
184
|
-
const groupName = options?.ciGroupName ?? (0,
|
|
177
|
+
const groupName = options?.ciGroupName ?? (0, internal_1.deriveGroupNameFromTarget)(options?.ciTargetName);
|
|
185
178
|
if (disableJestRuntime) {
|
|
186
179
|
const outputs = (target.outputs = getOutputs(projectRoot, rawConfig.coverageDirectory
|
|
187
180
|
? (0, node_path_1.join)(context.workspaceRoot, projectRoot, rawConfig.coverageDirectory)
|
|
@@ -567,7 +560,7 @@ function resolveJestPath(projectRoot, workspaceRoot) {
|
|
|
567
560
|
return resolvedJestPaths[projectRoot];
|
|
568
561
|
}
|
|
569
562
|
resolvedJestPaths[projectRoot] = require.resolve('jest', {
|
|
570
|
-
paths: [projectRoot, ...(0,
|
|
563
|
+
paths: [projectRoot, ...(0, internal_1.getNxRequirePaths)(workspaceRoot), __dirname],
|
|
571
564
|
});
|
|
572
565
|
return resolvedJestPaths[projectRoot];
|
|
573
566
|
}
|
|
@@ -590,7 +583,7 @@ function requireJestUtil(packageName, projectRoot, workspaceRoot) {
|
|
|
590
583
|
}
|
|
591
584
|
async function getTestPaths(projectRoot, rawConfig, rootDir, context, presetCache) {
|
|
592
585
|
const testMatch = await getJestOption(rawConfig, rootDir, 'testMatch', presetCache);
|
|
593
|
-
let paths = await (0,
|
|
586
|
+
let paths = await (0, internal_1.globWithWorkspaceContext)(context.workspaceRoot, (testMatch || [
|
|
594
587
|
// Default copied from https://github.com/jestjs/jest/blob/d1a2ed7/packages/jest-config/src/Defaults.ts#L84
|
|
595
588
|
'**/__tests__/**/*.?([mc])[jt]s?(x)',
|
|
596
589
|
'**/?(*.)+(spec|test).?([mc])[jt]s?(x)',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/jest",
|
|
3
|
-
"version": "23.2.0-beta.
|
|
3
|
+
"version": "23.2.0-beta.5",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"files": [
|
|
@@ -117,11 +117,11 @@
|
|
|
117
117
|
"semver": "^7.6.3",
|
|
118
118
|
"tslib": "^2.3.0",
|
|
119
119
|
"yargs-parser": "21.1.1",
|
|
120
|
-
"@nx/devkit": "23.2.0-beta.
|
|
121
|
-
"@nx/js": "23.2.0-beta.
|
|
120
|
+
"@nx/devkit": "23.2.0-beta.5",
|
|
121
|
+
"@nx/js": "23.2.0-beta.5"
|
|
122
122
|
},
|
|
123
123
|
"devDependencies": {
|
|
124
|
-
"nx": "23.2.0-beta.
|
|
124
|
+
"nx": "23.2.0-beta.5"
|
|
125
125
|
},
|
|
126
126
|
"publishConfig": {
|
|
127
127
|
"access": "public"
|