Title: `unit-test` builder resolves include paths relative to sourceRoot instead of project root, breaking secondary entry points tests · Issue #33467 · angular/angular-cli · GitHub
Open Graph Title: `unit-test` builder resolves include paths relative to sourceRoot instead of project root, breaking secondary entry points tests · Issue #33467 · angular/angular-cli
X Title: `unit-test` builder resolves include paths relative to sourceRoot instead of project root, breaking secondary entry points tests · Issue #33467 · angular/angular-cli
Description: Command test Is this a regression? Yes, this behavior used to work in the previous version The previous version in which this bug was not present was No response Description When using the @angular/build:unit-test builder in a library pr...
Open Graph Description: Command test Is this a regression? Yes, this behavior used to work in the previous version The previous version in which this bug was not present was No response Description When using the @angular...
X Description: Command test Is this a regression? Yes, this behavior used to work in the previous version The previous version in which this bug was not present was No response Description When using the @angular...
Opengraph URL: https://github.com/angular/angular-cli/issues/33467
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`unit-test` builder resolves include paths relative to sourceRoot instead of project root, breaking secondary entry points tests","articleBody":"### Command\n\ntest\n\n### Is this a regression?\n\n- [ ] Yes, this behavior used to work in the previous version\n\n### The previous version in which this bug was not present was\n\n_No response_\n\n### Description\n\nWhen using the `@angular/build:unit-test` builder in a library project that contains Secondary Entry Points (sub-packages), the builder incorrectly resolves the glob patterns defined in the `include` array (inside `angular.json`) relative to the project's `sourceRoot` (usually `.../src`) instead of the project's root.\n\nBecause the unit-test builder anchors include patterns to `sourceRoot`, it cannot discover test files located in secondary entry points unless developers use relative path traversal (for example, `../my-sub-package/**/*.spec.ts`).\n\n\n### Minimal Reproduction\n\nCreate an Angular library project.\n2. Generate a secondary entry point inside the library root (for example, `projects/my-lib/my-sub-package/`).\n3. Add a unit test inside the secondary entry point:\n\n ```text\n projects/my-lib/my-sub-package/my-sub.spec.ts\n ```\n\n4. Configure the test target in `angular.json` using `@angular/build:unit-test`:\n\n ```json\n {\n \"options\": {\n \"include\": [\n \"**/*.spec.ts\",\n \"my-sub-package/**/*.spec.ts\"\n ],\n \"tsConfig\": \"projects/my-lib/tsconfig.spec.json\"\n }\n }\n ```\n\n5. Run:\n\n ```bash\n ng test\n ```\n\n### Exception or Error\n\nThe builder should resolve the `include` patterns relative to the project's root, or otherwise recognize ng-packagr secondary entry points, allowing patterns such as:\n\n```json\n{\n \"include\": [\n \"**/*.spec.ts\",\n \"my-sub-package/**/*.spec.ts\"\n ]\n}\n```\n\nto correctly match test files located in:\n\n```text\nprojects/my-lib/my-sub-package/\n```\n\n### Workaround\n\nCurrently, developers must escape the `sourceRoot` directory by using a parent path segment in `angular.json`:\n\n```json\n{\n \"options\": {\n \"include\": [\n \"**/*.spec.ts\",\n \"../my-sub-package/**/*.spec.ts\"\n ],\n \"tsConfig\": \"projects/my-lib/tsconfig.spec.json\"\n }\n}\n```\n\n### Your Environment\n\n```text\n_ _ ____ _ ___\n / \\ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|\n / △ \\ | '_ \\ / _` | | | | |/ _` | '__| | | | | | |\n / ___ \\| | | | (_| | |_| | | (_| | | | |___| |___ | |\n /_/ \\_\\_| |_|\\__, |\\__,_|_|\\__,_|_| \\____|_____|___|\n |___/\n \n\nAngular CLI : 22.0.4\nAngular : 22.0.2\nNode.js : 24.16.0\nPackage Manager : npm 11.13.0\nOperating System : linux x64\n\n┌───────────────────────────────────┬───────────────────┬───────────────────┐\n│ Package │ Installed Version │ Requested Version │\n├───────────────────────────────────┼───────────────────┼───────────────────┤\n│ @angular/animations │ 22.0.2 │ ^22.0.2 │\n│ @angular/build │ 22.0.4 │ ^22.0.4 │\n│ @angular/cli │ 22.0.4 │ ^22.0.4 │\n│ @angular/common │ 22.0.2 │ ^22.0.2 │\n│ @angular/compiler │ 22.0.2 │ ^22.0.2 │\n│ @angular/compiler-cli │ 22.0.2 │ ^22.0.2 │\n│ @angular/core │ 22.0.2 │ ^22.0.2 │\n│ @angular/forms │ 22.0.2 │ ^22.0.2 │\n│ @angular/localize │ 22.0.2 │ ^22.0.2 │\n│ @angular/platform-browser │ 22.0.2 │ ^22.0.2 │\n│ @angular/platform-browser-dynamic │ 22.0.2 │ ^22.0.2 │\n│ @angular/router │ 22.0.2 │ ^22.0.2 │\n│ @angular/service-worker │ 22.0.2 │ ^22.0.2 │\n│ ng-packagr │ 22.0.0 │ ^22.0.0 │\n│ rxjs │ 7.8.2 │ ~7.8.2 │\n│ typescript │ 6.0.3 │ ^6.0.3 │\n│ vitest │ 4.1.9 │ ^4.1.9 │\n│ zone.js │ 0.16.2 │ ^0.16.2 │\n└───────────────────────────────────┴───────────────────┴───────────────────┘\n```\n\n### Anything else relevant?\n\n_No response_","author":{"url":"https://github.com/Carlosamouco","@type":"Person","name":"Carlosamouco"},"datePublished":"2026-06-25T17:07:49Z","url":"https://github.com/angular/angular-cli/issues/33467"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:681f2d21-e449-9581-fd76-1028e90c3fbc |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DC64:1F68:CAF3D5:111B887:6B01EE15 |
| html-safe-nonce | c379aae18b066edf2c8ba41da0bc33049c85a9f02d07ab525eead58c47b2e8c1 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQzY0OjFGNjg6Q0FGM0Q1OjExMUI4ODc6NkIwMUVFMTUiLCJ2aXNpdG9yX2lkIjoiMjAzMjc2OTQ0MTMwMDg2ODYyOSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | ad99c02d88a025584a304550337b5172cbfb43a3b8d1d386985797ee591a4ae3 |
| hovercard-subject-tag | issue:4745902925 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular-cli/33467/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e28e28df1e93c3f94870acaed1200114018e7444db5c23bdad716dcfaeeec09e/angular/angular-cli/issues/33467 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e28e28df1e93c3f94870acaed1200114018e7444db5c23bdad716dcfaeeec09e/angular/angular-cli/issues/33467 |
| og:image:alt | Command test Is this a regression? Yes, this behavior used to work in the previous version The previous version in which this bug was not present was No response Description When using the @angular... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Carlosamouco |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angular-cli git https://github.com/angular/angular-cli.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 36891867 |
| octolytics-dimension-repository_nwo | angular/angular-cli |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 36891867 |
| octolytics-dimension-repository_network_root_nwo | angular/angular-cli |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width