@nx/jest 21.2.3 → 21.2.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/jest",
3
- "version": "21.2.3",
3
+ "version": "21.2.4",
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": "21.2.3",
41
- "@nx/js": "21.2.3",
40
+ "@nx/devkit": "21.2.4",
41
+ "@nx/js": "21.2.4",
42
42
  "@phenomnomnominal/tsquery": "~5.0.1",
43
43
  "identity-obj-proxy": "3.0.0",
44
44
  "jest-config": "^29.4.1",
@@ -176,7 +176,7 @@ async function buildJestTargets(configFilePath, projectRoot, options, context, p
176
176
  ? (0, path_1.join)(context.workspaceRoot, projectRoot, rawConfig.coverageDirectory)
177
177
  : undefined, undefined, context));
178
178
  if (options?.ciTargetName) {
179
- const testPaths = await getTestPaths(projectRoot, rawConfig, absConfigFilePath, context, presetCache);
179
+ const { specs, testMatch } = await getTestPaths(projectRoot, rawConfig, absConfigFilePath, context, presetCache);
180
180
  const targetGroup = [];
181
181
  const dependsOn = [];
182
182
  metadata = {
@@ -185,8 +185,18 @@ async function buildJestTargets(configFilePath, projectRoot, options, context, p
185
185
  },
186
186
  };
187
187
  const specIgnoreRegexes = rawConfig.testPathIgnorePatterns?.map((p) => new RegExp(replaceRootDirInPath(projectRoot, p)));
188
- for (const testPath of testPaths) {
188
+ for (const testPath of specs) {
189
189
  const relativePath = (0, devkit_1.normalizePath)((0, path_1.relative)((0, path_1.join)(context.workspaceRoot, projectRoot), testPath));
190
+ if (relativePath.includes('../')) {
191
+ throw new Error('@nx/jest/plugin attempted to run tests outside of the project root. This is not supported and should not happen. Please open an issue at https://github.com/nrwl/nx/issues/new/choose with the following information:\n\n' +
192
+ `\n\n${JSON.stringify({
193
+ projectRoot,
194
+ relativePath,
195
+ specs,
196
+ context,
197
+ testMatch,
198
+ }, null, 2)}`);
199
+ }
190
200
  if (specIgnoreRegexes?.some((regex) => regex.test(relativePath))) {
191
201
  continue;
192
202
  }
@@ -300,6 +310,15 @@ async function buildJestTargets(configFilePath, projectRoot, options, context, p
300
310
  targetGroup.push(options.ciTargetName);
301
311
  for (const testPath of testPaths) {
302
312
  const relativePath = (0, devkit_1.normalizePath)((0, path_1.relative)((0, path_1.join)(context.workspaceRoot, projectRoot), testPath));
313
+ if (relativePath.includes('../')) {
314
+ throw new Error('@nx/jest/plugin attempted to run tests outside of the project root. This is not supported and should not happen. Please open an issue at https://github.com/nrwl/nx/issues/new/choose with the following information:\n\n' +
315
+ `\n\n${JSON.stringify({
316
+ projectRoot,
317
+ relativePath,
318
+ testPaths,
319
+ context,
320
+ }, null, 2)}`);
321
+ }
303
322
  const targetName = `${options.ciTargetName}--${relativePath}`;
304
323
  dependsOn.push(targetName);
305
324
  targets[targetName] = {
@@ -468,7 +487,7 @@ async function getTestPaths(projectRoot, rawConfig, absConfigFilePath, context,
468
487
  : [new RegExp(rawConfig.testRegex)];
469
488
  paths = paths.filter((path) => testRegexes.some((r) => r.test(path)));
470
489
  }
471
- return paths;
490
+ return { specs: paths, testMatch };
472
491
  }
473
492
  async function getJestOption(rawConfig, absConfigFilePath, optionName, presetCache) {
474
493
  if (rawConfig[optionName])