@nx/jest 23.3.0-beta.2 → 23.3.0-beta.4
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.
|
@@ -70,10 +70,11 @@ function createJestDefaultPatch(existing, productionFileSet, presetExt) {
|
|
|
70
70
|
}
|
|
71
71
|
function updateDependencies(tree, options) {
|
|
72
72
|
const { jestVersion, nxVersion } = (0, versions_1.versions)(tree);
|
|
73
|
-
// jest
|
|
74
|
-
//
|
|
75
|
-
//
|
|
73
|
+
// jest-resolve depends on unrs-resolver, and from jest 30.5.0 it pins a
|
|
74
|
+
// jest-haste-map that depends on @parcel/watcher. Neither build is needed:
|
|
75
|
+
// the binding has a fallback and the watcher ships prebuilt.
|
|
76
76
|
(0, internal_1.acknowledgeBuildScripts)(tree, (0, devkit_1.detectPackageManager)(tree.root), {
|
|
77
|
+
'@parcel/watcher': false,
|
|
77
78
|
'unrs-resolver': false,
|
|
78
79
|
});
|
|
79
80
|
return (0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
|
|
@@ -171,14 +171,19 @@ async function buildJestTargets(rawConfig, needsDtsInputs, configFilePath, proje
|
|
|
171
171
|
const rootDir = rawConfig.rootDir
|
|
172
172
|
? (0, node_path_1.resolve)((0, node_path_1.dirname)(absConfigFilePath), rawConfig.rootDir)
|
|
173
173
|
: (0, node_path_1.resolve)(context.workspaceRoot, projectRoot);
|
|
174
|
-
|
|
174
|
+
let cache = (target.cache = true);
|
|
175
175
|
const inputs = (target.inputs = await getInputs(namedInputs, rawConfig, rootDir, projectRoot, context.workspaceRoot, presetCache, needsDtsInputs, useJestResolver));
|
|
176
176
|
let metadata;
|
|
177
177
|
const groupName = options?.ciGroupName ?? (0, internal_1.deriveGroupNameFromTarget)(options?.ciTargetName);
|
|
178
178
|
if (disableJestRuntime) {
|
|
179
|
-
const outputs
|
|
180
|
-
|
|
181
|
-
|
|
179
|
+
const { outputs, cacheable } = getOutputs(projectRoot,
|
|
180
|
+
// Mirrors jest-config `normalize`: resolve against rootDir after the
|
|
181
|
+
// `<rootDir>` token, leaving an absolute path untouched.
|
|
182
|
+
rawConfig.coverageDirectory
|
|
183
|
+
? (0, node_path_1.resolve)(rootDir, replaceRootDirInPath(rootDir, rawConfig.coverageDirectory))
|
|
184
|
+
: undefined, undefined, context);
|
|
185
|
+
target.outputs = outputs;
|
|
186
|
+
cache = target.cache = cacheable;
|
|
182
187
|
if (options?.ciTargetName) {
|
|
183
188
|
const { specs, testMatch } = await getTestPaths(projectRoot, rawConfig, rootDir, context, presetCache);
|
|
184
189
|
const targetGroup = [];
|
|
@@ -237,7 +242,7 @@ async function buildJestTargets(rawConfig, needsDtsInputs, configFilePath, proje
|
|
|
237
242
|
if (targetGroup.length > 0) {
|
|
238
243
|
targets[options.ciTargetName] = {
|
|
239
244
|
executor: 'nx:noop',
|
|
240
|
-
cache
|
|
245
|
+
cache,
|
|
241
246
|
inputs,
|
|
242
247
|
outputs,
|
|
243
248
|
dependsOn,
|
|
@@ -266,13 +271,17 @@ async function buildJestTargets(rawConfig, needsDtsInputs, configFilePath, proje
|
|
|
266
271
|
config = await readConfig({
|
|
267
272
|
_: [],
|
|
268
273
|
$0: undefined,
|
|
269
|
-
},
|
|
274
|
+
},
|
|
275
|
+
// Jest resolves a relative rootDir only when it reads the file itself.
|
|
276
|
+
rawConfig.rootDir ? { ...rawConfig, rootDir } : rawConfig, undefined, (0, node_path_1.dirname)(absConfigFilePath));
|
|
270
277
|
}
|
|
271
278
|
catch (e) {
|
|
272
279
|
console.error(e);
|
|
273
280
|
throw e;
|
|
274
281
|
}
|
|
275
|
-
const outputs
|
|
282
|
+
const { outputs, cacheable } = getOutputs(projectRoot, config.globalConfig?.coverageDirectory, config.globalConfig?.outputFile, context);
|
|
283
|
+
target.outputs = outputs;
|
|
284
|
+
cache = target.cache = cacheable;
|
|
276
285
|
if (options?.ciTargetName) {
|
|
277
286
|
// nx-ignore-next-line
|
|
278
287
|
const { default: Runtime } = requireJestUtil('jest-runtime', projectRoot, context.workspaceRoot);
|
|
@@ -342,7 +351,7 @@ async function buildJestTargets(rawConfig, needsDtsInputs, configFilePath, proje
|
|
|
342
351
|
}
|
|
343
352
|
targets[options.ciTargetName] = {
|
|
344
353
|
executor: 'nx:noop',
|
|
345
|
-
cache
|
|
354
|
+
cache,
|
|
346
355
|
inputs,
|
|
347
356
|
outputs,
|
|
348
357
|
dependsOn,
|
|
@@ -534,19 +543,22 @@ function getOutputs(projectRoot, coverageDirectory, outputFile, context) {
|
|
|
534
543
|
function getOutput(path) {
|
|
535
544
|
const relativePath = (0, node_path_1.relative)((0, node_path_1.join)(context.workspaceRoot, projectRoot), path);
|
|
536
545
|
if (relativePath.startsWith('..')) {
|
|
537
|
-
return (0,
|
|
546
|
+
return (0, devkit_1.joinPathFragments)('{workspaceRoot}', projectRoot, relativePath);
|
|
538
547
|
}
|
|
539
548
|
else {
|
|
540
|
-
return (0,
|
|
549
|
+
return (0, devkit_1.joinPathFragments)('{projectRoot}', relativePath);
|
|
541
550
|
}
|
|
542
551
|
}
|
|
543
|
-
const
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
552
|
+
const outputPaths = [coverageDirectory, outputFile].filter((path) => !!path);
|
|
553
|
+
// Outputs outside the workspace cannot be cached: keep the target runnable
|
|
554
|
+
// but uncached.
|
|
555
|
+
const cacheable = outputPaths.every((path) => !isPathOutside((0, node_path_1.relative)(context.workspaceRoot, path)));
|
|
556
|
+
return { outputs: cacheable ? outputPaths.map(getOutput) : [], cacheable };
|
|
557
|
+
}
|
|
558
|
+
function isPathOutside(relativePath) {
|
|
559
|
+
return (relativePath === '..' ||
|
|
560
|
+
relativePath.startsWith(`..${node_path_1.sep}`) ||
|
|
561
|
+
(0, node_path_1.isAbsolute)(relativePath));
|
|
550
562
|
}
|
|
551
563
|
function normalizeOptions(options) {
|
|
552
564
|
options ??= {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/jest",
|
|
3
|
-
"version": "23.3.0-beta.
|
|
3
|
+
"version": "23.3.0-beta.4",
|
|
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.3.0-beta.
|
|
121
|
-
"@nx/js": "23.3.0-beta.
|
|
120
|
+
"@nx/devkit": "23.3.0-beta.4",
|
|
121
|
+
"@nx/js": "23.3.0-beta.4"
|
|
122
122
|
},
|
|
123
123
|
"devDependencies": {
|
|
124
|
-
"nx": "23.3.0-beta.
|
|
124
|
+
"nx": "23.3.0-beta.4"
|
|
125
125
|
},
|
|
126
126
|
"publishConfig": {
|
|
127
127
|
"access": "public"
|