Title: ng-add support for Vitest browser providers doesn't work · Issue #32401 · angular/angular-cli · GitHub
Open Graph Title: ng-add support for Vitest browser providers doesn't work · Issue #32401 · angular/angular-cli
X Title: ng-add support for Vitest browser providers doesn't work · Issue #32401 · angular/angular-cli
Description: Command add 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 @angular/cli v21.2.0-next.0 added in f80db6f add ng-add support ...
Open Graph Description: Command add 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 @angular/cli v21.2.0-nex...
X Description: Command add 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 @angular/cli v21.2.0-nex...
Opengraph URL: https://github.com/angular/angular-cli/issues/32401
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"ng-add support for Vitest browser providers doesn't work","articleBody":"### Command\n\nadd\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\n@angular/cli v21.2.0-next.0 added in https://github.com/angular/angular-cli/commit/f80db6fb714aa326f6ed03a8a51090ca59ad0955 `add ng-add support for Vitest browser providers` but it is not complete and does not actually work.\n\nThe schematic correctly adds the required packages and modifies `tsconfig.spec.json` but does not add the `browsers` option as documented at https://angular.dev/guide/testing/migrating-to-vitest#5-configure-browser-mode-optional.\n\nWithout this option the test doesn't actually run in browser environment and is still run in DOM emulation library within Node.js.\n\n### Minimal Reproduction\n\nRepro steps:\n\n1. `ng new angular22dot2dot0next0 --ssr=false --style=scss --ai-config=none`\n2. `ng add @vitest/browser-playwright`\n3. `npx playwright install`\n4. Open `app.spec.ts` and add line to any test: `console.log('RUNNING IN:', navigator.userAgent);`\n5. Run test via `ng test`\n6. Observe the console outputs: `RUNNING IN: Mozilla/5.0 (win32) AppleWebKit/537.36 (KHTML, like Gecko) jsdom/27.4.0`\n7. Test still runs in Node.js with DOM emulation, not in Vitest browser ❌\n\nHow to fix:\n\n1. Open `angular.json` and change:\n```json\n\"test\": {\n \"builder\": \"@angular/build:unit-test\"\n}\n```\n\nto:\n```json\n\"test\": {\n \"builder\": \"@angular/build:unit-test\",\n \"options\": {\n \"browsers\": [\"chromium\"]\n }\n}\n```\n2. Run test via `ng test`\n3. Observe actual Chrome for Testing window opens and Console outputs: `RUNNING IN: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36`\n4. Test runs in Vitest browser 👍 \n\n### Exception or Error\n\n```text\n\n```\n\n### Your Environment\n\n```text\n_ _ ____ _ ___\n / \\ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|\n / △ \\ | '_ \\ / _` | | | | |/ _` | '__| | | | | | |\n / ___ \\| | | | (_| | |_| | | (_| | | | |___| |___ | |\n /_/ \\_\\_| |_|\\__, |\\__,_|_|\\__,_|_| \\____|_____|___|\n |___/\n\n\nAngular CLI : 21.2.0-next.0\nNode.js : 24.13.0\nPackage Manager : npm 11.6.2\nOperating System : win32 x64\n```\n\n### Anything else relevant?\n\n_No response_","author":{"url":"https://github.com/klofi","@type":"Person","name":"klofi"},"datePublished":"2026-01-30T15:41:18.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/32401/angular-cli/issues/32401"}
| 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:09ebe5fa-8f60-714f-172b-a2cdfa3afc36 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E9AA:142F2A:50FC5E:7345FE:6A62FE09 |
| html-safe-nonce | 1ca26eff0d71c59aefb30877387b74c6d88095626643555309fb1bb856905def |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFOUFBOjE0MkYyQTo1MEZDNUU6NzM0NUZFOjZBNjJGRTA5IiwidmlzaXRvcl9pZCI6IjUzMzcwNzczNDc5NTg3Nzg5NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | a05401f1670e948ea60e61d4c9a9b8844eb412f42b0297fcee7861f6ab668f6a |
| hovercard-subject-tag | issue:3876243968 |
| 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/32401/issue_layout |
| twitter:image | https://opengraph.githubassets.com/496bbc10313c1c6875524c25fba72395f2dd7e9f3cd8646ca7516ae404a211ca/angular/angular-cli/issues/32401 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/496bbc10313c1c6875524c25fba72395f2dd7e9f3cd8646ca7516ae404a211ca/angular/angular-cli/issues/32401 |
| og:image:alt | Command add 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 @angular/cli v21.2.0-nex... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | klofi |
| hostname | github.com |
| expected-hostname | github.com |
| None | 59e40dc698184067b40ef2d941585f66ed42711564a879644f984f1eacea129c |
| 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 | b4f544bf80583e749557efd76afda56317b6252d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width