@nx/jest 22.6.0-rc.2 → 22.6.1

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.6.0-rc.2",
3
+ "version": "22.6.1",
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.6.0-rc.2",
41
- "@nx/js": "22.6.0-rc.2",
40
+ "@nx/devkit": "22.6.1",
41
+ "@nx/js": "22.6.1",
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.6.0-rc.2"
55
+ "nx": "22.6.1"
56
56
  },
57
57
  "publishConfig": {
58
58
  "access": "public"
@@ -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"}
@@ -85,16 +85,53 @@ async function getTestFilePaths(tree) {
85
85
  // skip the root jest config file which includes all projects
86
86
  continue;
87
87
  }
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, {
88
+ const resolvedPaths = await resolveTestPaths(tree, jestConfigFile);
89
+ if (resolvedPaths) {
90
+ for (const testPath of resolvedPaths) {
91
+ testFilePaths.add(testPath);
92
+ }
93
+ }
94
+ }
95
+ return Array.from(testFilePaths);
96
+ }
97
+ /**
98
+ * Resolves test file paths for a single jest config by loading the config
99
+ * through Jest's own resolution. Returns null if the config cannot be
100
+ * resolved (e.g. missing files, uninstalled transform modules, invalid
101
+ * presets), logging a warning so the user knows which project was skipped.
102
+ */
103
+ async function resolveTestPaths(tree, jestConfigFile) {
104
+ const fullConfigPath = (0, path_1.join)(tree.root, jestConfigFile);
105
+ let config;
106
+ try {
107
+ config = await (0, jest_config_1.readConfig)({ _: [], $0: undefined }, fullConfigPath);
108
+ }
109
+ catch (e) {
110
+ const message = e instanceof Error ? e.message : String(e);
111
+ devkit_1.logger.warn(`Could not read Jest config "${jestConfigFile}": ${message}. Skipping this project for matcher alias replacement.`);
112
+ return null;
113
+ }
114
+ let jestContext;
115
+ try {
116
+ jestContext = await jest_runtime_1.default.createContext(config.projectConfig, {
90
117
  maxWorkers: 1,
91
118
  watchman: false,
92
119
  });
120
+ }
121
+ catch (e) {
122
+ const message = e instanceof Error ? e.message : String(e);
123
+ devkit_1.logger.warn(`Could not create Jest context for "${jestConfigFile}": ${message}. Skipping this project for matcher alias replacement.`);
124
+ return null;
125
+ }
126
+ let specs;
127
+ try {
93
128
  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
- }
129
+ specs = await source.getTestPaths(config.globalConfig, config.projectConfig);
98
130
  }
99
- return Array.from(testFilePaths);
131
+ catch (e) {
132
+ const message = e instanceof Error ? e.message : String(e);
133
+ devkit_1.logger.warn(`Could not resolve test paths for "${jestConfigFile}": ${message}. Skipping this project for matcher alias replacement.`);
134
+ return null;
135
+ }
136
+ return specs.tests.map((t) => path_1.posix.normalize((0, path_1.relative)(tree.root, t.path)));
100
137
  }