@nx/jest 23.3.0-pr.37068.f95e11e → 23.3.0-rc.0
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/README.md +1 -1
- package/dist/src/generators/init/init.js +4 -3
- package/dist/src/plugins/plugin.js +32 -18
- package/package.json +5 -5
- package/readme-template.md +18 -0
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
[](<>)
|
|
13
13
|
[](http://commitizen.github.io/cz-cli/)
|
|
14
14
|
[](https://go.nx.dev/community)
|
|
15
|
-
[](https://nx.dev/nx-cloud)
|
|
16
16
|
|
|
17
17
|
</div>
|
|
18
18
|
|
|
@@ -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, {}, {
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createNodesV2 = exports.createNodes = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
4
5
|
const internal_1 = require("@nx/devkit/internal");
|
|
5
6
|
const devkit_1 = require("@nx/devkit");
|
|
6
7
|
const minimatch_1 = require("minimatch");
|
|
7
8
|
const node_fs_1 = require("node:fs");
|
|
8
9
|
const node_path_1 = require("node:path");
|
|
10
|
+
const posix = tslib_1.__importStar(require("node:path/posix"));
|
|
9
11
|
const js_1 = require("@nx/js");
|
|
10
12
|
const internal_2 = require("@nx/js/internal");
|
|
11
13
|
const versions_1 = require("../utils/versions");
|
|
@@ -171,14 +173,19 @@ async function buildJestTargets(rawConfig, needsDtsInputs, configFilePath, proje
|
|
|
171
173
|
const rootDir = rawConfig.rootDir
|
|
172
174
|
? (0, node_path_1.resolve)((0, node_path_1.dirname)(absConfigFilePath), rawConfig.rootDir)
|
|
173
175
|
: (0, node_path_1.resolve)(context.workspaceRoot, projectRoot);
|
|
174
|
-
|
|
176
|
+
let cache = (target.cache = true);
|
|
175
177
|
const inputs = (target.inputs = await getInputs(namedInputs, rawConfig, rootDir, projectRoot, context.workspaceRoot, presetCache, needsDtsInputs, useJestResolver));
|
|
176
178
|
let metadata;
|
|
177
179
|
const groupName = options?.ciGroupName ?? (0, internal_1.deriveGroupNameFromTarget)(options?.ciTargetName);
|
|
178
180
|
if (disableJestRuntime) {
|
|
179
|
-
const outputs
|
|
180
|
-
|
|
181
|
-
|
|
181
|
+
const { outputs, cacheable } = getOutputs(projectRoot,
|
|
182
|
+
// Mirrors jest-config `normalize`: resolve against rootDir after the
|
|
183
|
+
// `<rootDir>` token, leaving an absolute path untouched.
|
|
184
|
+
rawConfig.coverageDirectory
|
|
185
|
+
? (0, node_path_1.resolve)(rootDir, replaceRootDirInPath(rootDir, rawConfig.coverageDirectory))
|
|
186
|
+
: undefined, undefined, context);
|
|
187
|
+
target.outputs = outputs;
|
|
188
|
+
cache = target.cache = cacheable;
|
|
182
189
|
if (options?.ciTargetName) {
|
|
183
190
|
const { specs, testMatch } = await getTestPaths(projectRoot, rawConfig, rootDir, context, presetCache);
|
|
184
191
|
const targetGroup = [];
|
|
@@ -237,7 +244,7 @@ async function buildJestTargets(rawConfig, needsDtsInputs, configFilePath, proje
|
|
|
237
244
|
if (targetGroup.length > 0) {
|
|
238
245
|
targets[options.ciTargetName] = {
|
|
239
246
|
executor: 'nx:noop',
|
|
240
|
-
cache
|
|
247
|
+
cache,
|
|
241
248
|
inputs,
|
|
242
249
|
outputs,
|
|
243
250
|
dependsOn,
|
|
@@ -266,13 +273,17 @@ async function buildJestTargets(rawConfig, needsDtsInputs, configFilePath, proje
|
|
|
266
273
|
config = await readConfig({
|
|
267
274
|
_: [],
|
|
268
275
|
$0: undefined,
|
|
269
|
-
},
|
|
276
|
+
},
|
|
277
|
+
// Jest resolves a relative rootDir only when it reads the file itself.
|
|
278
|
+
rawConfig.rootDir ? { ...rawConfig, rootDir } : rawConfig, undefined, (0, node_path_1.dirname)(absConfigFilePath));
|
|
270
279
|
}
|
|
271
280
|
catch (e) {
|
|
272
281
|
console.error(e);
|
|
273
282
|
throw e;
|
|
274
283
|
}
|
|
275
|
-
const outputs
|
|
284
|
+
const { outputs, cacheable } = getOutputs(projectRoot, config.globalConfig?.coverageDirectory, config.globalConfig?.outputFile, context);
|
|
285
|
+
target.outputs = outputs;
|
|
286
|
+
cache = target.cache = cacheable;
|
|
276
287
|
if (options?.ciTargetName) {
|
|
277
288
|
// nx-ignore-next-line
|
|
278
289
|
const { default: Runtime } = requireJestUtil('jest-runtime', projectRoot, context.workspaceRoot);
|
|
@@ -342,7 +353,7 @@ async function buildJestTargets(rawConfig, needsDtsInputs, configFilePath, proje
|
|
|
342
353
|
}
|
|
343
354
|
targets[options.ciTargetName] = {
|
|
344
355
|
executor: 'nx:noop',
|
|
345
|
-
cache
|
|
356
|
+
cache,
|
|
346
357
|
inputs,
|
|
347
358
|
outputs,
|
|
348
359
|
dependsOn,
|
|
@@ -534,19 +545,22 @@ function getOutputs(projectRoot, coverageDirectory, outputFile, context) {
|
|
|
534
545
|
function getOutput(path) {
|
|
535
546
|
const relativePath = (0, node_path_1.relative)((0, node_path_1.join)(context.workspaceRoot, projectRoot), path);
|
|
536
547
|
if (relativePath.startsWith('..')) {
|
|
537
|
-
return (0,
|
|
548
|
+
return (0, devkit_1.joinPathFragments)('{workspaceRoot}', projectRoot, relativePath);
|
|
538
549
|
}
|
|
539
550
|
else {
|
|
540
|
-
return (0,
|
|
551
|
+
return (0, devkit_1.joinPathFragments)('{projectRoot}', relativePath);
|
|
541
552
|
}
|
|
542
553
|
}
|
|
543
|
-
const
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
554
|
+
const outputPaths = [coverageDirectory, outputFile].filter((path) => !!path);
|
|
555
|
+
// Outputs outside the workspace cannot be cached: keep the target runnable
|
|
556
|
+
// but uncached.
|
|
557
|
+
const cacheable = outputPaths.every((path) => !isPathOutside((0, node_path_1.relative)(context.workspaceRoot, path)));
|
|
558
|
+
return { outputs: cacheable ? outputPaths.map(getOutput) : [], cacheable };
|
|
559
|
+
}
|
|
560
|
+
function isPathOutside(relativePath) {
|
|
561
|
+
return (relativePath === '..' ||
|
|
562
|
+
relativePath.startsWith(`..${node_path_1.sep}`) ||
|
|
563
|
+
(0, node_path_1.isAbsolute)(relativePath));
|
|
550
564
|
}
|
|
551
565
|
function normalizeOptions(options) {
|
|
552
566
|
options ??= {};
|
|
@@ -587,7 +601,7 @@ async function getTestPaths(projectRoot, rawConfig, rootDir, context, presetCach
|
|
|
587
601
|
// Default copied from https://github.com/jestjs/jest/blob/d1a2ed7/packages/jest-config/src/Defaults.ts#L84
|
|
588
602
|
'**/__tests__/**/*.?([mc])[jt]s?(x)',
|
|
589
603
|
'**/?(*.)+(spec|test).?([mc])[jt]s?(x)',
|
|
590
|
-
]).map((pattern) =>
|
|
604
|
+
]).map((pattern) => posix.join(projectRoot, pattern)), []);
|
|
591
605
|
const testRegex = await getJestOption(rawConfig, rootDir, 'testRegex', presetCache);
|
|
592
606
|
if (testRegex) {
|
|
593
607
|
const testRegexes = Array.isArray(rawConfig.testRegex)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/jest",
|
|
3
|
-
"version": "23.3.0-
|
|
3
|
+
"version": "23.3.0-rc.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"files": [
|
|
@@ -105,6 +105,8 @@
|
|
|
105
105
|
"dependencies": {
|
|
106
106
|
"@jest/reporters": "^30.0.2",
|
|
107
107
|
"@jest/test-result": "^30.0.2",
|
|
108
|
+
"@nx/devkit": "23.3.0-rc.0",
|
|
109
|
+
"@nx/js": "23.3.0-rc.0",
|
|
108
110
|
"@phenomnomnominal/tsquery": "~6.2.0",
|
|
109
111
|
"identity-obj-proxy": "3.0.0",
|
|
110
112
|
"jest-config": "^30.0.2",
|
|
@@ -116,12 +118,10 @@
|
|
|
116
118
|
"resolve.exports": "2.0.3",
|
|
117
119
|
"semver": "^7.6.3",
|
|
118
120
|
"tslib": "^2.3.0",
|
|
119
|
-
"yargs-parser": "21.1.1"
|
|
120
|
-
"@nx/devkit": "23.3.0-pr.37068.f95e11e",
|
|
121
|
-
"@nx/js": "23.3.0-pr.37068.f95e11e"
|
|
121
|
+
"yargs-parser": "21.1.1"
|
|
122
122
|
},
|
|
123
123
|
"devDependencies": {
|
|
124
|
-
"nx": "23.3.0-
|
|
124
|
+
"nx": "23.3.0-rc.0"
|
|
125
125
|
},
|
|
126
126
|
"publishConfig": {
|
|
127
127
|
"access": "public"
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<p style="text-align: center;">
|
|
2
|
+
<picture>
|
|
3
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-dark.svg">
|
|
4
|
+
<img alt="Nx - Smart Monorepos · Fast Builds" src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-light.svg" width="100%">
|
|
5
|
+
</picture>
|
|
6
|
+
</p>
|
|
7
|
+
|
|
8
|
+
{{links}}
|
|
9
|
+
|
|
10
|
+
<hr>
|
|
11
|
+
|
|
12
|
+
# Nx: Smart Monorepos · Fast Builds
|
|
13
|
+
|
|
14
|
+
Get to green PRs in half the time. Nx optimizes your builds, scales your CI, and fixes failed PRs. Built for developers and AI agents.
|
|
15
|
+
|
|
16
|
+
This package is a [Jest plugin for Nx](https://nx.dev/jest/overview).
|
|
17
|
+
|
|
18
|
+
{{content}}
|