@nx/jest 21.0.0-beta.10 → 21.0.0-beta.12

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/index.d.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  import { configurationGenerator } from './src/generators/configuration/configuration';
2
2
  export { configurationGenerator };
3
- /** @deprecated Use `configurationGenerator` instead. */
3
+ /**
4
+ * @deprecated Use `configurationGenerator` instead. It will be removed in Nx v22.
5
+ */
4
6
  export declare const jestProjectGenerator: typeof configurationGenerator;
5
7
  export { addPropertyToJestConfig, removePropertyFromJestConfig, } from './src/utils/config/update-config';
6
8
  export { jestConfigObjectAst } from './src/utils/config/functions';
package/index.js CHANGED
@@ -4,7 +4,9 @@ exports.getJestProjectsAsync = exports.jestInitGenerator = exports.jestConfigObj
4
4
  const configuration_1 = require("./src/generators/configuration/configuration");
5
5
  Object.defineProperty(exports, "configurationGenerator", { enumerable: true, get: function () { return configuration_1.configurationGenerator; } });
6
6
  // Exported for backwards compatibility in case a plugin is using the old name.
7
- /** @deprecated Use `configurationGenerator` instead. */
7
+ /**
8
+ * @deprecated Use `configurationGenerator` instead. It will be removed in Nx v22.
9
+ */
8
10
  exports.jestProjectGenerator = configuration_1.configurationGenerator;
9
11
  var update_config_1 = require("./src/utils/config/update-config");
10
12
  Object.defineProperty(exports, "addPropertyToJestConfig", { enumerable: true, get: function () { return update_config_1.addPropertyToJestConfig; } });
package/migrations.json CHANGED
@@ -11,6 +11,11 @@
11
11
  "version": "21.0.0-beta.9",
12
12
  "description": "Replace usage of `getJestProjects` with `getJestProjectsAsync`.",
13
13
  "implementation": "./src/migrations/update-21-0-0/replace-getJestProjects-with-getJestProjectsAsync"
14
+ },
15
+ "remove-tsconfig-option-from-jest-executor": {
16
+ "version": "21.0.0-beta.10",
17
+ "description": "Remove the previously deprecated and unused `tsConfig` option from the `@nx/jest:jest` executor.",
18
+ "implementation": "./src/migrations/update-21-0-0/remove-tsconfig-option-from-jest-executor"
14
19
  }
15
20
  },
16
21
  "packageJsonUpdates": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/jest",
3
- "version": "21.0.0-beta.10",
3
+ "version": "21.0.0-beta.12",
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.0.0-beta.10",
41
- "@nx/js": "21.0.0-beta.10",
40
+ "@nx/devkit": "21.0.0-beta.12",
41
+ "@nx/js": "21.0.0-beta.12",
42
42
  "@phenomnomnominal/tsquery": "~5.0.1",
43
43
  "identity-obj-proxy": "3.0.0",
44
44
  "jest-config": "^29.4.1",
@@ -6,10 +6,6 @@ export interface JestExecutorOptions {
6
6
  detectLeaks?: boolean;
7
7
  jestConfig: string;
8
8
  testFile?: string;
9
- /**
10
- * @deprecated set in the jest config file instead
11
- **/
12
- setupFile?: string;
13
9
  bail?: boolean | number;
14
10
  ci?: boolean;
15
11
  color?: boolean;
@@ -41,4 +37,11 @@ export interface JestExecutorOptions {
41
37
  watchAll?: boolean;
42
38
  testLocationInResults?: boolean;
43
39
  testTimeout?: number;
40
+
41
+ /**
42
+ * @deprecated Use the `setupFilesAfterEnv` option in the Jest configuration
43
+ * file instead. See https://jestjs.io/docs/configuration#setupfilesafterenv-array.
44
+ * It will be removed in Nx v22.
45
+ */
46
+ setupFile?: string;
44
47
  }
@@ -59,15 +59,10 @@
59
59
  "index": 0
60
60
  }
61
61
  },
62
- "tsConfig": {
63
- "description": "The name of the Typescript configuration file.",
64
- "type": "string",
65
- "x-deprecated": "Use the ts-jest configuration options in the jest config file instead."
66
- },
67
62
  "setupFile": {
68
63
  "description": "The name of a setup file used by Jest.",
69
64
  "type": "string",
70
- "x-deprecated": "Use the setupFilesAfterEnv option in the jest config file. https://jestjs.io/docs/en/configuration#setupfilesafterenv-array"
65
+ "x-deprecated": "Use the `setupFilesAfterEnv` option in the Jest configuration file instead. See https://jestjs.io/docs/configuration#setupfilesafterenv-array. It will be removed in Nx v22."
71
66
  },
72
67
  "bail": {
73
68
  "alias": "b",
@@ -2,10 +2,6 @@ export interface JestProjectSchema {
2
2
  project: string;
3
3
  targetName?: string;
4
4
  supportTsx?: boolean;
5
- /**
6
- * @deprecated use setupFile instead
7
- */
8
- skipSetupFile?: boolean;
9
5
  setupFile?:
10
6
  | 'angular'
11
7
  | 'web-components'
@@ -14,12 +10,7 @@ export interface JestProjectSchema {
14
10
  | 'none';
15
11
  skipSerializers?: boolean;
16
12
  testEnvironment?: 'node' | 'jsdom' | 'none';
17
- /**
18
- * @deprecated use compiler: "babel" instead
19
- */
20
- babelJest?: boolean;
21
13
  skipFormat?: boolean;
22
-
23
14
  addPlugin?: boolean;
24
15
  compiler?: 'tsc' | 'babel' | 'swc';
25
16
  skipPackageJson?: boolean;
@@ -30,6 +21,15 @@ export interface JestProjectSchema {
30
21
  * @internal
31
22
  */
32
23
  addExplicitTargets?: boolean;
24
+
25
+ /**
26
+ * @deprecated Use the `compiler` option instead. It will be removed in Nx v22.
27
+ */
28
+ babelJest?: boolean;
29
+ /**
30
+ * @deprecated Use the `setupFile` option instead. It will be removed in Nx v22.
31
+ */
32
+ skipSetupFile?: boolean;
33
33
  }
34
34
 
35
35
  export type NormalizedJestProjectSchema = JestProjectSchema & {
@@ -18,7 +18,7 @@
18
18
  "type": "boolean",
19
19
  "description": "Skips the setup file required for angular.",
20
20
  "default": false,
21
- "x-deprecated": "Use `--setup-file` instead."
21
+ "x-deprecated": "Use the `setupFile` option instead. It will be removed in Nx v22."
22
22
  },
23
23
  "setupFile": {
24
24
  "type": "string",
@@ -55,7 +55,7 @@
55
55
  "type": "boolean",
56
56
  "alias": "babel-jest",
57
57
  "description": "Use `babel-jest` instead of `ts-jest`.",
58
- "x-deprecated": "Use `--compiler=babel` instead.",
58
+ "x-deprecated": "Use the `compiler` option instead. It will be removed in Nx v22.",
59
59
  "default": false
60
60
  },
61
61
  "skipFormat": {
@@ -0,0 +1,2 @@
1
+ import { type Tree } from '@nx/devkit';
2
+ export default function (tree: Tree): Promise<void>;
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = default_1;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
6
+ const EXECUTOR_TO_MIGRATE = '@nx/jest:jest';
7
+ async function default_1(tree) {
8
+ // update options from project configs
9
+ (0, executor_options_utils_1.forEachExecutorOptions)(tree, EXECUTOR_TO_MIGRATE, (options, project, target, configuration) => {
10
+ if (options.tsConfig === undefined) {
11
+ return;
12
+ }
13
+ const projectConfiguration = (0, devkit_1.readProjectConfiguration)(tree, project);
14
+ if (configuration) {
15
+ updateConfiguration(projectConfiguration.targets[target], configuration);
16
+ }
17
+ else {
18
+ updateOptions(projectConfiguration.targets[target]);
19
+ }
20
+ (0, devkit_1.updateProjectConfiguration)(tree, project, projectConfiguration);
21
+ });
22
+ // update options from nx.json target defaults
23
+ const nxJson = (0, devkit_1.readNxJson)(tree);
24
+ if (nxJson.targetDefaults) {
25
+ for (const [targetOrExecutor, targetConfig] of Object.entries(nxJson.targetDefaults)) {
26
+ if (targetOrExecutor !== EXECUTOR_TO_MIGRATE &&
27
+ targetConfig.executor !== EXECUTOR_TO_MIGRATE) {
28
+ continue;
29
+ }
30
+ if (targetConfig.options) {
31
+ updateOptions(targetConfig);
32
+ }
33
+ Object.keys(targetConfig.configurations ?? {}).forEach((config) => {
34
+ updateConfiguration(targetConfig, config);
35
+ });
36
+ if (!Object.keys(targetConfig).length ||
37
+ (Object.keys(targetConfig).length === 1 &&
38
+ Object.keys(targetConfig)[0] === 'executor')) {
39
+ delete nxJson.targetDefaults[targetOrExecutor];
40
+ }
41
+ if (!Object.keys(nxJson.targetDefaults).length) {
42
+ delete nxJson.targetDefaults;
43
+ }
44
+ }
45
+ (0, devkit_1.updateNxJson)(tree, nxJson);
46
+ }
47
+ await (0, devkit_1.formatFiles)(tree);
48
+ }
49
+ function updateOptions(target) {
50
+ delete target.options.tsConfig;
51
+ if (!Object.keys(target.options).length) {
52
+ delete target.options;
53
+ }
54
+ }
55
+ function updateConfiguration(target, configuration) {
56
+ delete target.configurations[configuration].tsConfig;
57
+ if (!Object.keys(target.configurations[configuration]).length &&
58
+ (!target.defaultConfiguration ||
59
+ target.defaultConfiguration !== configuration)) {
60
+ delete target.configurations[configuration];
61
+ }
62
+ if (!Object.keys(target.configurations).length) {
63
+ delete target.configurations;
64
+ }
65
+ }