@nx/jest 19.8.0 → 20.0.0-beta.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/jest",
3
- "version": "19.8.0",
3
+ "version": "20.0.0-beta.0",
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.8.0",
41
- "@nx/js": "19.8.0",
40
+ "@nx/devkit": "20.0.0-beta.0",
41
+ "@nx/js": "20.0.0-beta.0",
42
42
  "@phenomnomnominal/tsquery": "~5.0.1",
43
43
  "chalk": "^4.1.0",
44
44
  "identity-obj-proxy": "3.0.0",
@@ -50,7 +50,7 @@
50
50
  "semver": "^7.5.3",
51
51
  "tslib": "^2.3.0",
52
52
  "yargs-parser": "21.1.1",
53
- "@nrwl/jest": "19.8.0"
53
+ "@nrwl/jest": "20.0.0-beta.0"
54
54
  },
55
55
  "publishConfig": {
56
56
  "access": "public"
@@ -1,3 +1,3 @@
1
- import { NormalizedJestProjectSchema } from '../schema';
2
- import { Tree } from '@nx/devkit';
1
+ import { type Tree } from '@nx/devkit';
2
+ import type { NormalizedJestProjectSchema } from '../schema';
3
3
  export declare function updateTsConfig(host: Tree, options: NormalizedJestProjectSchema): void;
@@ -1,14 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.updateTsConfig = updateTsConfig;
4
- const path_1 = require("path");
5
4
  const devkit_1 = require("@nx/devkit");
6
5
  function updateTsConfig(host, options) {
7
- const projectConfig = (0, devkit_1.readProjectConfiguration)(host, options.project);
8
- if (!host.exists((0, path_1.join)(projectConfig.root, 'tsconfig.json'))) {
9
- throw new Error(`Expected ${(0, path_1.join)(projectConfig.root, 'tsconfig.json')} to exist. Please create one.`);
6
+ const { root, projectType } = (0, devkit_1.readProjectConfiguration)(host, options.project);
7
+ if (!host.exists((0, devkit_1.joinPathFragments)(root, 'tsconfig.json'))) {
8
+ throw new Error(`Expected ${(0, devkit_1.joinPathFragments)(root, 'tsconfig.json')} to exist. Please create one.`);
10
9
  }
11
- (0, devkit_1.updateJson)(host, (0, path_1.join)(projectConfig.root, 'tsconfig.json'), (json) => {
10
+ (0, devkit_1.updateJson)(host, (0, devkit_1.joinPathFragments)(root, 'tsconfig.json'), (json) => {
12
11
  if (json.references &&
13
12
  !json.references.some((r) => r.path === './tsconfig.spec.json')) {
14
13
  json.references.push({
@@ -17,4 +16,30 @@ function updateTsConfig(host, options) {
17
16
  }
18
17
  return json;
19
18
  });
19
+ // fall-back runtime tsconfig file path in case the user didn't provide one
20
+ let runtimeTsconfigPath = (0, devkit_1.joinPathFragments)(root, projectType === 'application' ? 'tsconfig.app.json' : 'tsconfig.lib.json');
21
+ if (options.runtimeTsconfigFileName) {
22
+ runtimeTsconfigPath = (0, devkit_1.joinPathFragments)(root, options.runtimeTsconfigFileName);
23
+ if (!host.exists(runtimeTsconfigPath)) {
24
+ // the user provided a runtimeTsconfigFileName that doesn't exist, so we throw an error
25
+ throw new Error(`Cannot find the provided runtimeTsConfigFileName ("${options.runtimeTsconfigFileName}") at the project root "${root}".`);
26
+ }
27
+ }
28
+ if (host.exists(runtimeTsconfigPath)) {
29
+ (0, devkit_1.updateJson)(host, runtimeTsconfigPath, (json) => {
30
+ const uniqueExclude = new Set([
31
+ ...(json.exclude || []),
32
+ options.js ? 'jest.config.js' : 'jest.config.ts',
33
+ 'src/**/*.spec.ts',
34
+ 'src/**/*.test.ts',
35
+ ...(options.js ? ['src/**/*.spec.js', 'src/**/*.test.js'] : []),
36
+ ]);
37
+ json.exclude = [...uniqueExclude];
38
+ return json;
39
+ });
40
+ }
41
+ else {
42
+ devkit_1.logger.warn(`Couldn't find a runtime tsconfig file at ${runtimeTsconfigPath} to exclude the test files from. ` +
43
+ `If you're using a different filename for your runtime tsconfig, please provide it with the '--runtimeTsconfigFileName' flag.`);
44
+ }
20
45
  }
@@ -19,6 +19,7 @@ export interface JestProjectSchema {
19
19
  compiler?: 'tsc' | 'babel' | 'swc';
20
20
  skipPackageJson?: boolean;
21
21
  js?: boolean;
22
+ runtimeTsconfigFileName?: string;
22
23
 
23
24
  /**
24
25
  * @internal
@@ -74,6 +74,10 @@
74
74
  "type": "boolean",
75
75
  "default": false,
76
76
  "description": "Use JavaScript instead of TypeScript for config files"
77
+ },
78
+ "runtimeTsconfigFileName": {
79
+ "type": "string",
80
+ "description": "The name of the project's tsconfig file that includes the runtime source files. If not provided, it will default to `tsconfig.lib.json` for libraries and `tsconfig.app.json` for applications."
77
81
  }
78
82
  },
79
83
  "required": []