Title: Cannot set base providers because it has already been called when running >1 test cases with Vitest ^4.0.5 · Issue #32754 · angular/angular-cli · GitHub
Open Graph Title: Cannot set base providers because it has already been called when running >1 test cases with Vitest ^4.0.5 · Issue #32754 · angular/angular-cli
X Title: Cannot set base providers because it has already been called when running >1 test cases with Vitest ^4.0.5 · Issue #32754 · angular/angular-cli
Description: Which @angular/* package(s) are the source of the bug? Don't known / other Is this a regression? Yes Description When running an Angular test suite with @angular/platform-browser/testing@21.2.1 and vitest@4.0.18, the test runner throws t...
Open Graph Description: Which @angular/* package(s) are the source of the bug? Don't known / other Is this a regression? Yes Description When running an Angular test suite with @angular/platform-browser/testing@21.2.1 and...
X Description: Which @angular/* package(s) are the source of the bug? Don't known / other Is this a regression? Yes Description When running an Angular test suite with @angular/platform-browser/testing@21.2.1...
Opengraph URL: https://github.com/angular/angular-cli/issues/32754
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Cannot set base providers because it has already been called when running >1 test cases with Vitest ^4.0.5","articleBody":"### Which @angular/* package(s) are the source of the bug?\n\nDon't known / other\n\n### Is this a regression?\n\nYes\n\n### Description\n\nWhen running an Angular test suite with @angular/platform-browser/testing@21.2.1 and vitest@4.0.18, the test runner throws the following error after the second test case:\n\n\nError: Cannot set base providers because it has already been called\nThe error originates from Angular's TestBed.initTestEnvironment() being invoked multiple times within the same worker context. Vitest ^4.0.5 appears to have changed how setupFiles and worker isolation interact, causing the test-setup.ts to be re-executed for subsequent test files while the Angular TestBed state is already initialized from the previous run.\n\nThe issue only surfaces when running 2 or more test files/cases on Github Actions. Running 1 passes without error.\n\n\n\n### Please provide a link to a minimal reproduction of the bug\n\n_No response_\n\n### Please provide the exception or error you saw\n\n```true\nError: Cannot set base providers because it has already been called\n ❯ _TestBedImpl.initTestEnvironment ../../node_modules/.pnpm/k8-fastbuild-ST-fdfa778d11ba/bin/packages/core/testing/src/test_bed.ts:477:13\n ❯ ../../test-setup.ts:145:14\n 143| );\n 144| \n 145| getTestBed().initTestEnvironment(\n | ^\n 146| BrowserTestingModule,\n 147| platformBrowserTesting(),\n```\n\n### Please provide the environment you discovered this bug in (run `ng version`)\n\n```true\nvitest\t4.0.18\n@vitest/coverage-v8\t4.0.18\n@analogjs/vitest-angular\t2.2.1\n@analogjs/vite-plugin-angular\t^2.3.1\n@angular/core\t21.2.1\n@nx/vitest\t22.5.4\nhappy-dom\t^20.1.0\ntypescript\t5.9.3\n@angular/platform-browser\t21.2.1\n@angular/core\t21.2.1 \n```\n\n### Anything else?\n\nThis issue is reported in the vitest repository, they implied that \"Angular forces isolate to be false.\", which cause the issue\n[https://github.com/vitest-dev/vitest/issues/8944](Regression: 4.0.5 broke Angular tests’ isolation?)","author":{"url":"https://github.com/thanh-nguyen-codeleap","@type":"Person","name":"thanh-nguyen-codeleap"},"datePublished":"2026-03-12T00:51:44Z","url":"https://github.com/angular/angular-cli/issues/32754"}
| 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:d7b04f2b-7fd5-a463-cccf-051657e879e9 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C0BC:62F48:A9451F:DFED38:6B01EE16 |
| html-safe-nonce | 1273e06844c7a29e5546bc26d1e874bc73eca5823090b807d2e68ae672f998dd |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMEJDOjYyRjQ4OkE5NDUxRjpERkVEMzg6NkIwMUVFMTYiLCJ2aXNpdG9yX2lkIjoiOTE0ODE0NzMwMDM0NjA1NTkxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | a4de585af8e81eac5fe436cfac0963fa5036700be4c6d93d69e7a5838d28bc51 |
| hovercard-subject-tag | issue:4061695065 |
| 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/32754/issue_layout |
| twitter:image | https://opengraph.githubassets.com/cdaf511721ab640e7a39010cf8de032dc5bacbb52fb2a632bd81ee3f45bd1b97/angular/angular-cli/issues/32754 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/cdaf511721ab640e7a39010cf8de032dc5bacbb52fb2a632bd81ee3f45bd1b97/angular/angular-cli/issues/32754 |
| og:image:alt | Which @angular/* package(s) are the source of the bug? Don't known / other Is this a regression? Yes Description When running an Angular test suite with @angular/platform-browser/testing@21.2.1 and... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | thanh-nguyen-codeleap |
| 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