Commit 1507788
authored
chore(repo): short-circuit isUsingTsSolutionSetup in unit tests (#35371)
## Current Behavior
`isUsingTsSolutionSetup()` (in both `@nx/js` and `@nx/workspace`) falls
back to `new FsTree(workspaceRoot, false)` when called without a tree,
reading the real repo's `tsconfig.json` / `tsconfig.base.json`. Many
unit tests indirectly invoke it (cypress-preset, playwright-preset,
plugin `createNodesV2`, executor `normalize`, etc.), which surfaces as
sandbox violations across ~13 test targets (angular, rspack, vite,
rollup, webpack, react, next, js, cypress, remix, workspace, nest,
node).
## Expected Behavior
Unit tests should never touch the real workspace FS. A global mock in
`scripts/unit-test-setup.js` short-circuits `isUsingTsSolutionSetup()`
when called without a tree, returning `true` to match the de-facto
behavior of hitting the real FS (the Nx repo is a TS solution workspace)
and preserve every test's existing expectations. Calls that pass an
explicit (virtual) tree still run the real implementation.
Two specs that deliberately simulate a non-TS-solution workspace (via
`node:fs` / `workspaceRoot` mocks) add a per-file override returning
`false` to keep expressing that intent:
- `packages/vite/src/plugins/plugin-vitest.spec.ts`
- `packages/rollup/src/plugins/with-nx/normalize-options.spec.ts`1 parent a0b4bf8 commit 1507788
3 files changed
Lines changed: 52 additions & 0 deletions
File tree
- packages
- rollup/src/plugins/with-nx
- vite/src/plugins
- scripts
Lines changed: 9 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
8 | 17 | | |
9 | 18 | | |
10 | 19 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
62 | 71 | | |
63 | 72 | | |
64 | 73 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
42 | 76 | | |
0 commit comments