@nx/jest 23.0.0-pr.35465.2bc2643 → 23.0.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.
Files changed (145) hide show
  1. package/{index.d.ts → dist/index.d.ts} +0 -5
  2. package/{index.js → dist/index.js} +1 -6
  3. package/dist/internal.d.ts +2 -0
  4. package/dist/internal.js +13 -0
  5. package/{plugin.d.ts → dist/plugin.d.ts} +0 -1
  6. package/dist/plugins/resolver.d.ts +1 -0
  7. package/{plugins → dist/plugins}/resolver.js +1 -1
  8. package/{preset → dist/preset}/index.d.ts +0 -1
  9. package/{preset → dist/preset}/jest-preset.d.ts +0 -1
  10. package/{preset → dist/preset}/jest-preset.js +1 -0
  11. package/{preset.d.ts → dist/preset.d.ts} +0 -1
  12. package/{src → dist/src}/executors/jest/jest.impl.d.ts +0 -1
  13. package/{src → dist/src}/executors/jest/jest.impl.js +4 -12
  14. package/{src → dist/src}/executors/jest/schema.d.ts +0 -7
  15. package/{src → dist/src}/executors/jest/schema.json +1 -5
  16. package/{src → dist/src}/executors/jest/summary.d.ts +0 -1
  17. package/{src → dist/src}/generators/configuration/configuration.d.ts +0 -1
  18. package/{src → dist/src}/generators/configuration/configuration.js +24 -13
  19. package/{src → dist/src}/generators/configuration/lib/check-for-test-target.d.ts +0 -1
  20. package/{src → dist/src}/generators/configuration/lib/create-files.d.ts +0 -1
  21. package/{src → dist/src}/generators/configuration/lib/create-files.js +2 -2
  22. package/{src → dist/src}/generators/configuration/lib/create-jest-config.d.ts +0 -1
  23. package/{src → dist/src}/generators/configuration/lib/create-jest-config.js +2 -2
  24. package/{src → dist/src}/generators/configuration/lib/ensure-dependencies.d.ts +0 -1
  25. package/{src → dist/src}/generators/configuration/lib/ensure-dependencies.js +1 -1
  26. package/{src → dist/src}/generators/configuration/lib/update-tsconfig.d.ts +0 -1
  27. package/{src → dist/src}/generators/configuration/lib/update-tsconfig.js +2 -2
  28. package/{src → dist/src}/generators/configuration/lib/update-vscode-recommended-extensions.d.ts +0 -1
  29. package/{src → dist/src}/generators/configuration/lib/update-workspace.d.ts +0 -1
  30. package/{src → dist/src}/generators/configuration/schema.d.ts +0 -4
  31. package/{src → dist/src}/generators/configuration/schema.json +0 -6
  32. package/{src → dist/src}/generators/convert-to-inferred/convert-to-inferred.d.ts +0 -1
  33. package/{src → dist/src}/generators/convert-to-inferred/convert-to-inferred.js +15 -14
  34. package/{src → dist/src}/generators/init/init.d.ts +0 -1
  35. package/{src → dist/src}/generators/init/init.js +63 -26
  36. package/{src → dist/src}/generators/init/schema.json +1 -1
  37. package/{src → dist/src}/migrations/update-21-0-0/remove-tsconfig-option-from-jest-executor.d.ts +0 -1
  38. package/dist/src/migrations/update-21-0-0/remove-tsconfig-option-from-jest-executor.js +97 -0
  39. package/dist/src/migrations/update-21-0-0/remove-tsconfig-option-from-jest-executor.md +102 -0
  40. package/{src/migrations/update-20-0-0 → dist/src/migrations/update-21-0-0}/replace-getJestProjects-with-getJestProjectsAsync.d.ts +0 -1
  41. package/{src → dist/src}/migrations/update-21-0-0/replace-getJestProjects-with-getJestProjectsAsync.js +2 -2
  42. package/dist/src/migrations/update-21-0-0/replace-getJestProjects-with-getJestProjectsAsync.md +25 -0
  43. package/{src → dist/src}/migrations/update-21-3-0/rename-test-path-pattern.d.ts +0 -1
  44. package/{src → dist/src}/migrations/update-21-3-0/rename-test-path-pattern.js +27 -11
  45. package/dist/src/migrations/update-21-3-0/rename-test-path-pattern.md +147 -0
  46. package/{src → dist/src}/migrations/update-21-3-0/replace-removed-matcher-aliases.d.ts +0 -1
  47. package/dist/src/migrations/update-21-3-0/replace-removed-matcher-aliases.md +51 -0
  48. package/{src → dist/src}/migrations/update-22-2-0/convert-jest-config-to-cjs.d.ts +0 -1
  49. package/dist/src/migrations/update-22-2-0/convert-jest-config-to-cjs.md +33 -0
  50. package/dist/src/migrations/update-23-0-0/migrate-create-nodes-v2-to-create-nodes.d.ts +9 -0
  51. package/dist/src/migrations/update-23-0-0/migrate-create-nodes-v2-to-create-nodes.js +223 -0
  52. package/dist/src/migrations/update-23-0-0/migrate-create-nodes-v2-to-create-nodes.md +25 -0
  53. package/dist/src/migrations/update-23-0-0/migrate-jest-configuration-skip-setup-file.d.ts +2 -0
  54. package/dist/src/migrations/update-23-0-0/migrate-jest-configuration-skip-setup-file.js +62 -0
  55. package/dist/src/migrations/update-23-0-0/migrate-jest-configuration-skip-setup-file.md +91 -0
  56. package/dist/src/migrations/update-23-0-0/migrate-jest-executor-setup-file.d.ts +2 -0
  57. package/dist/src/migrations/update-23-0-0/migrate-jest-executor-setup-file.js +476 -0
  58. package/dist/src/migrations/update-23-0-0/migrate-jest-executor-setup-file.md +169 -0
  59. package/dist/src/migrations/update-23-0-0/rewrite-internal-subpath-imports.d.ts +3 -0
  60. package/dist/src/migrations/update-23-0-0/rewrite-internal-subpath-imports.js +201 -0
  61. package/dist/src/migrations/update-23-0-0/rewrite-jest-project-generator.d.ts +3 -0
  62. package/dist/src/migrations/update-23-0-0/rewrite-jest-project-generator.js +121 -0
  63. package/dist/src/migrations/update-23-0-0/update-snapshot-guide-link.d.ts +2 -0
  64. package/dist/src/migrations/update-23-0-0/update-snapshot-guide-link.js +28 -0
  65. package/dist/src/migrations/update-23-0-0/update-snapshot-guide-link.md +21 -0
  66. package/{src → dist/src}/plugins/plugin.d.ts +3 -4
  67. package/{src → dist/src}/plugins/plugin.js +18 -25
  68. package/dist/src/utils/assert-supported-jest-version.d.ts +2 -0
  69. package/dist/src/utils/assert-supported-jest-version.js +11 -0
  70. package/{src → dist/src}/utils/ast-utils.d.ts +0 -1
  71. package/{src → dist/src}/utils/config/config-file.d.ts +0 -1
  72. package/{src → dist/src}/utils/config/functions.d.ts +0 -1
  73. package/{src → dist/src}/utils/config/functions.js +7 -7
  74. package/{src → dist/src}/utils/config/get-jest-projects.d.ts +0 -1
  75. package/{src → dist/src}/utils/config/get-jest-projects.js +2 -2
  76. package/{src → dist/src}/utils/config/update-config.d.ts +0 -1
  77. package/dist/src/utils/deprecation.d.ts +3 -0
  78. package/dist/src/utils/deprecation.js +15 -0
  79. package/{src → dist/src}/utils/versions.d.ts +13 -3
  80. package/{src → dist/src}/utils/versions.js +37 -51
  81. package/executors.json +3 -3
  82. package/generators.json +6 -6
  83. package/migrations.json +70 -12
  84. package/package.json +78 -11
  85. package/index.d.ts.map +0 -1
  86. package/plugin.d.ts.map +0 -1
  87. package/plugins/resolver.d.ts +0 -2
  88. package/plugins/resolver.d.ts.map +0 -1
  89. package/preset/index.d.ts.map +0 -1
  90. package/preset/jest-preset.d.ts.map +0 -1
  91. package/preset.d.ts.map +0 -1
  92. package/src/executors/jest/jest.impl.d.ts.map +0 -1
  93. package/src/executors/jest/summary.d.ts.map +0 -1
  94. package/src/generators/configuration/configuration.d.ts.map +0 -1
  95. package/src/generators/configuration/lib/check-for-test-target.d.ts.map +0 -1
  96. package/src/generators/configuration/lib/create-files.d.ts.map +0 -1
  97. package/src/generators/configuration/lib/create-jest-config.d.ts.map +0 -1
  98. package/src/generators/configuration/lib/ensure-dependencies.d.ts.map +0 -1
  99. package/src/generators/configuration/lib/update-tsconfig.d.ts.map +0 -1
  100. package/src/generators/configuration/lib/update-vscode-recommended-extensions.d.ts.map +0 -1
  101. package/src/generators/configuration/lib/update-workspace.d.ts.map +0 -1
  102. package/src/generators/convert-to-inferred/convert-to-inferred.d.ts.map +0 -1
  103. package/src/generators/init/init.d.ts.map +0 -1
  104. package/src/migrations/update-20-0-0/replace-getJestProjects-with-getJestProjectsAsync.d.ts.map +0 -1
  105. package/src/migrations/update-20-0-0/replace-getJestProjects-with-getJestProjectsAsync.js +0 -86
  106. package/src/migrations/update-21-0-0/remove-tsconfig-option-from-jest-executor.d.ts.map +0 -1
  107. package/src/migrations/update-21-0-0/remove-tsconfig-option-from-jest-executor.js +0 -65
  108. package/src/migrations/update-21-0-0/replace-getJestProjects-with-getJestProjectsAsync.d.ts +0 -3
  109. package/src/migrations/update-21-0-0/replace-getJestProjects-with-getJestProjectsAsync.d.ts.map +0 -1
  110. package/src/migrations/update-21-3-0/rename-test-path-pattern.d.ts.map +0 -1
  111. package/src/migrations/update-21-3-0/replace-removed-matcher-aliases.d.ts.map +0 -1
  112. package/src/migrations/update-22-2-0/convert-jest-config-to-cjs.d.ts.map +0 -1
  113. package/src/plugins/plugin.d.ts.map +0 -1
  114. package/src/utils/ast-utils.d.ts.map +0 -1
  115. package/src/utils/config/config-file.d.ts.map +0 -1
  116. package/src/utils/config/functions.d.ts.map +0 -1
  117. package/src/utils/config/get-jest-projects.d.ts.map +0 -1
  118. package/src/utils/config/update-config.d.ts.map +0 -1
  119. package/src/utils/version-utils.d.ts +0 -3
  120. package/src/utils/version-utils.d.ts.map +0 -1
  121. package/src/utils/version-utils.js +0 -18
  122. package/src/utils/versions.d.ts.map +0 -1
  123. /package/{LICENSE → dist/LICENSE} +0 -0
  124. /package/{PLUGIN.md → dist/PLUGIN.md} +0 -0
  125. /package/{plugin.js → dist/plugin.js} +0 -0
  126. /package/{preset → dist/preset}/index.js +0 -0
  127. /package/{preset.js → dist/preset.js} +0 -0
  128. /package/{src → dist/src}/executors/jest/summary.js +0 -0
  129. /package/{src → dist/src}/generators/configuration/files/common/src/test-setup.ts__tmpl__ +0 -0
  130. /package/{src → dist/src}/generators/configuration/files/common/tsconfig.spec.json__tmpl__ +0 -0
  131. /package/{src → dist/src}/generators/configuration/files/jest-config-non-ts-solution/jest.config.ts__tmpl__ +0 -0
  132. /package/{src → dist/src}/generators/configuration/files/jest-config-ts-solution/jest.config.ts__tmpl__ +0 -0
  133. /package/{src → dist/src}/generators/configuration/files-angular/jest.config.ts__tmpl__ +0 -0
  134. /package/{src → dist/src}/generators/configuration/files-angular/src/test-setup.ts__tmpl__ +0 -0
  135. /package/{src → dist/src}/generators/configuration/files-angular/tsconfig.spec.json__tmpl__ +0 -0
  136. /package/{src → dist/src}/generators/configuration/lib/check-for-test-target.js +0 -0
  137. /package/{src → dist/src}/generators/configuration/lib/update-vscode-recommended-extensions.js +0 -0
  138. /package/{src → dist/src}/generators/configuration/lib/update-workspace.js +0 -0
  139. /package/{src → dist/src}/generators/convert-to-inferred/schema.json +0 -0
  140. /package/{src → dist/src}/generators/init/schema.d.ts +0 -0
  141. /package/{src → dist/src}/migrations/update-21-3-0/replace-removed-matcher-aliases.js +0 -0
  142. /package/{src → dist/src}/migrations/update-22-2-0/convert-jest-config-to-cjs.js +0 -0
  143. /package/{src → dist/src}/utils/ast-utils.js +0 -0
  144. /package/{src → dist/src}/utils/config/config-file.js +0 -0
  145. /package/{src → dist/src}/utils/config/update-config.js +0 -0
@@ -1,12 +1,7 @@
1
1
  import { configurationGenerator } from './src/generators/configuration/configuration';
2
2
  export { configurationGenerator };
3
- /**
4
- * @deprecated Use `configurationGenerator` instead. It will be removed in Nx v22.
5
- */
6
- export declare const jestProjectGenerator: typeof configurationGenerator;
7
3
  export { addPropertyToJestConfig, removePropertyFromJestConfig, } from './src/utils/config/update-config';
8
4
  export { jestConfigObjectAst } from './src/utils/config/functions';
9
5
  export { jestInitGenerator } from './src/generators/init/init';
10
6
  export { getJestProjectsAsync } from './src/utils/config/get-jest-projects';
11
7
  export { findJestConfig } from './src/utils/config/config-file';
12
- //# sourceMappingURL=index.d.ts.map
@@ -1,13 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.findJestConfig = exports.getJestProjectsAsync = exports.jestInitGenerator = exports.jestConfigObjectAst = exports.removePropertyFromJestConfig = exports.addPropertyToJestConfig = exports.jestProjectGenerator = exports.configurationGenerator = void 0;
3
+ exports.findJestConfig = exports.getJestProjectsAsync = exports.jestInitGenerator = exports.jestConfigObjectAst = exports.removePropertyFromJestConfig = exports.addPropertyToJestConfig = exports.configurationGenerator = void 0;
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
- // Exported for backwards compatibility in case a plugin is using the old name.
7
- /**
8
- * @deprecated Use `configurationGenerator` instead. It will be removed in Nx v22.
9
- */
10
- exports.jestProjectGenerator = configuration_1.configurationGenerator;
11
6
  var update_config_1 = require("./src/utils/config/update-config");
12
7
  Object.defineProperty(exports, "addPropertyToJestConfig", { enumerable: true, get: function () { return update_config_1.addPropertyToJestConfig; } });
13
8
  Object.defineProperty(exports, "removePropertyFromJestConfig", { enumerable: true, get: function () { return update_config_1.removePropertyFromJestConfig; } });
@@ -0,0 +1,2 @@
1
+ export { versions, getInstalledJestMajorVersion } from './src/utils/versions';
2
+ export { findRootJestPreset } from './src/utils/config/config-file';
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ // Semi-private surface for first-party Nx packages.
3
+ //
4
+ // External plugins should NOT import from here — this entry is curated for
5
+ // internal consumers and may change without semver protection. Mirrors
6
+ // `@nx/devkit/internal`.
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.findRootJestPreset = exports.getInstalledJestMajorVersion = exports.versions = void 0;
9
+ var versions_1 = require("./src/utils/versions");
10
+ Object.defineProperty(exports, "versions", { enumerable: true, get: function () { return versions_1.versions; } });
11
+ Object.defineProperty(exports, "getInstalledJestMajorVersion", { enumerable: true, get: function () { return versions_1.getInstalledJestMajorVersion; } });
12
+ var config_file_1 = require("./src/utils/config/config-file");
13
+ Object.defineProperty(exports, "findRootJestPreset", { enumerable: true, get: function () { return config_file_1.findRootJestPreset; } });
@@ -1,2 +1 @@
1
1
  export { createNodes, createNodesV2, JestPluginOptions, } from './src/plugins/plugin';
2
- //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1 @@
1
+ export {};
@@ -19,7 +19,7 @@ function getCompilerSetup(rootDir) {
19
19
  const config = ts.parseJsonConfigFileContent(readResult.config, ts.sys, (0, path_1.dirname)(tsConfigPath));
20
20
  const compilerOptions = config.options;
21
21
  if (!compilerOptions.baseUrl) {
22
- const { resolvePathsBaseUrl, } = require('@nx/js/src/utils/typescript/ts-config');
22
+ const { resolvePathsBaseUrl } = require('@nx/js');
23
23
  compilerOptions.baseUrl = resolvePathsBaseUrl(tsConfigPath);
24
24
  }
25
25
  const host = ts.createCompilerHost(compilerOptions, true);
@@ -1,3 +1,2 @@
1
1
  import { nxPreset } from './jest-preset';
2
2
  export default nxPreset;
3
- //# sourceMappingURL=index.d.ts.map
@@ -1,3 +1,2 @@
1
1
  import { Config } from 'jest';
2
2
  export declare const nxPreset: Config;
3
- //# sourceMappingURL=jest-preset.d.ts.map
@@ -25,6 +25,7 @@ exports.nxPreset = {
25
25
  ],
26
26
  },
27
27
  testEnvironment: 'jsdom',
28
+ modulePathIgnorePatterns: ['<rootDir>/dist/', '<rootDir>/out-tsc/'],
28
29
  /**
29
30
  * manually set the exports names to load in common js, to mimic the behaviors of jest 27
30
31
  * before jest didn't fully support package exports and would load in common js code (typically via main field). now jest 28+ will load in the browser esm code, but jest esm support is not fully supported.
@@ -1,4 +1,3 @@
1
1
  import { nxPreset } from './preset/jest-preset';
2
2
  export { nxPreset };
3
3
  export default nxPreset;
4
- //# sourceMappingURL=preset.d.ts.map
@@ -8,4 +8,3 @@ export declare function jestExecutor(options: JestExecutorOptions, context: Exec
8
8
  export declare function parseJestConfig(options: JestExecutorOptions, context: ExecutorContext, multiProjects?: boolean): Promise<Config.Argv>;
9
9
  export default jestExecutor;
10
10
  export declare function batchJest(taskGraph: TaskGraph, inputs: Record<string, JestExecutorOptions>, overrides: JestExecutorOptions, context: ExecutorContext): Promise<BatchResults>;
11
- //# sourceMappingURL=jest.impl.d.ts.map
@@ -10,11 +10,14 @@ const reporters_1 = require("@jest/reporters");
10
10
  const test_result_1 = require("@jest/test-result");
11
11
  const path = tslib_1.__importStar(require("path"));
12
12
  const path_1 = require("path");
13
+ const schema_json_1 = tslib_1.__importDefault(require("./schema.json"));
13
14
  const devkit_1 = require("@nx/devkit");
14
15
  const summary_1 = require("./summary");
15
16
  const fs_1 = require("fs");
17
+ const deprecation_1 = require("../../utils/deprecation");
16
18
  process.env.NODE_ENV ??= 'test';
17
19
  async function jestExecutor(options, context) {
20
+ (0, deprecation_1.warnJestExecutorDeprecation)();
18
21
  // Jest registers ts-node with module CJS https://github.com/SimenB/jest/blob/v29.6.4/packages/jest-config/src/readConfigFileAndSetRootDir.ts#L117-L119
19
22
  // We want to support of ESM via 'module':'nodenext', we need to override the resolution until Jest supports it.
20
23
  const existingValue = process.env['TS_NODE_COMPILER_OPTIONS'];
@@ -39,11 +42,9 @@ function getExtraArgs(options, schema) {
39
42
  return extraArgs;
40
43
  }
41
44
  async function parseJestConfig(options, context, multiProjects = false) {
42
- let jestConfig;
43
45
  // support passing extra args to jest cli supporting 3rd party plugins
44
46
  // like 'jest-runner-groups' --group arg
45
- const schema = await Promise.resolve().then(() => tslib_1.__importStar(require('./schema.json')));
46
- const extraArgs = getExtraArgs(options, schema);
47
+ const extraArgs = getExtraArgs(options, schema_json_1.default);
47
48
  const config = {
48
49
  ...extraArgs,
49
50
  $0: undefined,
@@ -82,15 +83,6 @@ async function parseJestConfig(options, context, multiProjects = false) {
82
83
  };
83
84
  if (!multiProjects) {
84
85
  options.jestConfig = path.resolve(context.root, options.jestConfig);
85
- jestConfig = (await (0, jest_config_1.readConfig)(config, options.jestConfig)).projectConfig;
86
- }
87
- // for backwards compatibility
88
- if (options.setupFile && !multiProjects) {
89
- const setupFilesAfterEnvSet = new Set([
90
- ...(jestConfig.setupFilesAfterEnv ?? []),
91
- path.resolve(context.root, options.setupFile),
92
- ]);
93
- config.setupFilesAfterEnv = Array.from(setupFilesAfterEnvSet);
94
86
  }
95
87
  if (options.testFile) {
96
88
  config._.push(options.testFile);
@@ -37,11 +37,4 @@ export interface JestExecutorOptions {
37
37
  watchAll?: boolean;
38
38
  testLocationInResults?: boolean;
39
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;
47
40
  }
@@ -5,6 +5,7 @@
5
5
  "description": "Jest target options for Build Facade.",
6
6
  "cli": "nx",
7
7
  "type": "object",
8
+ "x-deprecated": "The `@nx/jest:jest` executor is deprecated and will be removed in Nx v24. Run `nx g @nx/jest:convert-to-inferred` to migrate to the `@nx/jest/plugin` inferred plugin. See https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.",
8
9
  "presets": [
9
10
  {
10
11
  "name": "Pass Without Tests",
@@ -65,11 +66,6 @@
65
66
  "x-completion-type": "file",
66
67
  "x-completion-glob": "tsconfig.*.json"
67
68
  },
68
- "setupFile": {
69
- "description": "The name of a setup file used by Jest.",
70
- "type": "string",
71
- "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."
72
- },
73
69
  "bail": {
74
70
  "alias": "b",
75
71
  "description": "Exit the test suite immediately after `n` number of failing tests. (https://jestjs.io/docs/cli#--bail)",
@@ -5,4 +5,3 @@ export declare const getSummary: (aggregatedResults: AggregatedResult, options?:
5
5
  roundTime?: boolean;
6
6
  width?: number;
7
7
  }) => string;
8
- //# sourceMappingURL=summary.d.ts.map
@@ -3,4 +3,3 @@ import { JestProjectSchema } from './schema';
3
3
  export declare function configurationGenerator(tree: Tree, schema: JestProjectSchema): Promise<GeneratorCallback>;
4
4
  export declare function configurationGeneratorInternal(tree: Tree, schema: JestProjectSchema): Promise<GeneratorCallback>;
5
5
  export default configurationGenerator;
6
- //# sourceMappingURL=configuration.d.ts.map
@@ -3,10 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.configurationGenerator = configurationGenerator;
4
4
  exports.configurationGeneratorInternal = configurationGeneratorInternal;
5
5
  const devkit_1 = require("@nx/devkit");
6
+ const internal_1 = require("@nx/devkit/internal");
6
7
  const js_1 = require("@nx/js");
7
- const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
8
+ const internal_2 = require("@nx/js/internal");
8
9
  const config_file_1 = require("../../utils/config/config-file");
9
10
  const init_1 = require("../init/init");
11
+ const assert_supported_jest_version_1 = require("../../utils/assert-supported-jest-version");
12
+ const deprecation_1 = require("../../utils/deprecation");
10
13
  const check_for_test_target_1 = require("./lib/check-for-test-target");
11
14
  const create_files_1 = require("./lib/create-files");
12
15
  const create_jest_config_1 = require("./lib/create-jest-config");
@@ -18,7 +21,6 @@ const schemaDefaults = {
18
21
  setupFile: 'none',
19
22
  babelJest: false,
20
23
  supportTsx: false,
21
- skipSetupFile: false,
22
24
  skipSerializers: false,
23
25
  testEnvironment: 'jsdom',
24
26
  };
@@ -40,23 +42,20 @@ function normalizeOptions(tree, options) {
40
42
  ['swc', 'babel'].includes(options.compiler)) {
41
43
  options.skipSerializers = true;
42
44
  }
43
- if (options.skipSetupFile) {
44
- // setupFile is always 'none'
45
- options.setupFile = schemaDefaults.setupFile;
46
- }
47
45
  const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
48
46
  return {
49
47
  ...schemaDefaults,
50
48
  ...options,
51
49
  keepExistingVersions: options.keepExistingVersions ?? true,
52
50
  rootProject: project.root === '.' || project.root === '',
53
- isTsSolutionSetup: (0, ts_solution_setup_1.isUsingTsSolutionSetup)(tree),
51
+ isTsSolutionSetup: (0, internal_2.isUsingTsSolutionSetup)(tree),
54
52
  };
55
53
  }
56
54
  function configurationGenerator(tree, schema) {
57
55
  return configurationGeneratorInternal(tree, { addPlugin: false, ...schema });
58
56
  }
59
57
  async function configurationGeneratorInternal(tree, schema) {
58
+ (0, assert_supported_jest_version_1.assertSupportedJestVersion)(tree);
60
59
  const options = normalizeOptions(tree, schema);
61
60
  // we'll only add the vscode recommended extension if the jest preset does
62
61
  // not exist, which most likely means this is a first run, in the cases it's
@@ -88,18 +87,20 @@ async function configurationGeneratorInternal(tree, schema) {
88
87
  }
89
88
  });
90
89
  if (!hasPlugin || options.addExplicitTargets) {
90
+ (0, deprecation_1.warnJestExecutorGenerating)();
91
91
  (0, update_workspace_1.updateWorkspace)(tree, options);
92
92
  }
93
93
  if (options.isTsSolutionSetup) {
94
94
  ignoreTestOutput(tree);
95
95
  // in the TS solution setup, the test target depends on the build outputs
96
96
  // so we need to setup the task pipeline accordingly
97
- const nxJson = (0, devkit_1.readNxJson)(tree);
98
- nxJson.targetDefaults ??= {};
99
- nxJson.targetDefaults[options.targetName] ??= {};
100
- nxJson.targetDefaults[options.targetName].dependsOn ??= [];
101
- nxJson.targetDefaults[options.targetName].dependsOn.push('^build');
102
- nxJson.targetDefaults[options.targetName].dependsOn = Array.from(new Set(nxJson.targetDefaults[options.targetName].dependsOn));
97
+ const nxJson = (0, devkit_1.readNxJson)(tree) ?? {};
98
+ const existing = findExistingTestDefault(nxJson.targetDefaults, options.targetName);
99
+ const dependsOn = Array.from(new Set([...(existing?.dependsOn ?? []), '^build']));
100
+ (0, internal_1.upsertTargetDefault)(tree, nxJson, {
101
+ target: options.targetName,
102
+ dependsOn,
103
+ });
103
104
  (0, devkit_1.updateNxJson)(tree, nxJson);
104
105
  }
105
106
  if (!schema.skipFormat) {
@@ -107,6 +108,16 @@ async function configurationGeneratorInternal(tree, schema) {
107
108
  }
108
109
  return (0, devkit_1.runTasksInSerial)(...tasks);
109
110
  }
111
+ function findExistingTestDefault(td, targetName) {
112
+ if (!td)
113
+ return undefined;
114
+ if (Array.isArray(td)) {
115
+ return td.find((e) => e.target === targetName &&
116
+ e.projects === undefined &&
117
+ e.plugin === undefined);
118
+ }
119
+ return td[targetName];
120
+ }
110
121
  function ignoreTestOutput(tree) {
111
122
  if (!tree.exists('.gitignore')) {
112
123
  devkit_1.logger.warn(`Couldn't find a root .gitignore file to update.`);
@@ -1,4 +1,3 @@
1
1
  import { Tree } from '@nx/devkit';
2
2
  import { NormalizedJestProjectSchema } from '../schema';
3
3
  export declare function checkForTestTarget(tree: Tree, options: NormalizedJestProjectSchema): void;
4
- //# sourceMappingURL=check-for-test-target.d.ts.map
@@ -2,4 +2,3 @@ import { Tree } from '@nx/devkit';
2
2
  import type { JestPresetExtension } from '../../../utils/config/config-file';
3
3
  import { NormalizedJestProjectSchema } from '../schema';
4
4
  export declare function createFiles(tree: Tree, options: NormalizedJestProjectSchema, presetExt: JestPresetExtension): void;
5
- //# sourceMappingURL=create-files.d.ts.map
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createFiles = createFiles;
4
4
  const devkit_1 = require("@nx/devkit");
5
- const add_swc_config_1 = require("@nx/js/src/utils/swc/add-swc-config");
5
+ const internal_1 = require("@nx/js/internal");
6
6
  const path_1 = require("path");
7
7
  const versions_1 = require("../../../utils/versions");
8
8
  function createFiles(tree, options, presetExt) {
@@ -33,7 +33,7 @@ function createFiles(tree, options, presetExt) {
33
33
  transformerOptions = "{ tsconfig: '<rootDir>/tsconfig.spec.json' }";
34
34
  }
35
35
  if (options.compiler === 'swc' && options.isTsSolutionSetup) {
36
- (0, add_swc_config_1.addSwcTestConfig)(tree, projectConfig.root, 'es6', options.supportTsx);
36
+ (0, internal_1.addSwcTestConfig)(tree, projectConfig.root, 'es6', options.supportTsx);
37
37
  }
38
38
  const projectRoot = options.rootProject
39
39
  ? options.project
@@ -2,4 +2,3 @@ import { type Tree } from '@nx/devkit';
2
2
  import { type JestPresetExtension } from '../../../utils/config/config-file';
3
3
  import type { NormalizedJestProjectSchema } from '../schema';
4
4
  export declare function createJestConfig(tree: Tree, options: Partial<NormalizedJestProjectSchema>, presetExt: JestPresetExtension): Promise<void>;
5
- //# sourceMappingURL=create-jest-config.d.ts.map
@@ -4,7 +4,7 @@ exports.createJestConfig = createJestConfig;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const project_configuration_utils_1 = require("nx/src/project-graph/utils/project-configuration-utils");
6
6
  const config_file_1 = require("../../../utils/config/config-file");
7
- const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
7
+ const internal_1 = require("@nx/js/internal");
8
8
  async function createJestConfig(tree, options, presetExt) {
9
9
  if (!tree.exists(`jest.preset.${presetExt}`)) {
10
10
  if (presetExt === 'mjs') {
@@ -58,7 +58,7 @@ module.exports = { ...nxPreset };`);
58
58
  // Jest target has already been updated
59
59
  return;
60
60
  }
61
- const jestProjectConfig = `jest.config.${(0, ts_solution_setup_1.getProjectType)(tree, rootProjectConfig.root, rootProjectConfig.projectType) === 'application'
61
+ const jestProjectConfig = `jest.config.${(0, internal_1.getProjectType)(tree, rootProjectConfig.root, rootProjectConfig.projectType) === 'application'
62
62
  ? 'app'
63
63
  : 'lib'}.${options.js ? 'js' : 'ts'}`;
64
64
  tree.rename(rootJestPath, jestProjectConfig);
@@ -1,4 +1,3 @@
1
1
  import { type Tree } from '@nx/devkit';
2
2
  import type { NormalizedJestProjectSchema } from '../schema';
3
3
  export declare function ensureDependencies(tree: Tree, options: Partial<NormalizedJestProjectSchema>): import("@nx/devkit").GeneratorCallback;
4
- //# sourceMappingURL=ensure-dependencies.d.ts.map
@@ -32,5 +32,5 @@ function ensureDependencies(tree, options) {
32
32
  else if (options.compiler === 'swc') {
33
33
  devDeps['@swc/jest'] = swcJestVersion;
34
34
  }
35
- return (0, devkit_1.addDependenciesToPackageJson)(tree, dependencies, devDeps, undefined, options.keepExistingVersions);
35
+ return (0, devkit_1.addDependenciesToPackageJson)(tree, dependencies, devDeps, undefined, options.keepExistingVersions ?? true);
36
36
  }
@@ -1,4 +1,3 @@
1
1
  import { type Tree } from '@nx/devkit';
2
2
  import type { NormalizedJestProjectSchema } from '../schema';
3
3
  export declare function updateTsConfig(host: Tree, options: NormalizedJestProjectSchema): void;
4
- //# sourceMappingURL=update-tsconfig.d.ts.map
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.updateTsConfig = updateTsConfig;
4
4
  const devkit_1 = require("@nx/devkit");
5
- const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
5
+ const internal_1 = require("@nx/js/internal");
6
6
  function updateTsConfig(host, options) {
7
7
  const { root, projectType: _projectType } = (0, devkit_1.readProjectConfiguration)(host, options.project);
8
8
  if (!host.exists((0, devkit_1.joinPathFragments)(root, 'tsconfig.json'))) {
@@ -25,7 +25,7 @@ function updateTsConfig(host, options) {
25
25
  }
26
26
  return json;
27
27
  });
28
- const projectType = (0, ts_solution_setup_1.getProjectType)(host, root, _projectType);
28
+ const projectType = (0, internal_1.getProjectType)(host, root, _projectType);
29
29
  // fall-back runtime tsconfig file path in case the user didn't provide one
30
30
  let runtimeTsconfigPath = (0, devkit_1.joinPathFragments)(root, projectType === 'application' ? 'tsconfig.app.json' : 'tsconfig.lib.json');
31
31
  if (options.runtimeTsconfigFileName) {
@@ -1,3 +1,2 @@
1
1
  import { type Tree } from '@nx/devkit';
2
2
  export declare function updateVsCodeRecommendedExtensions(host: Tree): void;
3
- //# sourceMappingURL=update-vscode-recommended-extensions.d.ts.map
@@ -1,4 +1,3 @@
1
1
  import { type Tree } from '@nx/devkit';
2
2
  import type { NormalizedJestProjectSchema } from '../schema';
3
3
  export declare function updateWorkspace(tree: Tree, options: NormalizedJestProjectSchema): void;
4
- //# sourceMappingURL=update-workspace.d.ts.map
@@ -26,10 +26,6 @@ export interface JestProjectSchema {
26
26
  * @deprecated Use the `compiler` option instead. It will be removed in Nx v22.
27
27
  */
28
28
  babelJest?: boolean;
29
- /**
30
- * @deprecated Use the `setupFile` option instead. It will be removed in Nx v22.
31
- */
32
- skipSetupFile?: boolean;
33
29
  keepExistingVersions?: boolean;
34
30
  }
35
31
 
@@ -14,12 +14,6 @@
14
14
  },
15
15
  "x-priority": "important"
16
16
  },
17
- "skipSetupFile": {
18
- "type": "boolean",
19
- "description": "Skips the setup file required for angular.",
20
- "default": false,
21
- "x-deprecated": "Use the `setupFile` option instead. It will be removed in Nx v22."
22
- },
23
17
  "setupFile": {
24
18
  "type": "string",
25
19
  "enum": ["none", "angular", "web-components"],
@@ -5,4 +5,3 @@ interface Schema {
5
5
  }
6
6
  export declare function convertToInferred(tree: Tree, options: Schema): Promise<void>;
7
7
  export default convertToInferred;
8
- //# sourceMappingURL=convert-to-inferred.d.ts.map
@@ -1,17 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.convertToInferred = convertToInferred;
4
+ const internal_1 = require("@nx/devkit/internal");
4
5
  const devkit_1 = require("@nx/devkit");
5
- const executor_to_plugin_migrator_1 = require("@nx/devkit/src/generators/plugin-migrations/executor-to-plugin-migrator");
6
- const plugin_migration_utils_1 = require("@nx/devkit/src/generators/plugin-migrations/plugin-migration-utils");
7
6
  const jest_config_1 = require("jest-config");
8
7
  const node_path_1 = require("node:path");
9
8
  const plugin_1 = require("../../plugins/plugin");
10
9
  const config_file_1 = require("../../utils/config/config-file");
10
+ const assert_supported_jest_version_1 = require("../../utils/assert-supported-jest-version");
11
11
  const versions_1 = require("../../utils/versions");
12
12
  async function convertToInferred(tree, options) {
13
+ (0, assert_supported_jest_version_1.assertSupportedJestVersion)(tree);
13
14
  const projectGraph = await (0, devkit_1.createProjectGraphAsync)();
14
- const migratedProjects = await (0, executor_to_plugin_migrator_1.migrateProjectExecutorsToPlugin)(tree, projectGraph, '@nx/jest/plugin', plugin_1.createNodesV2, { targetName: 'test' }, [
15
+ const migratedProjects = await (0, internal_1.migrateProjectExecutorsToPlugin)(tree, projectGraph, '@nx/jest/plugin', plugin_1.createNodesV2, { targetName: 'test' }, [
15
16
  {
16
17
  executors: ['@nx/jest:jest', '@nrwl/jest:jest'],
17
18
  postTargetTransformer,
@@ -19,7 +20,7 @@ async function convertToInferred(tree, options) {
19
20
  },
20
21
  ], options.project);
21
22
  if (migratedProjects.size === 0) {
22
- throw new executor_to_plugin_migrator_1.NoTargetsToMigrateError();
23
+ throw new internal_1.NoTargetsToMigrateError();
23
24
  }
24
25
  if (!options.skipFormat) {
25
26
  await (0, devkit_1.formatFiles)(tree);
@@ -49,7 +50,7 @@ async function postTargetTransformer(target, tree, projectDetails, inferredTarge
49
50
  }
50
51
  }
51
52
  if (target.outputs) {
52
- (0, plugin_migration_utils_1.processTargetOutputs)(target, [], inferredTarget, {
53
+ (0, internal_1.processTargetOutputs)(target, [], inferredTarget, {
53
54
  projectName: projectDetails.projectName,
54
55
  projectRoot: projectDetails.root,
55
56
  });
@@ -68,11 +69,11 @@ async function updateOptionsObject(tree, targetOptions, projectRoot, workspaceRo
68
69
  async function updateConfigurationObject(tree, targetOptions, projectRoot, workspaceRoot, defaultJestConfigPath) {
69
70
  const jestConfigPath = targetOptions.jestConfig ?? defaultJestConfigPath;
70
71
  if (targetOptions.jestConfig) {
71
- targetOptions.config = (0, plugin_migration_utils_1.toProjectRelativePath)(targetOptions.jestConfig, projectRoot);
72
+ targetOptions.config = (0, internal_1.toProjectRelativePath)(targetOptions.jestConfig, projectRoot);
72
73
  delete targetOptions.jestConfig;
73
74
  }
74
75
  else if (targetOptions.config) {
75
- targetOptions.config = (0, plugin_migration_utils_1.toProjectRelativePath)(targetOptions.config, projectRoot);
76
+ targetOptions.config = (0, internal_1.toProjectRelativePath)(targetOptions.config, projectRoot);
76
77
  }
77
78
  await updateOptions(tree, targetOptions, projectRoot, workspaceRoot, jestConfigPath);
78
79
  }
@@ -127,7 +128,7 @@ async function updateOptions(tree, targetOptions, projectRoot, workspaceRoot, je
127
128
  // the executor accepts a comma-separated string, while jest accepts a space-separated string
128
129
  const parsedSourceFiles = targetOptions.findRelatedTests
129
130
  .split(',')
130
- .map((s) => (0, plugin_migration_utils_1.toProjectRelativePath)(s.trim(), projectRoot))
131
+ .map((s) => (0, internal_1.toProjectRelativePath)(s.trim(), projectRoot))
131
132
  .join(' ');
132
133
  targetOptions.args = [`--findRelatedTests ${parsedSourceFiles}`];
133
134
  delete targetOptions.findRelatedTests;
@@ -151,11 +152,11 @@ async function updateOptions(tree, targetOptions, projectRoot, workspaceRoot, je
151
152
  }
152
153
  if ('outputFile' in targetOptions) {
153
154
  // update the output file to be relative to the project root
154
- targetOptions.outputFile = (0, plugin_migration_utils_1.toProjectRelativePath)(targetOptions.outputFile, projectRoot);
155
+ targetOptions.outputFile = (0, internal_1.toProjectRelativePath)(targetOptions.outputFile, projectRoot);
155
156
  }
156
157
  if ('coverageDirectory' in targetOptions) {
157
158
  // update the coverage directory to be relative to the project root
158
- targetOptions.coverageDirectory = (0, plugin_migration_utils_1.toProjectRelativePath)(targetOptions.coverageDirectory, projectRoot);
159
+ targetOptions.coverageDirectory = (0, internal_1.toProjectRelativePath)(targetOptions.coverageDirectory, projectRoot);
159
160
  }
160
161
  }
161
162
  async function processSetupFiles(setupFile, setupFilesAfterEnv, projectRoot, workspaceRoot, jestConfigPath) {
@@ -167,11 +168,11 @@ async function processSetupFiles(setupFile, setupFilesAfterEnv, projectRoot, wor
167
168
  if (jestConfigPath) {
168
169
  const jestConfig = await (0, jest_config_1.readConfig)({ setupFilesAfterEnv }, (0, node_path_1.join)(workspaceRoot, jestConfigPath));
169
170
  if (jestConfig.projectConfig.setupFilesAfterEnv) {
170
- configSetupFilesAfterEnv.push(...jestConfig.projectConfig.setupFilesAfterEnv.map((file) => (0, plugin_migration_utils_1.toProjectRelativePath)(file, projectRoot)));
171
+ configSetupFilesAfterEnv.push(...jestConfig.projectConfig.setupFilesAfterEnv.map((file) => (0, internal_1.toProjectRelativePath)(file, projectRoot)));
171
172
  }
172
173
  }
173
174
  if (!configSetupFilesAfterEnv.length) {
174
- return [(0, plugin_migration_utils_1.toProjectRelativePath)(setupFile, projectRoot)];
175
+ return [(0, internal_1.toProjectRelativePath)(setupFile, projectRoot)];
175
176
  }
176
177
  if (isSetupFileInConfig(configSetupFilesAfterEnv, setupFile, projectRoot, workspaceRoot)) {
177
178
  // the setupFile is already included in the setupFilesAfterEnv
@@ -179,7 +180,7 @@ async function processSetupFiles(setupFile, setupFilesAfterEnv, projectRoot, wor
179
180
  }
180
181
  return [
181
182
  ...configSetupFilesAfterEnv,
182
- (0, plugin_migration_utils_1.toProjectRelativePath)(setupFile, projectRoot),
183
+ (0, internal_1.toProjectRelativePath)(setupFile, projectRoot),
183
184
  ];
184
185
  }
185
186
  function isSetupFileInConfig(setupFilesAfterEnv, setupFile, projectRoot, workspaceRoot) {
@@ -187,7 +188,7 @@ function isSetupFileInConfig(setupFilesAfterEnv, setupFile, projectRoot, workspa
187
188
  ? node_path_1.posix.join(workspaceRoot, projectRoot, f.slice('<rootDir>'.length))
188
189
  : node_path_1.posix.join(workspaceRoot, projectRoot, f);
189
190
  const normalizedSetupFiles = new Set(setupFilesAfterEnv.map(normalizePath));
190
- return normalizedSetupFiles.has(normalizePath((0, plugin_migration_utils_1.toProjectRelativePath)(setupFile, projectRoot)));
191
+ return normalizedSetupFiles.has(normalizePath((0, internal_1.toProjectRelativePath)(setupFile, projectRoot)));
191
192
  }
192
193
  function toProjectRelativeRegexPath(path, projectRoot) {
193
194
  if (projectRoot === '.') {
@@ -3,4 +3,3 @@ import type { JestInitSchema } from './schema';
3
3
  export declare function jestInitGenerator(tree: Tree, options: JestInitSchema): Promise<GeneratorCallback>;
4
4
  export declare function jestInitGeneratorInternal(tree: Tree, options: JestInitSchema): Promise<GeneratorCallback>;
5
5
  export default jestInitGenerator;
6
- //# sourceMappingURL=init.d.ts.map