@nx/jest 22.7.0-pr.35019.f500fd7 → 22.7.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/jest",
3
- "version": "22.7.0-pr.35019.f500fd7",
3
+ "version": "22.7.0-rc.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": {
@@ -21,7 +21,8 @@
21
21
  "Testing"
22
22
  ],
23
23
  "main": "./index.js",
24
- "typings": "./index.d.ts",
24
+ "type": "commonjs",
25
+ "types": "./index.d.ts",
25
26
  "author": "Victor Savkin",
26
27
  "license": "MIT",
27
28
  "bugs": {
@@ -37,8 +38,8 @@
37
38
  "dependencies": {
38
39
  "@jest/reporters": "^30.0.2",
39
40
  "@jest/test-result": "^30.0.2",
40
- "@nx/devkit": "22.7.0-pr.35019.f500fd7",
41
- "@nx/js": "22.7.0-pr.35019.f500fd7",
41
+ "@nx/devkit": "22.7.0-rc.0",
42
+ "@nx/js": "22.7.0-rc.0",
42
43
  "@phenomnomnominal/tsquery": "~6.1.4",
43
44
  "identity-obj-proxy": "3.0.0",
44
45
  "jest-config": "^30.0.2",
@@ -52,11 +53,9 @@
52
53
  "yargs-parser": "21.1.1"
53
54
  },
54
55
  "devDependencies": {
55
- "nx": "22.7.0-pr.35019.f500fd7"
56
+ "nx": "22.7.0-rc.0"
56
57
  },
57
58
  "publishConfig": {
58
59
  "access": "public"
59
- },
60
- "types": "./index.d.ts",
61
- "type": "commonjs"
60
+ }
62
61
  }
@@ -18,6 +18,10 @@ function getCompilerSetup(rootDir) {
18
18
  const readResult = ts.readConfigFile(tsConfigPath, ts.sys.readFile);
19
19
  const config = ts.parseJsonConfigFileContent(readResult.config, ts.sys, (0, path_1.dirname)(tsConfigPath));
20
20
  const compilerOptions = config.options;
21
+ if (!compilerOptions.baseUrl) {
22
+ const { resolvePathsBaseUrl, } = require('@nx/js/src/utils/typescript/ts-config');
23
+ compilerOptions.baseUrl = resolvePathsBaseUrl(tsConfigPath);
24
+ }
21
25
  const host = ts.createCompilerHost(compilerOptions, true);
22
26
  return { compilerOptions, host };
23
27
  }
@@ -1,231 +1,231 @@
1
1
  {
2
- "version": 2,
3
- "outputCapture": "direct-nodejs",
4
- "title": "Jest Builder",
5
- "description": "Jest target options for Build Facade.",
6
- "cli": "nx",
7
- "type": "object",
8
- "presets": [
9
- {
10
- "name": "Pass Without Tests",
11
- "keys": ["jestConfig", "passWithNoTests"]
12
- },
13
- {
14
- "name": "Code Coverage",
15
- "keys": ["jestConfig", "coverageReporters"]
16
- },
17
- {
18
- "name": "Stop After 'n' Failed",
19
- "keys": ["jestConfig", "bail"]
20
- }
21
- ],
22
- "properties": {
23
- "codeCoverage": {
24
- "description": "Indicates that test coverage information should be collected and reported in the output. (https://jestjs.io/docs/cli#--coverageboolean)",
25
- "type": "boolean",
26
- "aliases": ["coverage"]
27
- },
28
- "config": {
29
- "description": "The path to a Jest config file specifying how to find and execute tests. If no `rootDir` is set in the config, the directory containing the config file is assumed to be the `rootDir` for the project. This can also be a JSON-encoded value which Jest will use as configuration.",
30
- "type": "string"
31
- },
32
- "clearCache": {
33
- "description": "Deletes the Jest cache directory and then exits without running tests. Will delete Jest's default cache directory. _Note: clearing the cache will reduce performance_.",
34
- "type": "boolean"
35
- },
36
- "detectOpenHandles": {
37
- "description": "Attempt to collect and print open handles preventing Jest from exiting cleanly (https://jestjs.io/docs/cli#--detectopenhandles)",
38
- "type": "boolean"
39
- },
40
- "logHeapUsage": {
41
- "description": "Logs the heap usage after every test. Useful to debug memory leaks. Use together with --runInBand and --expose-gc in node.",
42
- "type": "boolean"
43
- },
44
- "detectLeaks": {
45
- "description": "**EXPERIMENTAL**: Detect memory leaks in tests. After executing a test, it will try to garbage collect the global object used, and fail if it was leaked",
46
- "type": "boolean"
47
- },
48
- "jestConfig": {
49
- "description": "The path of the Jest configuration. (https://jestjs.io/docs/en/configuration)",
50
- "type": "string",
51
- "x-completion-type": "file",
52
- "x-completion-glob": "jest.config@(.js|.ts)"
53
- },
54
- "testFile": {
55
- "description": "The name of the file to test.",
56
- "type": "string",
57
- "$default": {
58
- "$source": "argv",
59
- "index": 0
60
- }
61
- },
62
- "tsConfig": {
63
- "description": "The path to the TypeScript configuration file, relative to the workspace root. Note this is only metadata used by Angular migrations. This executor does not use it.",
64
- "type": "string",
65
- "x-completion-type": "file",
66
- "x-completion-glob": "tsconfig.*.json"
67
- },
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
- "bail": {
74
- "alias": "b",
75
- "description": "Exit the test suite immediately after `n` number of failing tests. (https://jestjs.io/docs/cli#--bail)",
76
- "oneOf": [
2
+ "version": 2,
3
+ "outputCapture": "direct-nodejs",
4
+ "title": "Jest Builder",
5
+ "description": "Jest target options for Build Facade.",
6
+ "cli": "nx",
7
+ "type": "object",
8
+ "presets": [
77
9
  {
78
- "type": "number"
10
+ "name": "Pass Without Tests",
11
+ "keys": ["jestConfig", "passWithNoTests"]
79
12
  },
80
13
  {
81
- "type": "boolean"
82
- }
83
- ]
84
- },
85
- "ci": {
86
- "description": "Whether to run Jest in continuous integration (CI) mode. This option is on by default in most popular CI environments. It will prevent snapshots from being written unless explicitly requested. (https://jestjs.io/docs/cli#--ci)",
87
- "type": "boolean"
88
- },
89
- "color": {
90
- "alias": "colors",
91
- "description": "Forces test results output color highlighting (even if `stdout` is not a TTY). Set to false if you would like to have no colors. (https://jestjs.io/docs/cli#--colors)",
92
- "type": "boolean"
93
- },
94
- "findRelatedTests": {
95
- "description": "Find and run the tests that cover a comma separated list of source files that were passed in as arguments. (https://jestjs.io/docs/cli#--findrelatedtests-spaceseparatedlistofsourcefiles)",
96
- "type": "string"
97
- },
98
- "forceExit": {
99
- "description": "Force Jest to exit after all tests have completed running. This is useful when resources set up by test code cannot be adequately cleaned up.This feature is an escape-hatch. If Jest doesn't exit at the end of a test run, it means external resources are still being held on to or timers are still pending in your code. It is advised to tear down external resources after each test to make sure Jest can shut down cleanly. You can use --detectOpenHandles to help track it down.",
100
- "type": "boolean"
101
- },
102
- "json": {
103
- "description": "Prints the test results in `JSON`. This mode will send all other test output and user messages to `stderr`. (https://jestjs.io/docs/cli#--json)",
104
- "type": "boolean"
105
- },
106
- "maxWorkers": {
107
- "alias": "w",
108
- "description": "Specifies the maximum number of workers the worker-pool will spawn for running tests. This defaults to the number of the cores available on your machine. Useful for CI. (its usually best not to override this default) (https://jestjs.io/docs/cli#--maxworkersnumstring)",
109
- "oneOf": [
110
- {
111
- "type": "number"
14
+ "name": "Code Coverage",
15
+ "keys": ["jestConfig", "coverageReporters"]
112
16
  },
113
17
  {
114
- "type": "string"
18
+ "name": "Stop After 'n' Failed",
19
+ "keys": ["jestConfig", "bail"]
20
+ }
21
+ ],
22
+ "properties": {
23
+ "codeCoverage": {
24
+ "description": "Indicates that test coverage information should be collected and reported in the output. (https://jestjs.io/docs/cli#--coverageboolean)",
25
+ "type": "boolean",
26
+ "aliases": ["coverage"]
27
+ },
28
+ "config": {
29
+ "description": "The path to a Jest config file specifying how to find and execute tests. If no `rootDir` is set in the config, the directory containing the config file is assumed to be the `rootDir` for the project. This can also be a JSON-encoded value which Jest will use as configuration.",
30
+ "type": "string"
31
+ },
32
+ "clearCache": {
33
+ "description": "Deletes the Jest cache directory and then exits without running tests. Will delete Jest's default cache directory. _Note: clearing the cache will reduce performance_.",
34
+ "type": "boolean"
35
+ },
36
+ "detectOpenHandles": {
37
+ "description": "Attempt to collect and print open handles preventing Jest from exiting cleanly (https://jestjs.io/docs/cli#--detectopenhandles)",
38
+ "type": "boolean"
39
+ },
40
+ "logHeapUsage": {
41
+ "description": "Logs the heap usage after every test. Useful to debug memory leaks. Use together with --runInBand and --expose-gc in node.",
42
+ "type": "boolean"
43
+ },
44
+ "detectLeaks": {
45
+ "description": "**EXPERIMENTAL**: Detect memory leaks in tests. After executing a test, it will try to garbage collect the global object used, and fail if it was leaked",
46
+ "type": "boolean"
47
+ },
48
+ "jestConfig": {
49
+ "description": "The path of the Jest configuration. (https://jestjs.io/docs/en/configuration)",
50
+ "type": "string",
51
+ "x-completion-type": "file",
52
+ "x-completion-glob": "jest.config@(.js|.ts)"
53
+ },
54
+ "testFile": {
55
+ "description": "The name of the file to test.",
56
+ "type": "string",
57
+ "$default": {
58
+ "$source": "argv",
59
+ "index": 0
60
+ }
61
+ },
62
+ "tsConfig": {
63
+ "description": "The path to the TypeScript configuration file, relative to the workspace root. Note this is only metadata used by Angular migrations. This executor does not use it.",
64
+ "type": "string",
65
+ "x-completion-type": "file",
66
+ "x-completion-glob": "tsconfig.*.json"
67
+ },
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
+ "bail": {
74
+ "alias": "b",
75
+ "description": "Exit the test suite immediately after `n` number of failing tests. (https://jestjs.io/docs/cli#--bail)",
76
+ "oneOf": [
77
+ {
78
+ "type": "number"
79
+ },
80
+ {
81
+ "type": "boolean"
82
+ }
83
+ ]
84
+ },
85
+ "ci": {
86
+ "description": "Whether to run Jest in continuous integration (CI) mode. This option is on by default in most popular CI environments. It will prevent snapshots from being written unless explicitly requested. (https://jestjs.io/docs/cli#--ci)",
87
+ "type": "boolean"
88
+ },
89
+ "color": {
90
+ "alias": "colors",
91
+ "description": "Forces test results output color highlighting (even if `stdout` is not a TTY). Set to false if you would like to have no colors. (https://jestjs.io/docs/cli#--colors)",
92
+ "type": "boolean"
93
+ },
94
+ "findRelatedTests": {
95
+ "description": "Find and run the tests that cover a comma separated list of source files that were passed in as arguments. (https://jestjs.io/docs/cli#--findrelatedtests-spaceseparatedlistofsourcefiles)",
96
+ "type": "string"
97
+ },
98
+ "forceExit": {
99
+ "description": "Force Jest to exit after all tests have completed running. This is useful when resources set up by test code cannot be adequately cleaned up.This feature is an escape-hatch. If Jest doesn't exit at the end of a test run, it means external resources are still being held on to or timers are still pending in your code. It is advised to tear down external resources after each test to make sure Jest can shut down cleanly. You can use --detectOpenHandles to help track it down.",
100
+ "type": "boolean"
101
+ },
102
+ "json": {
103
+ "description": "Prints the test results in `JSON`. This mode will send all other test output and user messages to `stderr`. (https://jestjs.io/docs/cli#--json)",
104
+ "type": "boolean"
105
+ },
106
+ "maxWorkers": {
107
+ "alias": "w",
108
+ "description": "Specifies the maximum number of workers the worker-pool will spawn for running tests. This defaults to the number of the cores available on your machine. Useful for CI. (its usually best not to override this default) (https://jestjs.io/docs/cli#--maxworkersnumstring)",
109
+ "oneOf": [
110
+ {
111
+ "type": "number"
112
+ },
113
+ {
114
+ "type": "string"
115
+ }
116
+ ]
117
+ },
118
+ "onlyChanged": {
119
+ "alias": "o",
120
+ "description": "Attempts to identify which tests to run based on which files have changed in the current repository. Only works if you're running tests in a `git` or `hg` repository at the moment. (https://jestjs.io/docs/cli#--onlychanged)",
121
+ "type": "boolean"
122
+ },
123
+ "changedSince": {
124
+ "description": "Runs tests related to the changes since the provided branch or commit hash. If the current branch has diverged from the given branch, then only changes made locally will be tested. (https://jestjs.io/docs/cli#--changedsince)",
125
+ "type": "string"
126
+ },
127
+ "outputFile": {
128
+ "description": "Write test results to a file when the `--json` option is also specified. (https://jestjs.io/docs/cli#--outputfilefilename)",
129
+ "type": "string"
130
+ },
131
+ "passWithNoTests": {
132
+ "description": "Will not fail if no tests are found (for example while using `--testPathPatterns`.) (https://jestjs.io/docs/cli#--passwithnotests)",
133
+ "type": "boolean"
134
+ },
135
+ "randomize": {
136
+ "description": "Shuffle the order of the tests within a file. The shuffling is based on the seed. This option is only supported using the default jest-circus test runner.",
137
+ "type": "boolean"
138
+ },
139
+ "runInBand": {
140
+ "alias": "i",
141
+ "description": "Run all tests serially in the current process (rather than creating a worker pool of child processes that run tests). This is sometimes useful for debugging, but such use cases are pretty rare. Useful for CI. (https://jestjs.io/docs/cli#--runinband)",
142
+ "type": "boolean"
143
+ },
144
+ "showConfig": {
145
+ "description": "Print your Jest config and then exits. (https://jestjs.io/docs/en/cli#--showconfig)",
146
+ "type": "boolean"
147
+ },
148
+ "silent": {
149
+ "description": "Prevent tests from printing messages through the console. (https://jestjs.io/docs/cli#--silent)",
150
+ "type": "boolean"
151
+ },
152
+ "testNamePattern": {
153
+ "alias": "t",
154
+ "description": "Run only tests with a name that matches the regex pattern. (https://jestjs.io/docs/cli#--testnamepatternregex)",
155
+ "type": "string"
156
+ },
157
+ "testPathIgnorePatterns": {
158
+ "description": "An array of regexp pattern strings that is matched against all tests paths before executing the test. Only run those tests with a path that does not match with the provided regexp expressions. (https://jestjs.io/docs/cli#--testpathignorepatternsregexarray)",
159
+ "type": "array",
160
+ "items": {
161
+ "type": "string"
162
+ }
163
+ },
164
+ "testPathPatterns": {
165
+ "description": "An array of regexp pattern strings that is matched against all tests paths before executing the test. (https://jestjs.io/docs/cli#--testpathpatternsregex)",
166
+ "type": "array",
167
+ "items": {
168
+ "type": "string"
169
+ },
170
+ "default": []
171
+ },
172
+ "colors": {
173
+ "description": "Forces test results output highlighting even if stdout is not a TTY. (https://jestjs.io/docs/cli#--colors)",
174
+ "type": "boolean"
175
+ },
176
+ "reporters": {
177
+ "description": "Run tests with specified reporters. Reporter options are not available via CLI. Example with multiple reporters: `jest --reporters=\"default\" --reporters=\"jest-junit\"`. (https://jestjs.io/docs/cli#--reporters)",
178
+ "type": "array",
179
+ "items": {
180
+ "type": "string"
181
+ }
182
+ },
183
+ "verbose": {
184
+ "description": "Display individual test results with the test suite hierarchy. (https://jestjs.io/docs/cli#--verbose)",
185
+ "type": "boolean"
186
+ },
187
+ "coverageReporters": {
188
+ "description": "A list of reporter names that Jest uses when writing coverage reports. Any istanbul reporter.",
189
+ "type": "array",
190
+ "items": {
191
+ "type": "string"
192
+ }
193
+ },
194
+ "coverageDirectory": {
195
+ "description": "The directory where Jest should output its coverage files.",
196
+ "type": "string",
197
+ "x-completion-type": "directory"
198
+ },
199
+ "testResultsProcessor": {
200
+ "description": "Node module that implements a custom results processor. (https://jestjs.io/docs/en/configuration#testresultsprocessor-string)",
201
+ "type": "string"
202
+ },
203
+ "updateSnapshot": {
204
+ "alias": "u",
205
+ "description": "Use this flag to re-record snapshots. Can be used together with a test suite pattern or with `--testNamePattern` to re-record snapshot for test matching the pattern. (https://jestjs.io/docs/cli#--updatesnapshot)",
206
+ "type": "boolean"
207
+ },
208
+ "useStderr": {
209
+ "description": "Divert all output to stderr.",
210
+ "type": "boolean"
211
+ },
212
+ "watch": {
213
+ "description": "Watch files for changes and rerun tests related to changed files. If you want to re-run all tests when a file has changed, use the `--watchAll` option. (https://jestjs.io/docs/cli#--watch)",
214
+ "type": "boolean"
215
+ },
216
+ "watchAll": {
217
+ "description": "Watch files for changes and rerun all tests when something changes. If you want to re-run only the tests that depend on the changed files, use the `--watch` option. (https://jestjs.io/docs/cli#--watchall)",
218
+ "type": "boolean"
219
+ },
220
+ "testLocationInResults": {
221
+ "description": "Adds a location field to test results. Used to report location of a test in a reporter. { \"column\": 4, \"line\": 5 } (https://jestjs.io/docs/cli#--testlocationinresults)",
222
+ "type": "boolean"
223
+ },
224
+ "testTimeout": {
225
+ "description": "Default timeout of a test in milliseconds. Default value: `5000`. (https://jestjs.io/docs/cli#--testtimeoutnumber)",
226
+ "type": "number"
115
227
  }
116
- ]
117
- },
118
- "onlyChanged": {
119
- "alias": "o",
120
- "description": "Attempts to identify which tests to run based on which files have changed in the current repository. Only works if you're running tests in a `git` or `hg` repository at the moment. (https://jestjs.io/docs/cli#--onlychanged)",
121
- "type": "boolean"
122
- },
123
- "changedSince": {
124
- "description": "Runs tests related to the changes since the provided branch or commit hash. If the current branch has diverged from the given branch, then only changes made locally will be tested. (https://jestjs.io/docs/cli#--changedsince)",
125
- "type": "string"
126
- },
127
- "outputFile": {
128
- "description": "Write test results to a file when the `--json` option is also specified. (https://jestjs.io/docs/cli#--outputfilefilename)",
129
- "type": "string"
130
- },
131
- "passWithNoTests": {
132
- "description": "Will not fail if no tests are found (for example while using `--testPathPatterns`.) (https://jestjs.io/docs/cli#--passwithnotests)",
133
- "type": "boolean"
134
- },
135
- "randomize": {
136
- "description": "Shuffle the order of the tests within a file. The shuffling is based on the seed. This option is only supported using the default jest-circus test runner.",
137
- "type": "boolean"
138
- },
139
- "runInBand": {
140
- "alias": "i",
141
- "description": "Run all tests serially in the current process (rather than creating a worker pool of child processes that run tests). This is sometimes useful for debugging, but such use cases are pretty rare. Useful for CI. (https://jestjs.io/docs/cli#--runinband)",
142
- "type": "boolean"
143
- },
144
- "showConfig": {
145
- "description": "Print your Jest config and then exits. (https://jestjs.io/docs/en/cli#--showconfig)",
146
- "type": "boolean"
147
- },
148
- "silent": {
149
- "description": "Prevent tests from printing messages through the console. (https://jestjs.io/docs/cli#--silent)",
150
- "type": "boolean"
151
- },
152
- "testNamePattern": {
153
- "alias": "t",
154
- "description": "Run only tests with a name that matches the regex pattern. (https://jestjs.io/docs/cli#--testnamepatternregex)",
155
- "type": "string"
156
- },
157
- "testPathIgnorePatterns": {
158
- "description": "An array of regexp pattern strings that is matched against all tests paths before executing the test. Only run those tests with a path that does not match with the provided regexp expressions. (https://jestjs.io/docs/cli#--testpathignorepatternsregexarray)",
159
- "type": "array",
160
- "items": {
161
- "type": "string"
162
- }
163
- },
164
- "testPathPatterns": {
165
- "description": "An array of regexp pattern strings that is matched against all tests paths before executing the test. (https://jestjs.io/docs/cli#--testpathpatternsregex)",
166
- "type": "array",
167
- "items": {
168
- "type": "string"
169
- },
170
- "default": []
171
- },
172
- "colors": {
173
- "description": "Forces test results output highlighting even if stdout is not a TTY. (https://jestjs.io/docs/cli#--colors)",
174
- "type": "boolean"
175
- },
176
- "reporters": {
177
- "description": "Run tests with specified reporters. Reporter options are not available via CLI. Example with multiple reporters: `jest --reporters=\"default\" --reporters=\"jest-junit\"`. (https://jestjs.io/docs/cli#--reporters)",
178
- "type": "array",
179
- "items": {
180
- "type": "string"
181
- }
182
- },
183
- "verbose": {
184
- "description": "Display individual test results with the test suite hierarchy. (https://jestjs.io/docs/cli#--verbose)",
185
- "type": "boolean"
186
- },
187
- "coverageReporters": {
188
- "description": "A list of reporter names that Jest uses when writing coverage reports. Any istanbul reporter.",
189
- "type": "array",
190
- "items": {
191
- "type": "string"
192
- }
193
- },
194
- "coverageDirectory": {
195
- "description": "The directory where Jest should output its coverage files.",
196
- "type": "string",
197
- "x-completion-type": "directory"
198
- },
199
- "testResultsProcessor": {
200
- "description": "Node module that implements a custom results processor. (https://jestjs.io/docs/en/configuration#testresultsprocessor-string)",
201
- "type": "string"
202
- },
203
- "updateSnapshot": {
204
- "alias": "u",
205
- "description": "Use this flag to re-record snapshots. Can be used together with a test suite pattern or with `--testNamePattern` to re-record snapshot for test matching the pattern. (https://jestjs.io/docs/cli#--updatesnapshot)",
206
- "type": "boolean"
207
- },
208
- "useStderr": {
209
- "description": "Divert all output to stderr.",
210
- "type": "boolean"
211
- },
212
- "watch": {
213
- "description": "Watch files for changes and rerun tests related to changed files. If you want to re-run all tests when a file has changed, use the `--watchAll` option. (https://jestjs.io/docs/cli#--watch)",
214
- "type": "boolean"
215
- },
216
- "watchAll": {
217
- "description": "Watch files for changes and rerun all tests when something changes. If you want to re-run only the tests that depend on the changed files, use the `--watch` option. (https://jestjs.io/docs/cli#--watchall)",
218
- "type": "boolean"
219
- },
220
- "testLocationInResults": {
221
- "description": "Adds a location field to test results. Used to report location of a test in a reporter. { \"column\": 4, \"line\": 5 } (https://jestjs.io/docs/cli#--testlocationinresults)",
222
- "type": "boolean"
223
228
  },
224
- "testTimeout": {
225
- "description": "Default timeout of a test in milliseconds. Default value: `5000`. (https://jestjs.io/docs/cli#--testtimeoutnumber)",
226
- "type": "number"
227
- }
228
- },
229
- "required": ["jestConfig"],
230
- "examplesFile": "../../../docs/jest-examples.md"
229
+ "required": ["jestConfig"],
230
+ "examplesFile": "../../../docs/jest-examples.md"
231
231
  }
@@ -1,90 +1,90 @@
1
1
  {
2
- "$schema": "https://json-schema.org/schema",
3
- "$id": "NxJestProject",
4
- "cli": "nx",
5
- "title": "Add Jest Configuration to a project",
6
- "description": "Add Jest Configuration to a project.",
7
- "type": "object",
8
- "properties": {
9
- "project": {
10
- "type": "string",
11
- "description": "The name of the project.",
12
- "$default": {
13
- "$source": "projectName"
14
- },
15
- "x-priority": "important"
2
+ "$schema": "https://json-schema.org/schema",
3
+ "$id": "NxJestProject",
4
+ "cli": "nx",
5
+ "title": "Add Jest Configuration to a project",
6
+ "description": "Add Jest Configuration to a project.",
7
+ "type": "object",
8
+ "properties": {
9
+ "project": {
10
+ "type": "string",
11
+ "description": "The name of the project.",
12
+ "$default": {
13
+ "$source": "projectName"
14
+ },
15
+ "x-priority": "important"
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
+ "setupFile": {
24
+ "type": "string",
25
+ "enum": ["none", "angular", "web-components"],
26
+ "description": "The setup file to be generated.",
27
+ "default": "none",
28
+ "x-priority": "important"
29
+ },
30
+ "skipSerializers": {
31
+ "type": "boolean",
32
+ "description": "Skips the serializers required to snapshot angular templates.",
33
+ "default": false
34
+ },
35
+ "supportTsx": {
36
+ "type": "boolean",
37
+ "description": "Setup `tsx` support.",
38
+ "default": false,
39
+ "x-priority": "important"
40
+ },
41
+ "testEnvironment": {
42
+ "type": "string",
43
+ "enum": ["jsdom", "node", "none"],
44
+ "description": "The test environment for jest.",
45
+ "default": "jsdom",
46
+ "x-priority": "important"
47
+ },
48
+ "compiler": {
49
+ "type": "string",
50
+ "enum": ["tsc", "babel", "swc"],
51
+ "description": "The compiler to use for source and tests.",
52
+ "default": "tsc"
53
+ },
54
+ "babelJest": {
55
+ "type": "boolean",
56
+ "alias": "babel-jest",
57
+ "description": "Use `babel-jest` instead of `ts-jest`.",
58
+ "x-deprecated": "Use the `compiler` option instead. It will be removed in Nx v22.",
59
+ "default": false
60
+ },
61
+ "skipFormat": {
62
+ "description": "Skip formatting files",
63
+ "type": "boolean",
64
+ "default": false,
65
+ "x-priority": "internal"
66
+ },
67
+ "skipPackageJson": {
68
+ "type": "boolean",
69
+ "default": false,
70
+ "description": "Do not add dependencies to `package.json`.",
71
+ "x-priority": "internal"
72
+ },
73
+ "js": {
74
+ "type": "boolean",
75
+ "default": false,
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."
81
+ },
82
+ "keepExistingVersions": {
83
+ "type": "boolean",
84
+ "x-priority": "internal",
85
+ "description": "Keep existing dependencies versions",
86
+ "default": true
87
+ }
16
88
  },
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
- "setupFile": {
24
- "type": "string",
25
- "enum": ["none", "angular", "web-components"],
26
- "description": "The setup file to be generated.",
27
- "default": "none",
28
- "x-priority": "important"
29
- },
30
- "skipSerializers": {
31
- "type": "boolean",
32
- "description": "Skips the serializers required to snapshot angular templates.",
33
- "default": false
34
- },
35
- "supportTsx": {
36
- "type": "boolean",
37
- "description": "Setup `tsx` support.",
38
- "default": false,
39
- "x-priority": "important"
40
- },
41
- "testEnvironment": {
42
- "type": "string",
43
- "enum": ["jsdom", "node", "none"],
44
- "description": "The test environment for jest.",
45
- "default": "jsdom",
46
- "x-priority": "important"
47
- },
48
- "compiler": {
49
- "type": "string",
50
- "enum": ["tsc", "babel", "swc"],
51
- "description": "The compiler to use for source and tests.",
52
- "default": "tsc"
53
- },
54
- "babelJest": {
55
- "type": "boolean",
56
- "alias": "babel-jest",
57
- "description": "Use `babel-jest` instead of `ts-jest`.",
58
- "x-deprecated": "Use the `compiler` option instead. It will be removed in Nx v22.",
59
- "default": false
60
- },
61
- "skipFormat": {
62
- "description": "Skip formatting files",
63
- "type": "boolean",
64
- "default": false,
65
- "x-priority": "internal"
66
- },
67
- "skipPackageJson": {
68
- "type": "boolean",
69
- "default": false,
70
- "description": "Do not add dependencies to `package.json`.",
71
- "x-priority": "internal"
72
- },
73
- "js": {
74
- "type": "boolean",
75
- "default": false,
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."
81
- },
82
- "keepExistingVersions": {
83
- "type": "boolean",
84
- "x-priority": "internal",
85
- "description": "Keep existing dependencies versions",
86
- "default": true
87
- }
88
- },
89
- "required": []
89
+ "required": []
90
90
  }
@@ -1,19 +1,19 @@
1
1
  {
2
- "$schema": "https://json-schema.org/schema",
3
- "$id": "NxJestConvertToInferred",
4
- "description": "Convert existing Jest project(s) using `@nx/jest:jest` executor to use `@nx/jest/plugin`.",
5
- "title": "Convert Jest project from executor to plugin",
6
- "type": "object",
7
- "properties": {
8
- "project": {
9
- "type": "string",
10
- "description": "The project to convert from using the `@nx/jest:jest` executor to use `@nx/jest/plugin`. If not provided, all projects using the `@nx/jest:jest` executor will be converted.",
11
- "x-priority": "important"
12
- },
13
- "skipFormat": {
14
- "type": "boolean",
15
- "description": "Whether to format files.",
16
- "default": false
2
+ "$schema": "https://json-schema.org/schema",
3
+ "$id": "NxJestConvertToInferred",
4
+ "description": "Convert existing Jest project(s) using `@nx/jest:jest` executor to use `@nx/jest/plugin`.",
5
+ "title": "Convert Jest project from executor to plugin",
6
+ "type": "object",
7
+ "properties": {
8
+ "project": {
9
+ "type": "string",
10
+ "description": "The project to convert from using the `@nx/jest:jest` executor to use `@nx/jest/plugin`. If not provided, all projects using the `@nx/jest:jest` executor will be converted.",
11
+ "x-priority": "important"
12
+ },
13
+ "skipFormat": {
14
+ "type": "boolean",
15
+ "description": "Whether to format files.",
16
+ "default": false
17
+ }
17
18
  }
18
- }
19
19
  }
@@ -1,35 +1,35 @@
1
1
  {
2
- "$schema": "https://json-schema.org/schema",
3
- "$id": "NxJestInit",
4
- "cli": "nx",
5
- "title": "Jest init",
6
- "description": "Add Jest Configuration to a workspace.",
7
- "type": "object",
8
- "properties": {
9
- "skipFormat": {
10
- "description": "Skip formatting files.",
11
- "type": "boolean",
12
- "default": false,
13
- "x-priority": "internal"
2
+ "$schema": "https://json-schema.org/schema",
3
+ "$id": "NxJestInit",
4
+ "cli": "nx",
5
+ "title": "Jest init",
6
+ "description": "Add Jest Configuration to a workspace.",
7
+ "type": "object",
8
+ "properties": {
9
+ "skipFormat": {
10
+ "description": "Skip formatting files.",
11
+ "type": "boolean",
12
+ "default": false,
13
+ "x-priority": "internal"
14
+ },
15
+ "skipPackageJson": {
16
+ "type": "boolean",
17
+ "default": false,
18
+ "description": "Do not add dependencies to `package.json`.",
19
+ "x-priority": "internal"
20
+ },
21
+ "keepExistingVersions": {
22
+ "type": "boolean",
23
+ "x-priority": "internal",
24
+ "description": "Keep existing dependencies versions",
25
+ "default": false
26
+ },
27
+ "updatePackageScripts": {
28
+ "type": "boolean",
29
+ "x-priority": "internal",
30
+ "description": "Update `package.json` scripts with inferred targets",
31
+ "default": false
32
+ }
14
33
  },
15
- "skipPackageJson": {
16
- "type": "boolean",
17
- "default": false,
18
- "description": "Do not add dependencies to `package.json`.",
19
- "x-priority": "internal"
20
- },
21
- "keepExistingVersions": {
22
- "type": "boolean",
23
- "x-priority": "internal",
24
- "description": "Keep existing dependencies versions",
25
- "default": false
26
- },
27
- "updatePackageScripts": {
28
- "type": "boolean",
29
- "x-priority": "internal",
30
- "description": "Update `package.json` scripts with inferred targets",
31
- "default": false
32
- }
33
- },
34
- "required": []
34
+ "required": []
35
35
  }
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../../packages/jest/src/plugins/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,aAAa,EASd,MAAM,YAAY,CAAC;AA6BpB,MAAM,WAAW,iBAAiB;IAChC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B;;;;;;;;OAQG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAmBD,eAAO,MAAM,WAAW,EAAE,aAAa,CAAC,iBAAiB,CAiFxD,CAAC;AAEF,eAAO,MAAM,aAAa,kCAAc,CAAC"}
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../../packages/jest/src/plugins/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,aAAa,EAUd,MAAM,YAAY,CAAC;AAiCpB,MAAM,WAAW,iBAAiB;IAChC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B;;;;;;;;OAQG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAwBD,eAAO,MAAM,WAAW,EAAE,aAAa,CAAC,iBAAiB,CA8IxD,CAAC;AAEF,eAAO,MAAM,aAAa,kCAAc,CAAC"}
@@ -15,8 +15,9 @@ const globs_1 = require("nx/src/utils/globs");
15
15
  const installation_directory_1 = require("nx/src/utils/installation-directory");
16
16
  const plugins_1 = require("nx/src/utils/plugins");
17
17
  const workspace_context_1 = require("nx/src/utils/workspace-context");
18
+ const js_1 = require("@nx/js");
19
+ const internal_1 = require("@nx/js/src/internal");
18
20
  const versions_1 = require("../utils/versions");
19
- const pmc = (0, devkit_1.getPackageManagerCommand)();
20
21
  const REPORTER_BUILTINS = new Set(['default', 'github-actions', 'summary']);
21
22
  function readTargetsCache(cachePath) {
22
23
  return process.env.NX_CACHE_PROJECT_GRAPH !== 'false' && (0, node_fs_1.existsSync)(cachePath)
@@ -35,8 +36,15 @@ exports.createNodes = [
35
36
  const targetsCache = readTargetsCache(cachePath);
36
37
  // Cache jest preset(s) to avoid penalties of module load times. Most of jest configs will use the same preset.
37
38
  const presetCache = {};
39
+ // Cache tsconfig reads + isolatedModules resolution. Many projects share
40
+ // the same base tsconfig in their extends chain — read each file once.
41
+ const tsconfigJsonCache = new Map();
42
+ const tsconfigExistsCache = new Map();
43
+ const isolatedModulesCache = new Map();
38
44
  const isInPackageManagerWorkspaces = buildPackageJsonWorkspacesMatcher(context.workspaceRoot);
39
45
  options = normalizeOptions(options);
46
+ const packageManager = (0, devkit_1.detectPackageManager)(context.workspaceRoot);
47
+ const pmc = (0, devkit_1.getPackageManagerCommand)(packageManager);
40
48
  const { roots: projectRoots, configFiles: validConfigFiles } = configFiles.reduce((acc, configFile) => {
41
49
  const potentialRoot = (0, node_path_1.dirname)(configFile);
42
50
  if (checkIfConfigFileShouldBeProject(configFile, potentialRoot, isInPackageManagerWorkspaces, context)) {
@@ -48,12 +56,47 @@ exports.createNodes = [
48
56
  roots: [],
49
57
  configFiles: [],
50
58
  });
51
- const hashes = await (0, calculate_hash_for_create_nodes_1.calculateHashesForCreateNodes)(projectRoots, options, context);
59
+ const lockFilePattern = (0, js_1.getLockFileName)(packageManager);
60
+ // Load configs in parallel. `loadConfigFile` calls `registerTsProject`,
61
+ // whose transpiler dedup is refcounted: serial register/unregister cycles
62
+ // drop refCount to 0 between iterations and recreate a fresh ts-node
63
+ // service each time (ts-node has no cleanup — see
64
+ // packages/nx/src/plugins/js/utils/register.js), stacking N services in
65
+ // `require.extensions` and OOM'ing under NX_PREFER_TS_NODE. Parallel
66
+ // loads keep all registrations alive concurrently so the dedup holds and
67
+ // a single transpiler instance is shared.
68
+ let requireCacheCleared = false;
69
+ const loadedConfigs = await Promise.all(validConfigFiles.map(async (configFilePath, i) => {
70
+ const projectRoot = projectRoots[i];
71
+ const absConfigFilePath = (0, node_path_1.resolve)(context.workspaceRoot, configFilePath);
72
+ if (!requireCacheCleared && require.cache[absConfigFilePath]) {
73
+ (0, config_utils_1.clearRequireCache)();
74
+ requireCacheCleared = true;
75
+ }
76
+ const rawConfig = await (0, config_utils_1.loadConfigFile)(absConfigFilePath, [
77
+ 'tsconfig.spec.json',
78
+ 'tsconfig.test.json',
79
+ 'tsconfig.jest.json',
80
+ 'tsconfig.json',
81
+ ]);
82
+ const { externalFiles, needsDtsInputs } = await collectExternalFileReferences(rawConfig, absConfigFilePath, projectRoot, context.workspaceRoot, {
83
+ presetCache,
84
+ tsconfigJsonCache,
85
+ tsconfigExistsCache,
86
+ isolatedModulesCache,
87
+ });
88
+ return { rawConfig, externalFiles, needsDtsInputs };
89
+ }));
90
+ const hashes = await (0, calculate_hash_for_create_nodes_1.calculateHashesForCreateNodes)(projectRoots, options, context, loadedConfigs.map(({ externalFiles }) => [
91
+ lockFilePattern,
92
+ ...externalFiles,
93
+ ]));
52
94
  try {
53
95
  return await (0, devkit_1.createNodesFromFiles)(async (configFilePath, options, context, idx) => {
54
96
  const projectRoot = projectRoots[idx];
55
97
  const hash = hashes[idx];
56
- targetsCache[hash] ??= await buildJestTargets(configFilePath, projectRoot, options, context, presetCache);
98
+ const { rawConfig, needsDtsInputs } = loadedConfigs[idx];
99
+ targetsCache[hash] ??= await buildJestTargets(rawConfig, needsDtsInputs, configFilePath, projectRoot, options, context, presetCache, pmc);
57
100
  const { targets, metadata } = targetsCache[hash];
58
101
  return {
59
102
  projects: {
@@ -103,18 +146,8 @@ function checkIfConfigFileShouldBeProject(configFilePath, projectRoot, isInPacka
103
146
  }
104
147
  return true;
105
148
  }
106
- async function buildJestTargets(configFilePath, projectRoot, options, context, presetCache) {
149
+ async function buildJestTargets(rawConfig, needsDtsInputs, configFilePath, projectRoot, options, context, presetCache, pmc) {
107
150
  const absConfigFilePath = (0, node_path_1.resolve)(context.workspaceRoot, configFilePath);
108
- if (require.cache[absConfigFilePath])
109
- (0, config_utils_1.clearRequireCache)();
110
- const rawConfig = await (0, config_utils_1.loadConfigFile)(absConfigFilePath,
111
- // lookup for the same files we look for in the resolver and fall back to tsconfig.json
112
- [
113
- 'tsconfig.spec.json',
114
- 'tsconfig.test.json',
115
- 'tsconfig.jest.json',
116
- 'tsconfig.json',
117
- ]);
118
151
  const targets = {};
119
152
  const namedInputs = (0, get_named_inputs_1.getNamedInputs)(projectRoot, context);
120
153
  const tsNodeCompilerOptions = JSON.stringify({
@@ -154,7 +187,7 @@ async function buildJestTargets(configFilePath, projectRoot, options, context, p
154
187
  ? (0, node_path_1.resolve)((0, node_path_1.dirname)(absConfigFilePath), rawConfig.rootDir)
155
188
  : (0, node_path_1.resolve)(context.workspaceRoot, projectRoot);
156
189
  const cache = (target.cache = true);
157
- const inputs = (target.inputs = await getInputs(namedInputs, rawConfig, rootDir, projectRoot, context.workspaceRoot, presetCache, useJestResolver));
190
+ const inputs = (target.inputs = await getInputs(namedInputs, rawConfig, rootDir, projectRoot, context.workspaceRoot, presetCache, needsDtsInputs, useJestResolver));
158
191
  let metadata;
159
192
  const groupName = options?.ciGroupName ?? (0, plugins_1.deriveGroupNameFromTarget)(options?.ciTargetName);
160
193
  if (disableJestRuntime) {
@@ -265,7 +298,7 @@ async function buildJestTargets(configFilePath, projectRoot, options, context, p
265
298
  });
266
299
  const jest = require(resolveJestPath(projectRoot, context.workspaceRoot));
267
300
  const source = new jest.SearchSource(jestContext);
268
- const jestVersion = (0, versions_1.getInstalledJestMajorVersion)();
301
+ const jestVersion = getJestMajorVersion();
269
302
  const specs = jestVersion >= 30
270
303
  ? await source.getTestPaths(config.globalConfig, config.projectConfig)
271
304
  : // @ts-expect-error Jest v29 doesn't have the projectConfig parameter
@@ -347,7 +380,7 @@ async function buildJestTargets(configFilePath, projectRoot, options, context, p
347
380
  }
348
381
  return { targets, metadata };
349
382
  }
350
- async function getInputs(namedInputs, rawConfig, rootDir, projectRoot, workspaceRoot, presetCache, useJestResolver) {
383
+ async function getInputs(namedInputs, rawConfig, rootDir, projectRoot, workspaceRoot, presetCache, needsDtsInputs, useJestResolver) {
351
384
  const inputs = [
352
385
  ...('production' in namedInputs
353
386
  ? ['default', '^production']
@@ -388,6 +421,16 @@ async function getInputs(namedInputs, rawConfig, rootDir, projectRoot, workspace
388
421
  }
389
422
  }
390
423
  inputs.push({ externalDependencies });
424
+ // When ts-jest runs without isolatedModules, it creates a TypeScript
425
+ // Language Service that reads .d.ts files from dependency projects.
426
+ // Declare these as dependentTasksOutputFiles so changes to dependency
427
+ // type declarations correctly invalidate the test cache.
428
+ if (needsDtsInputs) {
429
+ inputs.push({
430
+ dependentTasksOutputFiles: '**/*.d.ts',
431
+ transitive: true,
432
+ });
433
+ }
391
434
  return inputs;
392
435
  }
393
436
  function resolvePresetInputWithoutJestResolver(presetValue, rootDir, projectRoot, workspaceRoot) {
@@ -568,6 +611,96 @@ async function getTestPaths(projectRoot, rawConfig, rootDir, context, presetCach
568
611
  }
569
612
  return { specs: paths, testMatch };
570
613
  }
614
+ /**
615
+ * Collects workspace-relative paths to files whose CONTENT the plugin reads
616
+ * when computing inferred targets and that live OUTSIDE the project root.
617
+ *
618
+ * Only two kinds of files qualify:
619
+ * - The jest preset (loaded to read its `transform`, etc.)
620
+ * - Tsconfig files in the extends chain referenced by ts-jest (read to
621
+ * determine `isolatedModules`); only walked when ts-jest is not already
622
+ * known to be in isolated mode.
623
+ *
624
+ * Other config references (setup files, custom resolvers, transformers,
625
+ * etc.) are NOT collected — the plugin only resolves their paths and emits
626
+ * them as task inputs; their content is not read by the plugin, so changes
627
+ * to them don't influence inference.
628
+ */
629
+ async function collectExternalFileReferences(rawConfig, absConfigFilePath, projectRoot, workspaceRoot, caches) {
630
+ const { presetCache, tsconfigJsonCache, tsconfigExistsCache, isolatedModulesCache, } = caches;
631
+ const absWorkspaceRoot = (0, node_path_1.resolve)(workspaceRoot);
632
+ const rootDir = rawConfig.rootDir
633
+ ? (0, node_path_1.resolve)((0, node_path_1.dirname)(absConfigFilePath), rawConfig.rootDir)
634
+ : (0, node_path_1.resolve)(absWorkspaceRoot, projectRoot);
635
+ const absoluteProjectRoot = (0, node_path_1.resolve)(absWorkspaceRoot, projectRoot);
636
+ const externalFiles = new Set();
637
+ const addIfExternal = (absolutePath) => {
638
+ if (!absolutePath)
639
+ return;
640
+ const rel = (0, devkit_1.normalizePath)((0, node_path_1.relative)(absWorkspaceRoot, absolutePath));
641
+ if (rel.startsWith('..') || (0, node_path_1.isAbsolute)(rel))
642
+ return; // outside workspace
643
+ if (rel.includes('node_modules/'))
644
+ return; // covered by lockfile
645
+ const relToProject = (0, devkit_1.normalizePath)((0, node_path_1.relative)(absoluteProjectRoot, absolutePath));
646
+ if (!relToProject.startsWith('..') && !(0, node_path_1.isAbsolute)(relToProject))
647
+ return; // inside project root
648
+ externalFiles.add(rel);
649
+ };
650
+ // Preset path (content is loaded by the plugin to merge with rawConfig)
651
+ if (typeof rawConfig.preset === 'string') {
652
+ const replaced = replaceRootDirInPath(rootDir, rawConfig.preset);
653
+ if (replaced.startsWith('.') || (0, node_path_1.isAbsolute)(replaced)) {
654
+ addIfExternal((0, node_path_1.resolve)(rootDir, replaced));
655
+ }
656
+ }
657
+ // ts-jest tsconfig extends chain — only walked when ts-jest is in
658
+ // non-isolated mode (otherwise the chain doesn't influence the output).
659
+ // Loading the preset is required to merge its transform with the raw
660
+ // config, since presets are the common source of ts-jest configuration.
661
+ const presetConfig = await loadPresetConfig(rawConfig, rootDir, presetCache);
662
+ const transform = {
663
+ ...(presetConfig?.transform ?? {}),
664
+ ...(rawConfig.transform ?? {}),
665
+ };
666
+ let needsDtsInputs = false;
667
+ for (const value of Object.values(transform)) {
668
+ let transformPath;
669
+ let transformOptions;
670
+ if (Array.isArray(value)) {
671
+ transformPath = value[0];
672
+ transformOptions = value[1];
673
+ }
674
+ else if (typeof value === 'string') {
675
+ transformPath = value;
676
+ }
677
+ else {
678
+ continue;
679
+ }
680
+ if (!isTsJestTransformer(transformPath))
681
+ continue;
682
+ if (transformOptions?.isolatedModules === true) {
683
+ const tsJestMajor = getTsJestMajorVersion();
684
+ if (tsJestMajor !== null && tsJestMajor < 30)
685
+ continue;
686
+ }
687
+ const tsconfigAbsPath = transformOptions?.tsconfig
688
+ ? (0, node_path_1.resolve)(rootDir, replaceRootDirInPath(rootDir, transformOptions.tsconfig))
689
+ : findNearestTsconfig(rootDir, absWorkspaceRoot, tsconfigExistsCache);
690
+ if (!tsconfigAbsPath) {
691
+ // No tsconfig found — ts-jest defaults to non-isolated mode
692
+ needsDtsInputs = true;
693
+ continue;
694
+ }
695
+ const { value: isolatedValue, visitedFiles } = resolveIsolatedModules(tsconfigAbsPath, tsconfigJsonCache, isolatedModulesCache);
696
+ for (const visitedFile of visitedFiles) {
697
+ addIfExternal(visitedFile);
698
+ }
699
+ if (isolatedValue !== true)
700
+ needsDtsInputs = true;
701
+ }
702
+ return { externalFiles: [...externalFiles], needsDtsInputs };
703
+ }
571
704
  async function loadPresetConfig(rawConfig, rootDir, presetCache) {
572
705
  if (!rawConfig.preset)
573
706
  return null;
@@ -708,6 +841,93 @@ async function getConfigFileInputs(rawConfig, rootDir, presetCache, resolveFileP
708
841
  externalDeps: [...externalDeps],
709
842
  };
710
843
  }
844
+ /**
845
+ * Walks up from `startDir` looking for `tsconfig.json`, stopping at
846
+ * `stopDir` (inclusive). Mirrors `ts.findConfigFile` but capped at the
847
+ * workspace root to avoid escaping the monorepo.
848
+ */
849
+ function findNearestTsconfig(startDir, stopDir, existsCache) {
850
+ let dir = startDir;
851
+ while (true) {
852
+ const candidate = (0, node_path_1.join)(dir, 'tsconfig.json');
853
+ let exists = existsCache.get(candidate);
854
+ if (exists === undefined) {
855
+ exists = (0, node_fs_1.existsSync)(candidate);
856
+ existsCache.set(candidate, exists);
857
+ }
858
+ if (exists)
859
+ return candidate;
860
+ if (dir === stopDir)
861
+ return null;
862
+ const parent = (0, node_path_1.dirname)(dir);
863
+ if (parent === dir)
864
+ return null;
865
+ dir = parent;
866
+ }
867
+ }
868
+ function isTsJestTransformer(value) {
869
+ if (value === 'ts-jest' || value.startsWith('ts-jest/')) {
870
+ return true;
871
+ }
872
+ // Handle resolved paths (e.g. from require.resolve('ts-jest') in configs)
873
+ const normalized = (0, devkit_1.normalizePath)(value);
874
+ return (normalized.includes('/node_modules/ts-jest/') ||
875
+ normalized.endsWith('/node_modules/ts-jest'));
876
+ }
877
+ /**
878
+ * Returns the effective `compilerOptions.isolatedModules` for a tsconfig,
879
+ * walking the `extends` chain via `walkTsconfigExtendsChain`. Tri-state:
880
+ * `value` is `undefined` when the option is not set anywhere in the chain.
881
+ */
882
+ function resolveIsolatedModules(tsconfigPath, jsonCache, resultCache) {
883
+ const cached = resultCache.get(tsconfigPath);
884
+ if (cached)
885
+ return cached;
886
+ let value;
887
+ const visitedFiles = new Set();
888
+ (0, internal_1.walkTsconfigExtendsChain)(tsconfigPath, (absPath, rawJson) => {
889
+ visitedFiles.add(absPath);
890
+ const opts = rawJson?.compilerOptions;
891
+ if (opts?.isolatedModules !== undefined) {
892
+ value = opts.isolatedModules === true;
893
+ return 'stop';
894
+ }
895
+ // verbatimModuleSyntax: true implies isolatedModules: true (TS 5.0+,
896
+ // the minimum TS version Nx supports)
897
+ if (opts?.verbatimModuleSyntax === true) {
898
+ value = true;
899
+ return 'stop';
900
+ }
901
+ return 'continue';
902
+ }, { jsonCache });
903
+ const result = { value, visitedFiles };
904
+ resultCache.set(tsconfigPath, result);
905
+ return result;
906
+ }
907
+ // Module-level memoization: package versions don't change during a process
908
+ // lifetime, so it's safe to cache across createNodes invocations.
909
+ let cachedJestMajorVersion;
910
+ function getJestMajorVersion() {
911
+ if (cachedJestMajorVersion === undefined) {
912
+ cachedJestMajorVersion = (0, versions_1.getInstalledJestMajorVersion)();
913
+ }
914
+ return cachedJestMajorVersion;
915
+ }
916
+ let cachedTsJestMajorVersion;
917
+ function getTsJestMajorVersion() {
918
+ if (cachedTsJestMajorVersion !== undefined) {
919
+ return cachedTsJestMajorVersion;
920
+ }
921
+ try {
922
+ const { major } = require('semver');
923
+ const version = require('ts-jest/package.json').version;
924
+ cachedTsJestMajorVersion = major(version);
925
+ }
926
+ catch {
927
+ cachedTsJestMajorVersion = null;
928
+ }
929
+ return cachedTsJestMajorVersion;
930
+ }
711
931
  async function getJestOption(rawConfig, rootDir, optionName, presetCache) {
712
932
  if (rawConfig[optionName])
713
933
  return rawConfig[optionName];
package/project.json DELETED
@@ -1,57 +0,0 @@
1
- {
2
- "name": "jest",
3
- "$schema": "../../node_modules/nx/schemas/project-schema.json",
4
- "sourceRoot": "packages/jest",
5
- "projectType": "library",
6
- "targets": {
7
- "build": {
8
- "outputs": ["{workspaceRoot}/dist/packages/jest/README.md"],
9
- "command": "node ./scripts/copy-readme.js jest"
10
- },
11
- "legacy-post-build": {
12
- "executor": "@nx/workspace-plugin:legacy-post-build",
13
- "options": {
14
- "tsConfig": "./tsconfig.lib.json",
15
- "assets": [
16
- {
17
- "input": "packages/jest",
18
- "glob": "**/@(files|files-angular)/**",
19
- "output": "/"
20
- },
21
- {
22
- "input": "packages/jest",
23
- "glob": "**/files/**/.gitkeep",
24
- "output": "/"
25
- },
26
- {
27
- "input": "packages/jest",
28
- "glob": "**/*.json",
29
- "ignore": ["**/tsconfig*.json", "project.json", ".eslintrc.json"],
30
- "output": "/"
31
- },
32
- {
33
- "input": "packages/jest",
34
- "glob": "**/*.js",
35
- "ignore": ["**/jest.config.js"],
36
- "output": "/"
37
- },
38
- {
39
- "input": "packages/jest",
40
- "glob": "**/*.d.ts",
41
- "output": "/"
42
- },
43
- {
44
- "input": "packages/jest",
45
- "glob": "PLUGIN.md",
46
- "output": "/"
47
- },
48
- {
49
- "input": "",
50
- "glob": "LICENSE",
51
- "output": "/"
52
- }
53
- ]
54
- }
55
- }
56
- }
57
- }