@nx/jest 22.7.0-beta.0 → 22.7.0-beta.2

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": "22.7.0-beta.0",
3
+ "version": "22.7.0-beta.2",
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": "^30.0.2",
39
39
  "@jest/test-result": "^30.0.2",
40
- "@nx/devkit": "22.7.0-beta.0",
41
- "@nx/js": "22.7.0-beta.0",
40
+ "@nx/devkit": "22.7.0-beta.2",
41
+ "@nx/js": "22.7.0-beta.2",
42
42
  "@phenomnomnominal/tsquery": "~6.1.4",
43
43
  "identity-obj-proxy": "3.0.0",
44
44
  "jest-config": "^30.0.2",
@@ -52,7 +52,7 @@
52
52
  "yargs-parser": "21.1.1"
53
53
  },
54
54
  "devDependencies": {
55
- "nx": "22.7.0-beta.0"
55
+ "nx": "22.7.0-beta.2"
56
56
  },
57
57
  "publishConfig": {
58
58
  "access": "public"
@@ -3,11 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.jestExecutor = jestExecutor;
4
4
  exports.parseJestConfig = parseJestConfig;
5
5
  exports.batchJest = batchJest;
6
+ const tslib_1 = require("tslib");
6
7
  const jest_1 = require("jest");
7
8
  const jest_config_1 = require("jest-config");
8
9
  const reporters_1 = require("@jest/reporters");
9
10
  const test_result_1 = require("@jest/test-result");
10
- const path = require("path");
11
+ const path = tslib_1.__importStar(require("path"));
11
12
  const path_1 = require("path");
12
13
  const devkit_1 = require("@nx/devkit");
13
14
  const summary_1 = require("./summary");
@@ -41,7 +42,7 @@ async function parseJestConfig(options, context, multiProjects = false) {
41
42
  let jestConfig;
42
43
  // support passing extra args to jest cli supporting 3rd party plugins
43
44
  // like 'jest-runner-groups' --group arg
44
- const schema = await Promise.resolve().then(() => require('./schema.json'));
45
+ const schema = await Promise.resolve().then(() => tslib_1.__importStar(require('./schema.json')));
45
46
  const extraArgs = getExtraArgs(options, schema);
46
47
  const config = {
47
48
  ...extraArgs,
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getSummary = void 0;
4
+ const tslib_1 = require("tslib");
4
5
  const jest_util_1 = require("jest-util");
5
- const pc = require("picocolors");
6
+ const pc = tslib_1.__importStar(require("picocolors"));
6
7
  /**
7
8
  * Copied from the jest repo because these utility functions are not exposed through the package
8
9
  * https://github.com/facebook/jest/blob/7a64ede2163eba4ecc725f448cd92102cd8c14aa/packages/jest-reporters/src/utils.ts
@@ -1 +1 @@
1
- {"version":3,"file":"replace-removed-matcher-aliases.d.ts","sourceRoot":"","sources":["../../../../../../packages/jest/src/migrations/update-21-3-0/replace-removed-matcher-aliases.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC;AAuB/D,yBAA+B,IAAI,EAAE,IAAI,iBAWxC"}
1
+ {"version":3,"file":"replace-removed-matcher-aliases.d.ts","sourceRoot":"","sources":["../../../../../../packages/jest/src/migrations/update-21-3-0/replace-removed-matcher-aliases.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkC,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC;AAuBvE,yBAA+B,IAAI,EAAE,IAAI,iBAWxC"}
@@ -1,11 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = default_1;
4
+ const tslib_1 = require("tslib");
4
5
  const devkit_1 = require("@nx/devkit");
5
6
  const tsquery_1 = require("@phenomnomnominal/tsquery");
6
7
  const jest_1 = require("jest");
7
8
  const jest_config_1 = require("jest-config");
8
- const jest_runtime_1 = require("jest-runtime");
9
+ const jest_runtime_1 = tslib_1.__importDefault(require("jest-runtime"));
9
10
  const path_1 = require("path");
10
11
  const matcherAliasesMap = new Map([
11
12
  ['toBeCalled', 'toHaveBeenCalled'],
@@ -85,16 +86,53 @@ async function getTestFilePaths(tree) {
85
86
  // skip the root jest config file which includes all projects
86
87
  continue;
87
88
  }
88
- const config = await (0, jest_config_1.readConfig)({ _: [], $0: undefined }, (0, path_1.join)(tree.root, jestConfigFile));
89
- const jestContext = await jest_runtime_1.default.createContext(config.projectConfig, {
89
+ const resolvedPaths = await resolveTestPaths(tree, jestConfigFile);
90
+ if (resolvedPaths) {
91
+ for (const testPath of resolvedPaths) {
92
+ testFilePaths.add(testPath);
93
+ }
94
+ }
95
+ }
96
+ return Array.from(testFilePaths);
97
+ }
98
+ /**
99
+ * Resolves test file paths for a single jest config by loading the config
100
+ * through Jest's own resolution. Returns null if the config cannot be
101
+ * resolved (e.g. missing files, uninstalled transform modules, invalid
102
+ * presets), logging a warning so the user knows which project was skipped.
103
+ */
104
+ async function resolveTestPaths(tree, jestConfigFile) {
105
+ const fullConfigPath = (0, path_1.join)(tree.root, jestConfigFile);
106
+ let config;
107
+ try {
108
+ config = await (0, jest_config_1.readConfig)({ _: [], $0: undefined }, fullConfigPath);
109
+ }
110
+ catch (e) {
111
+ const message = e instanceof Error ? e.message : String(e);
112
+ devkit_1.logger.warn(`Could not read Jest config "${jestConfigFile}": ${message}. Skipping this project for matcher alias replacement.`);
113
+ return null;
114
+ }
115
+ let jestContext;
116
+ try {
117
+ jestContext = await jest_runtime_1.default.createContext(config.projectConfig, {
90
118
  maxWorkers: 1,
91
119
  watchman: false,
92
120
  });
121
+ }
122
+ catch (e) {
123
+ const message = e instanceof Error ? e.message : String(e);
124
+ devkit_1.logger.warn(`Could not create Jest context for "${jestConfigFile}": ${message}. Skipping this project for matcher alias replacement.`);
125
+ return null;
126
+ }
127
+ let specs;
128
+ try {
93
129
  const source = new jest_1.SearchSource(jestContext);
94
- const specs = await source.getTestPaths(config.globalConfig, config.projectConfig);
95
- for (const testPath of specs.tests) {
96
- testFilePaths.add(path_1.posix.normalize((0, path_1.relative)(tree.root, testPath.path)));
97
- }
130
+ specs = await source.getTestPaths(config.globalConfig, config.projectConfig);
98
131
  }
99
- return Array.from(testFilePaths);
132
+ catch (e) {
133
+ const message = e instanceof Error ? e.message : String(e);
134
+ devkit_1.logger.warn(`Could not resolve test paths for "${jestConfigFile}": ${message}. Skipping this project for matcher alias replacement.`);
135
+ return null;
136
+ }
137
+ return specs.tests.map((t) => path_1.posix.normalize((0, path_1.relative)(tree.root, t.path)));
100
138
  }
@@ -1,9 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getJestProjectsAsync = getJestProjectsAsync;
4
+ const tslib_1 = require("tslib");
4
5
  const devkit_1 = require("@nx/devkit");
5
6
  const path_1 = require("path");
6
- const yargs = require("yargs-parser");
7
+ const yargs = tslib_1.__importStar(require("yargs-parser"));
7
8
  function getJestConfigProjectPath(projectJestConfigPath) {
8
9
  return (0, path_1.join)('<rootDir>', projectJestConfigPath);
9
10
  }