@smoothbricks/nx-plugin 0.4.26 → 0.4.27

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 (343) hide show
  1. package/README.md +994 -117
  2. package/dist/bin/smoo-nx-bound-failures.d.ts +3 -0
  3. package/dist/bin/smoo-nx-bound-failures.d.ts.map +1 -0
  4. package/dist/bin/smoo-nx-bound-failures.js +31 -0
  5. package/dist/bin/smoo-nx-cargo-hash.js +28 -3
  6. package/dist/bin/smoo-nx-exec.js +15 -73
  7. package/dist/bin/smoo-nx-failures.d.ts +3 -0
  8. package/dist/bin/smoo-nx-failures.d.ts.map +1 -0
  9. package/dist/bin/smoo-nx-failures.js +3 -0
  10. package/dist/bin/smoo-nx-nextest-extract.js +3 -2
  11. package/dist/bin/smoo-nx-test-walks.d.ts +3 -0
  12. package/dist/bin/smoo-nx-test-walks.d.ts.map +1 -0
  13. package/dist/bin/smoo-nx-test-walks.js +34 -0
  14. package/dist/bounded-test-policy.d.ts +7 -1
  15. package/dist/bounded-test-policy.d.ts.map +1 -1
  16. package/dist/bounded-test-policy.js +101 -40
  17. package/dist/build-state-output-policy.d.ts +25 -0
  18. package/dist/build-state-output-policy.d.ts.map +1 -0
  19. package/dist/build-state-output-policy.js +64 -0
  20. package/dist/cargo-closure-input.d.ts +3 -2
  21. package/dist/cargo-closure-input.d.ts.map +1 -1
  22. package/dist/cargo-closure-input.js +16 -15
  23. package/dist/cargo-dev-profile.d.ts +37 -0
  24. package/dist/cargo-dev-profile.d.ts.map +1 -0
  25. package/dist/cargo-dev-profile.js +108 -0
  26. package/dist/cargo-source-hash.d.ts +43 -6
  27. package/dist/cargo-source-hash.d.ts.map +1 -1
  28. package/dist/cargo-source-hash.js +309 -73
  29. package/dist/cargo-toolchain-policy.d.ts +4 -0
  30. package/dist/cargo-toolchain-policy.d.ts.map +1 -1
  31. package/dist/cargo-toolchain-policy.js +5 -0
  32. package/dist/cargo-workspace.d.ts +101 -5
  33. package/dist/cargo-workspace.d.ts.map +1 -1
  34. package/dist/cargo-workspace.js +291 -10
  35. package/dist/cross-check-policy.d.ts +21 -3
  36. package/dist/cross-check-policy.d.ts.map +1 -1
  37. package/dist/cross-check-policy.js +24 -6
  38. package/dist/disk-command-policy.d.ts +7 -0
  39. package/dist/disk-command-policy.d.ts.map +1 -0
  40. package/dist/disk-command-policy.js +98 -0
  41. package/dist/ensure-built-receipt.d.ts +25 -0
  42. package/dist/ensure-built-receipt.d.ts.map +1 -0
  43. package/dist/ensure-built-receipt.js +261 -0
  44. package/dist/ensure-built-witness.d.ts +57 -0
  45. package/dist/ensure-built-witness.d.ts.map +1 -0
  46. package/dist/ensure-built-witness.js +412 -0
  47. package/dist/ensure-built.d.ts +207 -12
  48. package/dist/ensure-built.d.ts.map +1 -1
  49. package/dist/ensure-built.js +576 -202
  50. package/dist/eslint-file-set.d.ts +7 -0
  51. package/dist/eslint-file-set.d.ts.map +1 -0
  52. package/dist/eslint-file-set.js +12 -0
  53. package/dist/executors/bounded-exec/cpu-pool.d.ts +63 -0
  54. package/dist/executors/bounded-exec/cpu-pool.d.ts.map +1 -0
  55. package/dist/executors/bounded-exec/cpu-pool.js +379 -0
  56. package/dist/executors/bounded-exec/cpu-tokens.d.ts +82 -0
  57. package/dist/executors/bounded-exec/cpu-tokens.d.ts.map +1 -0
  58. package/dist/executors/bounded-exec/cpu-tokens.js +114 -0
  59. package/dist/executors/bounded-exec/disk-lease.d.ts +61 -0
  60. package/dist/executors/bounded-exec/disk-lease.d.ts.map +1 -0
  61. package/dist/executors/bounded-exec/disk-lease.js +91 -0
  62. package/dist/executors/bounded-exec/executor.d.ts +45 -2
  63. package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
  64. package/dist/executors/bounded-exec/executor.js +447 -52
  65. package/dist/executors/bounded-exec/gateway-lease.d.ts +52 -0
  66. package/dist/executors/bounded-exec/gateway-lease.d.ts.map +1 -0
  67. package/dist/executors/bounded-exec/gateway-lease.js +143 -0
  68. package/dist/executors/bounded-exec/hang-diagnostics.d.ts +35 -0
  69. package/dist/executors/bounded-exec/hang-diagnostics.d.ts.map +1 -0
  70. package/dist/executors/bounded-exec/hang-diagnostics.js +231 -0
  71. package/dist/executors/bounded-exec/progress.d.ts +35 -0
  72. package/dist/executors/bounded-exec/progress.d.ts.map +1 -0
  73. package/dist/executors/bounded-exec/progress.js +79 -0
  74. package/dist/executors/bounded-exec/ram-temp-fixtures.d.ts +3 -0
  75. package/dist/executors/bounded-exec/ram-temp-fixtures.d.ts.map +1 -0
  76. package/dist/executors/bounded-exec/ram-temp-fixtures.js +12 -0
  77. package/dist/executors/bounded-exec/ram-temp-held.d.ts +91 -0
  78. package/dist/executors/bounded-exec/ram-temp-held.d.ts.map +1 -0
  79. package/dist/executors/bounded-exec/ram-temp-held.js +152 -0
  80. package/dist/executors/bounded-exec/ram-temp.d.ts +223 -0
  81. package/dist/executors/bounded-exec/ram-temp.d.ts.map +1 -0
  82. package/dist/executors/bounded-exec/ram-temp.js +1528 -0
  83. package/dist/executors/bounded-exec/schema.d.ts +29 -11
  84. package/dist/executors/bounded-exec/schema.d.ts.map +1 -1
  85. package/dist/executors/bounded-exec/verdict.d.ts +162 -0
  86. package/dist/executors/bounded-exec/verdict.d.ts.map +1 -0
  87. package/dist/executors/bounded-exec/verdict.js +318 -0
  88. package/dist/executors/shard-timings/executor.d.ts +14 -0
  89. package/dist/executors/shard-timings/executor.d.ts.map +1 -0
  90. package/dist/executors/shard-timings/executor.js +25 -0
  91. package/dist/executors/shard-timings/schema.d.ts +4 -0
  92. package/dist/executors/shard-timings/schema.d.ts.map +1 -0
  93. package/dist/executors/shard-timings/schema.js +1 -0
  94. package/dist/failure-summary.d.ts +5 -0
  95. package/dist/failure-summary.d.ts.map +1 -0
  96. package/dist/failure-summary.js +118 -0
  97. package/dist/generators/create-package/generator.d.ts.map +1 -1
  98. package/dist/generators/create-package/generator.js +6 -2
  99. package/dist/index.d.ts +14 -2
  100. package/dist/index.d.ts.map +1 -1
  101. package/dist/index.js +370 -138
  102. package/dist/managed-files/ci-workflow.d.ts +13 -0
  103. package/dist/managed-files/ci-workflow.d.ts.map +1 -1
  104. package/dist/managed-files/ci-workflow.js +44 -13
  105. package/dist/managed-files/files.d.ts +7 -1
  106. package/dist/managed-files/files.d.ts.map +1 -1
  107. package/dist/managed-files/files.js +62 -8
  108. package/dist/managed-files/json-edit.d.ts +21 -0
  109. package/dist/managed-files/json-edit.d.ts.map +1 -0
  110. package/dist/managed-files/json-edit.js +295 -0
  111. package/dist/managed-files/managed-format.d.ts +33 -1
  112. package/dist/managed-files/managed-format.d.ts.map +1 -1
  113. package/dist/managed-files/managed-format.js +82 -2
  114. package/dist/managed-files/pr-preview-cleanup-workflow.d.ts +7 -0
  115. package/dist/managed-files/pr-preview-cleanup-workflow.d.ts.map +1 -1
  116. package/dist/managed-files/pr-preview-cleanup-workflow.js +68 -4
  117. package/dist/managed-files/publish-workflow.d.ts.map +1 -1
  118. package/dist/managed-files/publish-workflow.js +231 -48
  119. package/dist/managed-files/tree.d.ts +5 -0
  120. package/dist/managed-files/tree.d.ts.map +1 -1
  121. package/dist/managed-files/tree.js +5 -3
  122. package/dist/manifest-hash.d.ts.map +1 -1
  123. package/dist/manifest-hash.js +2 -5
  124. package/dist/nextest-code-bound.d.ts +62 -0
  125. package/dist/nextest-code-bound.d.ts.map +1 -0
  126. package/dist/nextest-code-bound.js +154 -0
  127. package/dist/nextest-extraction.d.ts +24 -8
  128. package/dist/nextest-extraction.d.ts.map +1 -1
  129. package/dist/nextest-extraction.js +42 -7
  130. package/dist/package-target-policy.d.ts.map +1 -1
  131. package/dist/package-target-policy.js +3 -5
  132. package/dist/release-config-policy.d.ts.map +1 -1
  133. package/dist/release-config-policy.js +3 -5
  134. package/dist/runtime-input.d.ts +14 -0
  135. package/dist/runtime-input.d.ts.map +1 -0
  136. package/dist/runtime-input.js +15 -0
  137. package/dist/rust-tokens.d.ts +11 -0
  138. package/dist/rust-tokens.d.ts.map +1 -0
  139. package/dist/rust-tokens.js +81 -0
  140. package/dist/task-results.d.ts +6 -0
  141. package/dist/task-results.d.ts.map +1 -0
  142. package/dist/task-results.js +61 -0
  143. package/dist/test-program.d.ts +54 -0
  144. package/dist/test-program.d.ts.map +1 -0
  145. package/dist/test-program.js +292 -0
  146. package/dist/test-timings.d.ts +71 -0
  147. package/dist/test-timings.d.ts.map +1 -0
  148. package/dist/test-timings.js +393 -0
  149. package/dist/test-walk-policy.d.ts +103 -0
  150. package/dist/test-walk-policy.d.ts.map +1 -0
  151. package/dist/test-walk-policy.js +657 -0
  152. package/dist/testing.d.ts +177 -0
  153. package/dist/testing.d.ts.map +1 -0
  154. package/dist/testing.js +824 -0
  155. package/dist/type-guards.d.ts +3 -0
  156. package/dist/type-guards.d.ts.map +1 -0
  157. package/dist/type-guards.js +4 -0
  158. package/dist/typecheck-test-policy.d.ts +8 -5
  159. package/dist/typecheck-test-policy.d.ts.map +1 -1
  160. package/dist/typecheck-test-policy.js +113 -100
  161. package/dist/workspace-config-policy.d.ts +8 -0
  162. package/dist/workspace-config-policy.d.ts.map +1 -1
  163. package/dist/workspace-config-policy.js +175 -63
  164. package/dist/workspace-index.d.ts +12 -0
  165. package/dist/workspace-index.d.ts.map +1 -0
  166. package/dist/workspace-index.js +17 -0
  167. package/dist/workspace-manifest.d.ts +37 -0
  168. package/dist/workspace-manifest.d.ts.map +1 -1
  169. package/executors.json +5 -0
  170. package/loader.js +13 -11
  171. package/managed/raw/envrc +33 -67
  172. package/managed/raw/git-format-staged.yml +30 -35
  173. package/managed/raw/patches/nx@23.2.1.patch +3484 -0
  174. package/managed/raw/tooling/direnv/apple-developer.sh +83 -0
  175. package/managed/raw/tooling/direnv/developer-links.ts +569 -11
  176. package/managed/raw/tooling/direnv/devenv.smoo.nix +314 -93
  177. package/managed/raw/tooling/direnv/github-actions-bootstrap.sh +20 -11
  178. package/managed/raw/tooling/direnv/linked-snapshots.ts +845 -0
  179. package/managed/raw/tooling/direnv/nx-socket-dir.sh +82 -0
  180. package/managed/raw/tooling/direnv/repo-path +14 -2
  181. package/managed/raw/tooling/direnv/setup-environment.ts +962 -148
  182. package/managed/raw/tooling/direnv/toolchain-stamp.ts +45 -3
  183. package/managed/raw/tooling/direnv/ttsc-env.sh +39 -0
  184. package/managed/raw/tooling/git-hooks/commit-msg.sh +5 -6
  185. package/managed/raw/tooling/git-hooks/pre-commit.sh +7 -6
  186. package/managed/raw/tooling/git-hooks/pre-push.sh +20 -15
  187. package/managed/templates/github/actions/cache-nix-devenv/action.yml +6 -6
  188. package/managed/templates/github/actions/cache-node-modules/action.yml +6 -4
  189. package/managed/templates/github/actions/cache-nx/action.yml +1 -1
  190. package/managed/templates/github/actions/cache-ttsc-plugins/action.yml +1 -1
  191. package/managed/templates/github/actions/forgejo-artifact.cjs +99 -0
  192. package/managed/templates/github/actions/forgejo-download-artifact/action.yml +49 -0
  193. package/managed/templates/github/actions/forgejo-download-artifact/index.cjs +7 -0
  194. package/managed/templates/github/actions/forgejo-upload-artifact/action.yml +65 -0
  195. package/managed/templates/github/actions/forgejo-upload-artifact/index.cjs +7 -0
  196. package/managed/templates/github/actions/setup-devenv/action.yml +21 -3
  197. package/managed/templates/github/workflows/managed-files.yml +1 -2
  198. package/nextest.toml +8 -41
  199. package/package.json +74 -12
  200. package/runtime-input.sh +81 -0
  201. package/src/__tests__/counted-cargo.ts +33 -14
  202. package/src/__tests__/fixture-nx-env.ts +111 -46
  203. package/src/__tests__/progress-clock.ts +43 -0
  204. package/src/__tests__/runtime-input.ts +23 -0
  205. package/src/bin/smoo-nx-bound-failures.test.ts +127 -0
  206. package/src/bin/smoo-nx-bound-failures.ts +33 -0
  207. package/src/bin/smoo-nx-cargo-hash.ts +28 -3
  208. package/src/bin/smoo-nx-exec.ts +16 -74
  209. package/src/bin/smoo-nx-failures.ts +4 -0
  210. package/src/bin/smoo-nx-nextest-extract.ts +3 -2
  211. package/src/bin/smoo-nx-test-walks.ts +42 -0
  212. package/src/bounded-test-policy.test.ts +268 -21
  213. package/src/bounded-test-policy.ts +114 -42
  214. package/src/build-state-output-policy.test.ts +115 -0
  215. package/src/build-state-output-policy.ts +90 -0
  216. package/src/bun-bootstrap.test.ts +57 -3
  217. package/src/bun-file-packages.test.ts +47 -0
  218. package/src/cargo-closure-input.test.ts +138 -66
  219. package/src/cargo-closure-input.ts +17 -15
  220. package/src/cargo-dev-profile.ts +137 -0
  221. package/src/cargo-resolve-cache.test.ts +70 -1
  222. package/src/cargo-source-hash.test.ts +193 -97
  223. package/src/cargo-source-hash.ts +345 -68
  224. package/src/cargo-toolchain-policy.ts +6 -0
  225. package/src/cargo-workspace.test.ts +320 -0
  226. package/src/cargo-workspace.ts +336 -10
  227. package/src/cross-check-policy.test.ts +59 -1
  228. package/src/cross-check-policy.ts +25 -6
  229. package/src/disk-command-policy.test.ts +61 -0
  230. package/src/disk-command-policy.ts +107 -0
  231. package/src/ensure-built-receipt.test.ts +184 -0
  232. package/src/ensure-built-receipt.ts +263 -0
  233. package/src/ensure-built-witness.test.ts +344 -0
  234. package/src/ensure-built-witness.ts +252 -0
  235. package/src/ensure-built.test.ts +1036 -578
  236. package/src/ensure-built.ts +820 -224
  237. package/src/eslint-file-set.ts +9 -0
  238. package/src/executors/bounded-exec/cpu-pool.test.ts +454 -0
  239. package/src/executors/bounded-exec/cpu-pool.ts +417 -0
  240. package/src/executors/bounded-exec/cpu-tokens.test.ts +269 -0
  241. package/src/executors/bounded-exec/cpu-tokens.ts +177 -0
  242. package/src/executors/bounded-exec/disk-lease.test.ts +185 -0
  243. package/src/executors/bounded-exec/disk-lease.ts +139 -0
  244. package/src/executors/bounded-exec/executor-host.test.ts +778 -0
  245. package/src/executors/bounded-exec/executor.test.ts +1116 -63
  246. package/src/executors/bounded-exec/executor.ts +565 -67
  247. package/src/executors/bounded-exec/gateway-lease.ts +176 -0
  248. package/src/executors/bounded-exec/hang-diagnostics.test.ts +285 -0
  249. package/src/executors/bounded-exec/hang-diagnostics.ts +283 -0
  250. package/src/executors/bounded-exec/progress.test.ts +79 -0
  251. package/src/executors/bounded-exec/progress.ts +118 -0
  252. package/src/executors/bounded-exec/ram-temp-fixtures.ts +12 -0
  253. package/src/executors/bounded-exec/ram-temp-held.test.ts +264 -0
  254. package/src/executors/bounded-exec/ram-temp-held.ts +242 -0
  255. package/src/executors/bounded-exec/ram-temp-host.test.ts +605 -0
  256. package/src/executors/bounded-exec/ram-temp.test.ts +674 -0
  257. package/src/executors/bounded-exec/ram-temp.ts +1918 -0
  258. package/src/executors/bounded-exec/schema.json +11 -5
  259. package/src/executors/bounded-exec/schema.ts +27 -11
  260. package/src/executors/bounded-exec/verdict.test.ts +440 -0
  261. package/src/executors/bounded-exec/verdict.ts +433 -0
  262. package/src/executors/shard-timings/executor.ts +36 -0
  263. package/src/executors/shard-timings/schema.json +21 -0
  264. package/src/executors/shard-timings/schema.ts +4 -0
  265. package/src/failure-summary.ts +119 -0
  266. package/src/generators/bounded-test-targets/generator.test.ts +4 -4
  267. package/src/generators/bun-test-tracing/generator.test.ts +2 -2
  268. package/src/generators/create-package/generator.test.ts +6 -0
  269. package/src/generators/create-package/generator.ts +6 -2
  270. package/src/host-controller-wiring.test.ts +31 -0
  271. package/src/index.test.ts +909 -295
  272. package/src/index.ts +441 -143
  273. package/src/linked-snapshots.nx.test.ts +172 -0
  274. package/src/managed-files/ci-workflow.ts +54 -13
  275. package/src/managed-files/files.ts +65 -9
  276. package/src/managed-files/forgejo-artifact.test.ts +395 -0
  277. package/src/managed-files/generator.test.ts +60 -1
  278. package/src/managed-files/json-edit.test.ts +216 -0
  279. package/src/managed-files/json-edit.ts +290 -0
  280. package/src/managed-files/managed-format-json.test.ts +308 -0
  281. package/src/managed-files/managed-format.ts +90 -2
  282. package/src/managed-files/pr-preview-cleanup-workflow.ts +69 -3
  283. package/src/managed-files/publish-workflow.ts +285 -67
  284. package/src/managed-files/repo-path.test.ts +129 -0
  285. package/src/managed-files/trace-db-artifact.test.ts +7 -0
  286. package/src/managed-files/tree.ts +11 -3
  287. package/src/manifest-hash.ts +2 -6
  288. package/src/nextest-code-bound.test.ts +155 -0
  289. package/src/nextest-code-bound.ts +195 -0
  290. package/src/nextest-extraction.test.ts +37 -5
  291. package/src/nextest-extraction.ts +51 -9
  292. package/src/nextest-partitions.test.ts +427 -82
  293. package/src/nx-cache-bound.test.ts +5 -10
  294. package/src/nx-cache-restore-mtime.test.ts +170 -0
  295. package/src/nx-daemon-claim.test.ts +277 -0
  296. package/src/nx-daemon-idle-cpu.test.ts +81 -0
  297. package/src/nx-daemon-idle-policy.test.ts +51 -0
  298. package/src/nx-daemon-ignore-files.test.ts +210 -0
  299. package/src/nx-daemon-root-normalization.test.ts +105 -0
  300. package/src/nx-daemon-validity.test.ts +925 -0
  301. package/src/nx-dot-input-policy.test.ts +353 -0
  302. package/src/nx-failure-life-cycles.test.ts +207 -0
  303. package/src/nx-files-archive-racy.test.ts +97 -0
  304. package/src/nx-foreign-workspace-env.test.ts +329 -0
  305. package/src/nx-incomplete-run-summary.test.ts +70 -0
  306. package/src/nx-plugin-load-errors.test.ts +120 -0
  307. package/src/nx-project-resolution-cache.test.ts +176 -0
  308. package/src/nx-raw-inputs.test.ts +166 -0
  309. package/src/nx-resident-graph-workers.test.ts +7 -16
  310. package/src/nx-run-information.test.ts +118 -0
  311. package/src/nx-skipped-task-exit.test.ts +180 -0
  312. package/src/nx-state-location.test.ts +63 -0
  313. package/src/nx-store-resolution.test.ts +26 -25
  314. package/src/nx-task-graph-cycles.test.ts +148 -0
  315. package/src/nx-task-output-lease.test.ts +414 -0
  316. package/src/nx-use-local.test.ts +103 -0
  317. package/src/package-target-policy.ts +3 -6
  318. package/src/release-config-policy.ts +3 -6
  319. package/src/runtime-input.test.ts +215 -0
  320. package/src/runtime-input.ts +17 -0
  321. package/src/rust-tokens.ts +78 -0
  322. package/src/serial-group-wiring.test.ts +326 -0
  323. package/src/task-history-namespace.test.ts +87 -89
  324. package/src/task-results.test.ts +226 -0
  325. package/src/task-results.ts +75 -0
  326. package/src/test-program.test.ts +303 -0
  327. package/src/test-program.ts +341 -0
  328. package/src/test-timings.test.ts +240 -0
  329. package/src/test-timings.ts +311 -0
  330. package/src/test-walk-policy.test.ts +585 -0
  331. package/src/test-walk-policy.ts +731 -0
  332. package/src/testing.test.ts +509 -0
  333. package/src/testing.ts +922 -0
  334. package/src/type-guards.ts +4 -0
  335. package/src/typecheck-test-policy.test.ts +496 -11
  336. package/src/typecheck-test-policy.ts +137 -103
  337. package/src/workspace-config-policy.test.ts +212 -13
  338. package/src/workspace-config-policy.ts +101 -73
  339. package/src/workspace-index.ts +18 -0
  340. package/src/workspace-manifest.ts +41 -0
  341. package/test-timings.json +85 -30
  342. package/managed/raw/tooling/direnv/inherited-devenv.ts +0 -665
  343. package/managed/raw/tooling/direnv/shared-caches.sh +0 -53
@@ -0,0 +1,4 @@
1
+ /** A plain object: its keys are known to exist, its values are not known to be anything. */
2
+ export function isRecord(value: unknown): value is Record<string, unknown> {
3
+ return value !== null && typeof value === 'object' && !Array.isArray(value);
4
+ }
@@ -1,13 +1,14 @@
1
1
  import { describe, expect, it } from 'bun:test';
2
- import { mkdir, mkdtemp, readFile, rm, writeFile } from 'node:fs/promises';
2
+ import { mkdir, mkdtemp, readFile, rm, symlink, writeFile } from 'node:fs/promises';
3
3
  import { tmpdir } from 'node:os';
4
4
  import { dirname, join } from 'node:path';
5
5
 
6
- import { addProjectConfiguration, readJson, type Tree, writeJson } from 'nx/src/devkit-exports.js';
6
+ import { addProjectConfiguration, parseJson, readJson, type Tree, writeJson } from 'nx/src/devkit-exports.js';
7
7
  import { createTreeWithEmptyWorkspace } from 'nx/src/devkit-testing-exports.js';
8
8
  import { FsTree, flushChanges } from 'nx/src/generators/tree.js';
9
9
  import { inspectManagedPaths } from './managed-files/paths.js';
10
10
  import { assertNoManagedConflicts, stageManagedFiles } from './managed-files/tree.js';
11
+ import type { TestProgram } from './test-program.js';
11
12
 
12
13
  import {
13
14
  applyTypecheckTestDefaults,
@@ -199,11 +200,15 @@ describe('checkTsconfigTestReference', () => {
199
200
  });
200
201
 
201
202
  describe('applyTypecheckTestDefaults', () => {
203
+ const program: TestProgram = { projectRoot: 'packages/app', files: ['src/app.test.ts'], readConfig: () => null };
204
+
202
205
  it('applies all defaults to empty object', () => {
203
206
  const tsconfigTest: Record<string, unknown> = {};
204
207
  const changed = applyTypecheckTestDefaults(tsconfigTest, {
205
208
  testRunners: new Set(['bun'] as const),
209
+ testExtends: '../../tsconfig.base.json',
206
210
  referencePaths: ['./tsconfig.lib.json'],
211
+ program,
207
212
  isNew: true,
208
213
  });
209
214
  expect(changed).toBe(true);
@@ -231,13 +236,24 @@ describe('applyTypecheckTestDefaults', () => {
231
236
  // that with a program of zero files, which passed the gate by compiling
232
237
  // nothing (the false green the policy exists to prevent).
233
238
  const declared: Record<string, unknown> = { extends: './tsconfig.json', compilerOptions: { noEmit: true } };
234
- applyTypecheckTestDefaults(declared, { testRunners: new Set(['bun'] as const), referencePaths: [] });
239
+ applyTypecheckTestDefaults(declared, {
240
+ testRunners: new Set(['bun'] as const),
241
+ testExtends: '../../tsconfig.base.json',
242
+ referencePaths: [],
243
+ program,
244
+ });
245
+ expect(declared.extends).toBe('./tsconfig.json');
235
246
  expect(Object.hasOwn(declared, 'include')).toBe(false);
236
247
  // Same for `types`: declaring it would drop the workers types the program inherits.
237
248
  expect(Object.hasOwn(expectRecord(declared.compilerOptions), 'types')).toBe(false);
238
249
 
239
250
  const explicit: Record<string, unknown> = { extends: './tsconfig.json', include: ['test/**/*.ts'] };
240
- applyTypecheckTestDefaults(explicit, { testRunners: new Set(['bun'] as const), referencePaths: [] });
251
+ applyTypecheckTestDefaults(explicit, {
252
+ testRunners: new Set(['bun'] as const),
253
+ testExtends: '../../tsconfig.base.json',
254
+ referencePaths: [],
255
+ program,
256
+ });
241
257
  expect(expectStringArray(explicit.include)).toEqual(expect.arrayContaining(['test/**/*.ts', 'src/**/*.test.ts']));
242
258
  });
243
259
 
@@ -251,7 +267,9 @@ describe('applyTypecheckTestDefaults', () => {
251
267
  };
252
268
  applyTypecheckTestDefaults(declared, {
253
269
  testRunners: new Set(['bun'] as const),
270
+ testExtends: '../../tsconfig.base.json',
254
271
  referencePaths: [],
272
+ program,
255
273
  libCompilerOptions: { lib: ['es2022'], module: 'preserve' },
256
274
  });
257
275
 
@@ -262,18 +280,21 @@ describe('applyTypecheckTestDefaults', () => {
262
280
  const silent: Record<string, unknown> = { compilerOptions: {} };
263
281
  applyTypecheckTestDefaults(silent, {
264
282
  testRunners: new Set(['bun'] as const),
283
+ testExtends: '../../tsconfig.base.json',
265
284
  referencePaths: [],
285
+ program,
266
286
  libCompilerOptions: { lib: ['es2022'] },
267
287
  });
268
288
  expect(expectRecord(silent.compilerOptions).lib).toEqual(['es2022']);
269
289
  });
270
290
 
271
- it('uses custom extends from lib tsconfig', () => {
291
+ it('extends what it is given when the file names nothing', () => {
272
292
  const tsconfigTest: Record<string, unknown> = {};
273
293
  applyTypecheckTestDefaults(tsconfigTest, {
274
294
  testRunners: new Set(['bun'] as const),
275
- tsconfigLibExtends: '../tsconfig.custom.json',
295
+ testExtends: '../tsconfig.custom.json',
276
296
  referencePaths: [],
297
+ program,
277
298
  });
278
299
  expect(tsconfigTest.extends).toBe('../tsconfig.custom.json');
279
300
  });
@@ -282,8 +303,10 @@ describe('applyTypecheckTestDefaults', () => {
282
303
  const tsconfigTest: Record<string, unknown> = {};
283
304
  applyTypecheckTestDefaults(tsconfigTest, {
284
305
  testRunners: new Set(['bun'] as const),
306
+ testExtends: '../../tsconfig.base.json',
285
307
  libCompilerOptions: { baseUrl: '.', module: 'esnext', jsx: 'react-jsx' },
286
308
  referencePaths: [],
309
+ program,
287
310
  });
288
311
  const compilerOptions = expectRecord(tsconfigTest.compilerOptions);
289
312
  expect(compilerOptions.baseUrl).toBe('.');
@@ -295,7 +318,9 @@ describe('applyTypecheckTestDefaults', () => {
295
318
  const tsconfigTest: Record<string, unknown> = {};
296
319
  applyTypecheckTestDefaults(tsconfigTest, {
297
320
  testRunners: new Set(['vitest'] as const),
321
+ testExtends: '../../tsconfig.base.json',
298
322
  referencePaths: [],
323
+ program,
299
324
  });
300
325
  const compilerOptions = expectRecord(tsconfigTest.compilerOptions);
301
326
  expect(compilerOptions.types).toBeUndefined();
@@ -307,7 +332,9 @@ describe('applyTypecheckTestDefaults', () => {
307
332
  };
308
333
  const changed = applyTypecheckTestDefaults(tsconfigTest, {
309
334
  testRunners: new Set(['bun'] as const),
335
+ testExtends: '../../tsconfig.base.json',
310
336
  referencePaths: [],
337
+ program,
311
338
  });
312
339
  expect(changed).toBe(true);
313
340
  const compilerOptions = expectRecord(tsconfigTest.compilerOptions);
@@ -319,8 +346,10 @@ describe('applyTypecheckTestDefaults', () => {
319
346
  const tsconfigTest: Record<string, unknown> = {};
320
347
  const opts = {
321
348
  testRunners: new Set(['bun'] as const),
349
+ testExtends: '../../tsconfig.base.json',
322
350
  libCompilerOptions: { lib: ['es2024', 'webworker'] },
323
351
  referencePaths: ['./tsconfig.lib.json'],
352
+ program,
324
353
  };
325
354
  applyTypecheckTestDefaults(tsconfigTest, opts);
326
355
  const secondChanged = applyTypecheckTestDefaults(tsconfigTest, opts);
@@ -333,20 +362,22 @@ describe('removeTsconfigTestReference', () => {
333
362
  const tsconfig: Record<string, unknown> = {
334
363
  references: [{ path: './tsconfig.lib.json' }, { path: './tsconfig.test.json' }],
335
364
  };
336
- expect(removeTsconfigTestReference(tsconfig)).toBe(true);
365
+ removeTsconfigTestReference(tsconfig);
337
366
  expect(tsconfig.references).toEqual([{ path: './tsconfig.lib.json' }]);
338
367
  });
339
368
 
340
- it('returns false when no test reference', () => {
369
+ it('leaves a document with no test reference as it was', () => {
341
370
  const tsconfig: Record<string, unknown> = {
342
371
  references: [{ path: './tsconfig.lib.json' }],
343
372
  };
344
- expect(removeTsconfigTestReference(tsconfig)).toBe(false);
373
+ removeTsconfigTestReference(tsconfig);
374
+ expect(tsconfig).toEqual({ references: [{ path: './tsconfig.lib.json' }] });
345
375
  });
346
376
 
347
- it('returns false when no references', () => {
377
+ it('does not invent a references list', () => {
348
378
  const tsconfig: Record<string, unknown> = {};
349
- expect(removeTsconfigTestReference(tsconfig)).toBe(false);
379
+ removeTsconfigTestReference(tsconfig);
380
+ expect(tsconfig).toEqual({});
350
381
  });
351
382
  });
352
383
 
@@ -370,6 +401,7 @@ describe('typecheck test policy (Tree)', () => {
370
401
  compilerOptions: { composite: true, baseUrl: '.', rootDir: 'src', outDir: 'dist' },
371
402
  });
372
403
 
404
+ tree.write('packages/app/src/app.test.ts', 'export {};\n');
373
405
  const changed = applyTypecheckTestPolicyTree(tree);
374
406
  expect(changed).toBe(true);
375
407
 
@@ -389,6 +421,28 @@ describe('typecheck test policy (Tree)', () => {
389
421
  expect(references).toContainEqual({ path: './tsconfig.lib.json' });
390
422
  });
391
423
 
424
+ it('extends the workspace base from the project root when there is no lib program', () => {
425
+ // `tooling` sits one level below the workspace root. A fixed
426
+ // '../../tsconfig.base.json' named a file above the repository.
427
+ const tree = createTreeWithEmptyWorkspace();
428
+ for (const [name, root] of [
429
+ ['tooling', 'tooling'],
430
+ ['app', 'packages/app'],
431
+ ] as const) {
432
+ addProjectConfiguration(tree, name, { root, targets: {} });
433
+ if (tree.exists(`${root}/project.json`)) tree.delete(`${root}/project.json`);
434
+ writeJson(tree, `${root}/package.json`, { name: `@scope/${name}`, scripts: { test: 'bun test' }, nx: { name } });
435
+ }
436
+
437
+ tree.write('tooling/src/tooling.test.ts', 'export {};\n');
438
+ tree.write('packages/app/src/app.test.ts', 'export {};\n');
439
+ applyTypecheckTestPolicyTree(tree);
440
+ expect(readJson<Record<string, unknown>>(tree, 'tooling/tsconfig.test.json').extends).toBe('../tsconfig.base.json');
441
+ expect(readJson<Record<string, unknown>>(tree, 'packages/app/tsconfig.test.json').extends).toBe(
442
+ '../../tsconfig.base.json',
443
+ );
444
+ });
445
+
392
446
  it('references only composite lib programs (TS6306 otherwise), resolving composite through extends', () => {
393
447
  const tree = createTreeWithEmptyWorkspace();
394
448
  writeJson(tree, 'tsconfig.composite.json', { compilerOptions: { composite: true } });
@@ -412,6 +466,9 @@ describe('typecheck test policy (Tree)', () => {
412
466
  });
413
467
  }
414
468
 
469
+ for (const name of ['app', 'lib', 'inherits']) {
470
+ tree.write(`packages/${name}/src/${name}.test.ts`, 'export {};\n');
471
+ }
415
472
  applyTypecheckTestPolicyTree(tree);
416
473
  const references = expectReferences(
417
474
  readJson<Record<string, unknown>>(tree, 'packages/app/tsconfig.test.json').references,
@@ -521,6 +578,7 @@ describe('typecheck test policy (Tree)', () => {
521
578
  references: [{ path: './tsconfig.lib.json' }, { path: './tsconfig.test.json' }],
522
579
  });
523
580
 
581
+ tree.write('packages/app/src/app.test.ts', 'export {};\n');
524
582
  const changed = applyTypecheckTestPolicyTree(tree);
525
583
  expect(changed).toBe(true);
526
584
 
@@ -579,6 +637,7 @@ describe('typecheck test policy (Tree)', () => {
579
637
  compilerOptions: { composite: true },
580
638
  });
581
639
 
640
+ tree.write('packages/app/src/app.test.ts', 'export {};\n');
582
641
  expect(applyTypecheckTestPolicyTree(tree)).toBe(true);
583
642
 
584
643
  const tsconfig = readJson<Record<string, unknown>>(tree, 'packages/app/tsconfig.test.json');
@@ -629,6 +688,110 @@ describe('typecheck test policy', () => {
629
688
  }
630
689
  });
631
690
 
691
+ describe('a documented config that drifts from the policy', () => {
692
+ const BIOME_SPACES = '{"formatter":{"indentStyle":"space","indentWidth":2,"lineWidth":120}}\n';
693
+
694
+ /** An app that depends on a composite lib, so the policy wants a reference its tsconfig.test.json lacks. */
695
+ async function appWithCompositeDependency(root: string): Promise<void> {
696
+ await writeFile(join(root, 'biome.json'), BIOME_SPACES);
697
+ await writeJsonFs(join(root, 'package.json'), { workspaces: ['packages/*'] });
698
+ await writeJsonFs(join(root, 'tsconfig.base.json'), { compilerOptions: { composite: true } });
699
+ await writeJsonFs(join(root, 'packages/lib/package.json'), { name: '@scope/lib' });
700
+ await writeJsonFs(join(root, 'packages/lib/tsconfig.lib.json'), { extends: '../../tsconfig.base.json' });
701
+ await writeJsonFs(join(root, 'packages/app/package.json'), {
702
+ name: '@scope/app',
703
+ scripts: { test: 'bun test' },
704
+ dependencies: { '@scope/lib': 'workspace:*' },
705
+ });
706
+ // The program extends it, so the policy can read what the program selects through it.
707
+ await writeJsonFs(join(root, 'packages/app/tsconfig.json'), { extends: '../../tsconfig.base.json' });
708
+ await writeSource(join(root, 'packages/app/scripts/app.test.ts'));
709
+ }
710
+
711
+ const documented = [
712
+ '{',
713
+ " // WHY the program extends the package's own config: these are Bun programs.",
714
+ ' "extends": "./tsconfig.json",',
715
+ ' "compilerOptions": {',
716
+ ' "composite": false,',
717
+ ' "declaration": false,',
718
+ ' "declarationMap": false,',
719
+ ' "emitDeclarationOnly": false,',
720
+ ' "noEmit": true, // kept as the policy requires',
721
+ ' "types": ["bun"]',
722
+ ' },',
723
+ ' /* the suites live beside the scripts they exercise */',
724
+ ' "include": ["scripts/**/*.test.ts"],',
725
+ '}',
726
+ '',
727
+ ].join('\n');
728
+
729
+ it('is repaired in place: the policy edits what it owns and every comment survives', async () => {
730
+ const root = await mkdtemp(join(tmpdir(), 'smoo-typecheck-test-documented-'));
731
+ try {
732
+ await appWithCompositeDependency(root);
733
+ const path = join(root, 'packages/app/tsconfig.test.json');
734
+ await writeFile(path, documented);
735
+
736
+ expect(checkTypecheckTestPolicy(root).map((issue) => issue.message)).toEqual([
737
+ 'must match the canonical no-emit test typecheck configuration',
738
+ ]);
739
+ expect(applyTypecheckTestPolicy(root)).toBe(true);
740
+
741
+ const written = await readFile(path, 'utf8');
742
+ expect(written).toContain("// WHY the program extends the package's own config: these are Bun programs.");
743
+ expect(written).toContain('// kept as the policy requires');
744
+ expect(written).toContain('/* the suites live beside the scripts they exercise */');
745
+ expect(parseJson(written)).toEqual({
746
+ extends: './tsconfig.json',
747
+ compilerOptions: {
748
+ composite: false,
749
+ declaration: false,
750
+ declarationMap: false,
751
+ emitDeclarationOnly: false,
752
+ noEmit: true,
753
+ types: ['bun'],
754
+ },
755
+ include: ['scripts/**/*.test.ts'],
756
+ references: [{ path: '../lib/tsconfig.lib.json' }],
757
+ });
758
+ expect(checkTypecheckTestPolicy(root)).toEqual([]);
759
+ // The policy is at its own fixed point: a second run changes nothing.
760
+ expect(applyTypecheckTestPolicy(root)).toBe(false);
761
+ expect(await readFile(path, 'utf8')).toBe(written);
762
+ } finally {
763
+ await rm(root, { recursive: true, force: true });
764
+ }
765
+ });
766
+
767
+ it('has its test reference removed from tsconfig.json without losing the comments around it', async () => {
768
+ const root = await mkdtemp(join(tmpdir(), 'smoo-typecheck-test-documented-'));
769
+ try {
770
+ await appWithCompositeDependency(root);
771
+ await writeFile(join(root, 'packages/app/tsconfig.test.json'), documented);
772
+ const path = join(root, 'packages/app/tsconfig.json');
773
+ await writeFile(
774
+ path,
775
+ [
776
+ '{',
777
+ ' // The project is its lib program; the tests are typechecked on their own.',
778
+ ' "references": [{ "path": "./tsconfig.lib.json" }, { "path": "./tsconfig.test.json" }]',
779
+ '}',
780
+ '',
781
+ ].join('\n'),
782
+ );
783
+
784
+ applyTypecheckTestPolicy(root);
785
+
786
+ const written = await readFile(path, 'utf8');
787
+ expect(written).toContain('// The project is its lib program; the tests are typechecked on their own.');
788
+ expect(parseJson(written)).toEqual({ references: [{ path: './tsconfig.lib.json' }] });
789
+ } finally {
790
+ await rm(root, { recursive: true, force: true });
791
+ }
792
+ });
793
+ });
794
+
632
795
  it('creates tsconfig.test.json for bun test package', async () => {
633
796
  const root = await mkdtemp(join(tmpdir(), 'smoo-typecheck-test-policy-'));
634
797
  try {
@@ -734,6 +897,7 @@ describe('typecheck test policy', () => {
734
897
  name: '@scope/bad',
735
898
  scripts: { test: 'bun test' },
736
899
  });
900
+ await writeSource(join(root, 'packages/bad/src/bad.test.ts'));
737
901
  await writeJsonFs(join(root, 'packages/bad/tsconfig.test.json'), {
738
902
  compilerOptions: {
739
903
  composite: true,
@@ -936,6 +1100,327 @@ describe('typecheck test policy', () => {
936
1100
  });
937
1101
  });
938
1102
 
1103
+ // ---------------------------------------------------------------------------
1104
+ // The test program's include comes from where the tests live, and a program
1105
+ // that selects no file is refused
1106
+ // ---------------------------------------------------------------------------
1107
+
1108
+ const SRC_GLOBS = [
1109
+ 'src/**/*.test.ts',
1110
+ 'src/**/*.spec.ts',
1111
+ 'src/**/__tests__/**/*.ts',
1112
+ 'src/**/__tests__/**/*.tsx',
1113
+ 'src/test-suite-tracer.ts',
1114
+ ];
1115
+
1116
+ function globsFor(directory: string): string[] {
1117
+ return [
1118
+ `${directory}/**/*.test.ts`,
1119
+ `${directory}/**/*.spec.ts`,
1120
+ `${directory}/**/__tests__/**/*.ts`,
1121
+ `${directory}/**/__tests__/**/*.tsx`,
1122
+ ];
1123
+ }
1124
+
1125
+ async function writeSource(path: string, text = 'export {};\n'): Promise<void> {
1126
+ await mkdir(dirname(path), { recursive: true });
1127
+ await writeFile(path, text);
1128
+ }
1129
+
1130
+ /** The shape of this repository's `tooling` project: tests beside the shell scripts, no src/. */
1131
+ async function toolingShapedWorkspace(root: string): Promise<void> {
1132
+ await writeJsonFs(join(root, 'package.json'), { workspaces: ['packages/*', 'tooling'] });
1133
+ await writeJsonFs(join(root, 'tsconfig.base.json'), { compilerOptions: {} });
1134
+ await writeJsonFs(join(root, 'tooling/package.json'), {
1135
+ name: '@scope/tooling',
1136
+ private: true,
1137
+ nx: {
1138
+ name: 'tooling',
1139
+ targets: {
1140
+ test: {
1141
+ executor: '@smoothbricks/nx-plugin:bounded-exec',
1142
+ options: { command: 'bun test --timeout=30000 direnv', cwd: '{projectRoot}' },
1143
+ },
1144
+ },
1145
+ },
1146
+ });
1147
+ await writeSource(join(root, 'tooling/direnv/enter-shell.test.ts'));
1148
+ }
1149
+
1150
+ describe('where the test program looks for tests', () => {
1151
+ it('includes the directory a src-less project keeps its tests in, not src', async () => {
1152
+ const root = await mkdtemp(join(tmpdir(), 'smoo-typecheck-test-policy-'));
1153
+ try {
1154
+ await toolingShapedWorkspace(root);
1155
+
1156
+ expect(applyTypecheckTestPolicy(root)).toBe(true);
1157
+
1158
+ const tsconfig = expectRecord(await readJsonFs(join(root, 'tooling/tsconfig.test.json')));
1159
+ expect(tsconfig.include).toEqual(globsFor('direnv'));
1160
+ expect(applyTypecheckTestPolicy(root)).toBe(false);
1161
+ expect(checkTypecheckTestPolicy(root)).toEqual([]);
1162
+ } finally {
1163
+ await rm(root, { recursive: true, force: true });
1164
+ }
1165
+ });
1166
+
1167
+ it('keeps the src convention for a package whose tests live in src', async () => {
1168
+ const root = await mkdtemp(join(tmpdir(), 'smoo-typecheck-test-policy-'));
1169
+ try {
1170
+ await writeJsonFs(join(root, 'package.json'), { workspaces: ['packages/*'] });
1171
+ await writeJsonFs(join(root, 'packages/app/package.json'), { name: '@scope/app', scripts: { test: 'bun test' } });
1172
+ await writeSource(join(root, 'packages/app/src/app.test.ts'));
1173
+ // A stray outside src stays the stray-test policy's to report; it must not widen the program.
1174
+ await writeSource(join(root, 'packages/app/scripts/helper.test.ts'));
1175
+
1176
+ applyTypecheckTestPolicy(root);
1177
+
1178
+ const tsconfig = expectRecord(await readJsonFs(join(root, 'packages/app/tsconfig.test.json')));
1179
+ expect(tsconfig.include).toEqual(SRC_GLOBS);
1180
+ } finally {
1181
+ await rm(root, { recursive: true, force: true });
1182
+ }
1183
+ });
1184
+
1185
+ it('does not add a glob for tests an include the project wrote already selects', async () => {
1186
+ const root = await mkdtemp(join(tmpdir(), 'smoo-typecheck-test-policy-'));
1187
+ try {
1188
+ await toolingShapedWorkspace(root);
1189
+ await writeJsonFs(join(root, 'tooling/tsconfig.test.json'), {
1190
+ extends: '../tsconfig.base.json',
1191
+ compilerOptions: {
1192
+ composite: false,
1193
+ declaration: false,
1194
+ declarationMap: false,
1195
+ emitDeclarationOnly: false,
1196
+ noEmit: true,
1197
+ types: ['bun'],
1198
+ },
1199
+ include: ['direnv/**/*'],
1200
+ });
1201
+
1202
+ expect(applyTypecheckTestPolicy(root)).toBe(false);
1203
+
1204
+ const tsconfig = expectRecord(await readJsonFs(join(root, 'tooling/tsconfig.test.json')));
1205
+ expect(tsconfig.include).toEqual(['direnv/**/*']);
1206
+ } finally {
1207
+ await rm(root, { recursive: true, force: true });
1208
+ }
1209
+ });
1210
+
1211
+ it('adds the directory to an include the project wrote that selects none of its tests', async () => {
1212
+ const root = await mkdtemp(join(tmpdir(), 'smoo-typecheck-test-policy-'));
1213
+ try {
1214
+ await toolingShapedWorkspace(root);
1215
+ await writeJsonFs(join(root, 'tooling/tsconfig.test.json'), {
1216
+ extends: '../tsconfig.base.json',
1217
+ compilerOptions: {
1218
+ composite: false,
1219
+ declaration: false,
1220
+ declarationMap: false,
1221
+ emitDeclarationOnly: false,
1222
+ noEmit: true,
1223
+ types: ['bun'],
1224
+ },
1225
+ include: ['src/**/*.test.ts'],
1226
+ });
1227
+
1228
+ expect(applyTypecheckTestPolicy(root)).toBe(true);
1229
+
1230
+ const tsconfig = expectRecord(await readJsonFs(join(root, 'tooling/tsconfig.test.json')));
1231
+ expect(tsconfig.include).toEqual(['src/**/*.test.ts', ...globsFor('direnv')]);
1232
+ } finally {
1233
+ await rm(root, { recursive: true, force: true });
1234
+ }
1235
+ });
1236
+ });
1237
+
1238
+ describe('a test program that selects none of its tests', () => {
1239
+ async function packageWithoutTests(root: string): Promise<void> {
1240
+ await writeJsonFs(join(root, 'package.json'), { workspaces: ['packages/*'] });
1241
+ await writeJsonFs(join(root, 'tsconfig.base.json'), { compilerOptions: {} });
1242
+ await writeJsonFs(join(root, 'packages/app/package.json'), { name: '@scope/app', scripts: { test: 'bun test' } });
1243
+ await writeSource(join(root, 'packages/app/src/index.ts'));
1244
+ }
1245
+
1246
+ it('is reported by the generator without writing the file, naming the project and why', async () => {
1247
+ const root = await mkdtemp(join(tmpdir(), 'smoo-typecheck-test-policy-'));
1248
+ try {
1249
+ await packageWithoutTests(root);
1250
+ const tree = new FsTree(root, false);
1251
+
1252
+ const results = stageManagedFiles(tree, renderTypecheckTestFiles(tree));
1253
+ const skipped = results.find((result) => result.target === 'packages/app/tsconfig.test.json');
1254
+
1255
+ expect(skipped?.action).toBe('skipped');
1256
+ expect(skipped?.reason).toContain('matches no file');
1257
+ expect(skipped?.reason).toContain('packages/app');
1258
+ expect(tree.exists('packages/app/tsconfig.test.json')).toBe(false);
1259
+ expect(() => assertNoManagedConflicts(results)).not.toThrow();
1260
+ } finally {
1261
+ await rm(root, { recursive: true, force: true });
1262
+ }
1263
+ });
1264
+
1265
+ it('is reported by the policy check', async () => {
1266
+ const root = await mkdtemp(join(tmpdir(), 'smoo-typecheck-test-policy-'));
1267
+ try {
1268
+ await packageWithoutTests(root);
1269
+ await writeJsonFs(join(root, 'packages/app/tsconfig.test.json'), {
1270
+ extends: '../../tsconfig.base.json',
1271
+ compilerOptions: {
1272
+ composite: false,
1273
+ declaration: false,
1274
+ declarationMap: false,
1275
+ emitDeclarationOnly: false,
1276
+ noEmit: true,
1277
+ types: ['bun'],
1278
+ },
1279
+ include: SRC_GLOBS,
1280
+ });
1281
+
1282
+ const issues = checkTypecheckTestPolicy(root);
1283
+
1284
+ expect(issues.map((issue) => issue.path)).toEqual([join(root, 'packages/app/tsconfig.test.json')]);
1285
+ expect(issues[0]?.message).toContain('matches no file');
1286
+ } finally {
1287
+ await rm(root, { recursive: true, force: true });
1288
+ }
1289
+ });
1290
+
1291
+ it('is refused when its exclude removes every test', async () => {
1292
+ const root = await mkdtemp(join(tmpdir(), 'smoo-typecheck-test-policy-'));
1293
+ try {
1294
+ await packageWithoutTests(root);
1295
+ await writeSource(join(root, 'packages/app/src/app.test.ts'));
1296
+ await writeJsonFs(join(root, 'packages/app/tsconfig.test.json'), {
1297
+ extends: '../../tsconfig.base.json',
1298
+ compilerOptions: {
1299
+ composite: false,
1300
+ declaration: false,
1301
+ declarationMap: false,
1302
+ emitDeclarationOnly: false,
1303
+ noEmit: true,
1304
+ types: ['bun'],
1305
+ },
1306
+ include: SRC_GLOBS,
1307
+ exclude: ['src'],
1308
+ });
1309
+
1310
+ const issues = checkTypecheckTestPolicy(root);
1311
+
1312
+ expect(issues.map((issue) => issue.message).join('\n')).toContain('matches no file');
1313
+ } finally {
1314
+ await rm(root, { recursive: true, force: true });
1315
+ }
1316
+ });
1317
+
1318
+ it('is not refused while an inherited include the plugin cannot read may select files', async () => {
1319
+ const root = await mkdtemp(join(tmpdir(), 'smoo-typecheck-test-policy-'));
1320
+ try {
1321
+ await packageWithoutTests(root);
1322
+ await writeJsonFs(join(root, 'packages/app/tsconfig.test.json'), {
1323
+ extends: '@acme/tsconfig/bun.json',
1324
+ compilerOptions: {
1325
+ composite: false,
1326
+ declaration: false,
1327
+ declarationMap: false,
1328
+ emitDeclarationOnly: false,
1329
+ noEmit: true,
1330
+ types: ['bun'],
1331
+ },
1332
+ });
1333
+
1334
+ expect(checkTypecheckTestPolicy(root).some((issue) => issue.message.includes('matches no file'))).toBe(false);
1335
+ } finally {
1336
+ await rm(root, { recursive: true, force: true });
1337
+ }
1338
+ });
1339
+
1340
+ it('is reported for a workspace member named by path, which the packages/* listing never walked', async () => {
1341
+ const root = await mkdtemp(join(tmpdir(), 'smoo-typecheck-test-policy-'));
1342
+ try {
1343
+ await toolingShapedWorkspace(root);
1344
+ await writeJsonFs(join(root, 'tooling/tsconfig.test.json'), {
1345
+ extends: '../tsconfig.base.json',
1346
+ compilerOptions: {
1347
+ composite: false,
1348
+ declaration: false,
1349
+ declarationMap: false,
1350
+ emitDeclarationOnly: false,
1351
+ noEmit: true,
1352
+ types: ['bun'],
1353
+ },
1354
+ include: ['src/**/*.test.ts'],
1355
+ });
1356
+
1357
+ const issues = checkTypecheckTestPolicy(root);
1358
+
1359
+ expect(issues.map((issue) => issue.path)).toEqual([
1360
+ join(root, 'tooling/tsconfig.test.json'),
1361
+ join(root, 'tooling/tsconfig.test.json'),
1362
+ ]);
1363
+ expect(issues[0]?.message).toContain('matches no file of its tests');
1364
+ expect(issues[1]?.message).toContain('canonical');
1365
+ } finally {
1366
+ await rm(root, { recursive: true, force: true });
1367
+ }
1368
+ });
1369
+
1370
+ it('is reported by the Tree check too', () => {
1371
+ const tree = createTreeWithEmptyWorkspace();
1372
+ addProjectConfiguration(tree, 'app', { root: 'packages/app', targets: {} });
1373
+ writeJson(tree, 'packages/app/package.json', {
1374
+ name: '@scope/app',
1375
+ scripts: { test: 'bun test' },
1376
+ nx: { name: 'app' },
1377
+ });
1378
+ writeJson(tree, 'tsconfig.base.json', { compilerOptions: {} });
1379
+ tree.write('packages/app/src/index.ts', 'export {};\n');
1380
+ writeJson(tree, 'packages/app/tsconfig.test.json', {
1381
+ extends: '../../tsconfig.base.json',
1382
+ compilerOptions: { noEmit: true, composite: false, declaration: false, declarationMap: false, types: ['bun'] },
1383
+ include: SRC_GLOBS,
1384
+ });
1385
+
1386
+ expect(checkTypecheckTestPolicyTree(tree).map((issue) => issue.message)).toEqual([
1387
+ expect.stringContaining('matches no file (the project has no test file)'),
1388
+ ]);
1389
+ });
1390
+
1391
+ it('leaves an existing config it cannot honor as it was, and still repairs the project tsconfig.json', async () => {
1392
+ const root = await mkdtemp(join(tmpdir(), 'smoo-typecheck-test-policy-'));
1393
+ try {
1394
+ await packageWithoutTests(root);
1395
+ await writeJsonFs(join(root, 'packages/app/tsconfig.json'), {
1396
+ references: [{ path: './tsconfig.lib.json' }, { path: './tsconfig.test.json' }],
1397
+ });
1398
+
1399
+ const tree = new FsTree(root, false);
1400
+ const results = stageManagedFiles(tree, renderTypecheckTestFiles(tree));
1401
+
1402
+ expect(results.find((result) => result.target === 'packages/app/tsconfig.json')?.action).toBe('updated');
1403
+ expect(results.find((result) => result.target === 'packages/app/tsconfig.test.json')?.action).toBe('skipped');
1404
+ } finally {
1405
+ await rm(root, { recursive: true, force: true });
1406
+ }
1407
+ });
1408
+
1409
+ it('does not stumble on a dangling link beside the sources', async () => {
1410
+ const root = await mkdtemp(join(tmpdir(), 'smoo-typecheck-test-policy-'));
1411
+ try {
1412
+ await packageWithoutTests(root);
1413
+ await writeSource(join(root, 'packages/app/src/app.test.ts'));
1414
+ await symlink(join(root, 'nowhere'), join(root, 'packages/app/result'));
1415
+
1416
+ expect(applyTypecheckTestPolicy(root)).toBe(true);
1417
+ expect(checkTypecheckTestPolicy(root)).toEqual([]);
1418
+ } finally {
1419
+ await rm(root, { recursive: true, force: true });
1420
+ }
1421
+ });
1422
+ });
1423
+
939
1424
  interface TypeScriptReference {
940
1425
  path: string;
941
1426
  }