René's URL Explorer Experiment


Title: `TestBed.overrideComponent` breaks module imports with `@angular/build:unit-test` · Issue #33064 · angular/angular-cli · GitHub

Open Graph Title: `TestBed.overrideComponent` breaks module imports with `@angular/build:unit-test` · Issue #33064 · angular/angular-cli

X Title: `TestBed.overrideComponent` breaks module imports with `@angular/build:unit-test` · Issue #33064 · 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 Reopening from angular/angular#68363 as I don't feel it was ful...

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 Reopening from 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 Reopening from angular/...

Opengraph URL: https://github.com/angular/angular-cli/issues/33064

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`TestBed.overrideComponent` breaks module imports with `@angular/build:unit-test`","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\nReopening from https://github.com/angular/angular/issues/68363 as I don't feel it was fully answered and I later found the issue is related to the new builder.\n\nWhen using the `@angular/build:unit-test` builder, `TestBed.overrideComponent` breaks imports out of modules. This happens for both vitest and karma runners, so I would assume it is connected to the build, not the test execution.\n\nThe issue does not occur when using other builder like `@angular-devkit/build-angular:karma`\n\n### Minimal Reproduction\n\nPlain Angular project + packages needed for running karma\n\n```typescript\n// app.spec.ts\nimport { Component, NgModule } from '@angular/core';\nimport { TestBed } from '@angular/core/testing';\n\n@Component({\n  selector: 'test-component',\n  template: '',\n})\nexport class TestComponent {}\n\n@NgModule({\n  imports: [TestComponent],\n  exports: [TestComponent],\n})\nexport class TestModule {}\n\n@Component({\n  selector: 'app-root',\n  imports: [TestModule],\n  template: ` \u003ctest-component>\u003c/test-component> `,\n})\nexport class App {}\n\ndescribe('App', () => {\n  beforeEach(async () => {\n    await TestBed.configureTestingModule({\n      imports: [App],\n    })\n      .overrideComponent(App, {}) // \u003c= problematic call\n      .compileComponents();\n  });\n\n  it('should create', () => {\n    expect(TestBed.createComponent(App)).toBeTruthy();\n  });\n});\n```\n\n```jsonc\n// angular.json\n...\n// fails\n\"test-vitest\": {\n  \"builder\": \"@angular/build:unit-test\",\n  \"options\": {\n    \"runner\": \"vitest\"\n  }\n},\n// fails\n\"test-karma\": {\n  \"builder\": \"@angular/build:unit-test\",\n  \"options\": {\n    \"runner\": \"karma\"\n  }\n},\n// this one works\n\"test-karma-devkit\": {\n  \"builder\": \"@angular-devkit/build-angular:karma\",\n  \"options\": {\n    \"tsConfig\": \"./tsconfig.spec.json\"\n  }\n}\n...\n```\n\nRunning the test with `@angular/build:unit-test` it fails for both runners with\n```\nError: NG0304: 'test-component' is not a known element (used in the '_App' component template):\n1. If 'test-component' is an Angular component, then verify that it is included in the '@Component.imports' of this component.\n2. If 'test-component' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@Component.schemas' of this component to suppress this message.\n ❯ validateElementIsKnown ../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/packages/core/src/render3/instructions/element_validation.ts:116:14\n ❯ validateElementIsKnown ../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/packages/core/src/render3/instructions/element.ts:151:4\n ❯ initializeElement ../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/packages/core/src/render3/instructions/element.ts:127:2\n ❯ ɵɵelementStart ../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/packages/core/src/render3/instructions/element.ts:218:2\n ❯ _App_Template ng:/_App.js:6:21\n ❯ templateFn ../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/packages/core/src/render3/instructions/shared.ts:109:4\n ❯ executeTemplate ../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/packages/core/src/render3/instructions/render.ts:107:6\n ❯ renderView ../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/packages/core/src/render3/instructions/render.ts:47:4\n ❯ renderComponent ../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/packages/core/src/render3/instructions/render.ts:160:4\n ❯ renderChildComponents ../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/packages/core/src/render3/instructions/render.ts:140:6\n```\n\nWith the `@angular-devkit/build-angular:karma` it passes as expected.\n\nAlso actually overriding something in `TestBed.overrideComponent` doesn't change the behaviour. I originally discovered this with a test that needs to stub a component. I left it out for simplicity here.\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.8\nAngular           : 21.2.10\nNode.js           : 24.15.0\nPackage Manager   : npm 10.9.4\nOperating System  : win32 x64\n\n┌───────────────────────────────┬───────────────────┬───────────────────┐\n│ Package                       │ Installed Version │ Requested Version │\n├───────────────────────────────┼───────────────────┼───────────────────┤\n│ @angular-devkit/build-angular │ 21.2.8            │ ^21.2.8           │\n│ @angular/build                │ 21.2.8            │ ^21.2.7           │\n│ @angular/cli                  │ 21.2.8            │ ^21.2.7           │\n│ @angular/common               │ 21.2.10           │ ^21.2.0           │\n│ @angular/compiler             │ 21.2.10           │ ^21.2.0           │\n│ @angular/compiler-cli         │ 21.2.10           │ ^21.2.0           │\n│ @angular/core                 │ 21.2.10           │ ^21.2.0           │\n│ @angular/forms                │ 21.2.10           │ ^21.2.0           │\n│ @angular/platform-browser     │ 21.2.10           │ ^21.2.0           │\n│ @angular/router               │ 21.2.10           │ ^21.2.0           │\n│ rxjs                          │ 7.8.2             │ ~7.8.0            │\n│ typescript                    │ 5.9.3             │ ~5.9.2            │\n│ vitest                        │ 4.1.5             │ ^4.0.8            │\n└───────────────────────────────┴───────────────────┴───────────────────┘\n```\n\n### Anything else relevant?\n\n_No response_","author":{"url":"https://github.com/m-yst-ery","@type":"Person","name":"m-yst-ery"},"datePublished":"2026-04-28T08:08:08Z","url":"https://github.com/angular/angular-cli/issues/33064"}

react-profiling0
react-import-mapreact,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-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:15105354-85ae-d96d-5108-1cbb8e03dfd0
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id8850:1AE20C:36431CD:44BB92E:6B01DE71
html-safe-noncecb98c8770a7aa805ea52e954af73a47f104711bc604ccc2fd26630a0c9b130b8
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4ODUwOjFBRTIwQzozNjQzMUNEOjQ0QkI5MkU6NkIwMURFNzEiLCJ2aXNpdG9yX2lkIjoiODI1NzIzMjU5Mjk1NzQ2NDE3NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac54bf6ededae63185a7501f92ddfbbc59c2aa74f73a112137d1c228682ecefa32
hovercard-subject-tagissue:4341555354
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular-cli/33064/issue_layout
twitter:imagehttps://opengraph.githubassets.com/53d0c5a1ca7d01cd6367dbe795339244918f504fadd45585d9af07cb4eb9fe2e/angular/angular-cli/issues/33064
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/53d0c5a1ca7d01cd6367dbe795339244918f504fadd45585d9af07cb4eb9fe2e/angular/angular-cli/issues/33064
og:image:altCommand 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 Reopening from angular/...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamem-yst-ery
hostnamegithub.com
expected-hostnamegithub.com
Nonecc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c
turbo-cache-controlno-preview
go-importgithub.com/angular/angular-cli git https://github.com/angular/angular-cli.git
octolytics-dimension-user_id139426
octolytics-dimension-user_loginangular
octolytics-dimension-repository_id36891867
octolytics-dimension-repository_nwoangular/angular-cli
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id36891867
octolytics-dimension-repository_network_root_nwoangular/angular-cli
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release8c77c9e8439031ad54c75a250694842892f693e1
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/angular/angular-cli/issues/33064#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fangular%2Fangular-cli%2Fissues%2F33064
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fangular%2Fangular-cli%2Fissues%2F33064
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=angular%2Fangular-cli
Reloadhttps://github.com/angular/angular-cli/issues/33064
Reloadhttps://github.com/angular/angular-cli/issues/33064
Reloadhttps://github.com/angular/angular-cli/issues/33064
angularhttps://github.com/angular
angular-clihttps://github.com/angular/angular-cli
Codehttps://github.com/angular/angular-cli
Issues198 (198)https://github.com/angular/angular-cli/issues
Pull requests23 (23)https://github.com/angular/angular-cli/pulls
Actionshttps://github.com/angular/angular-cli/actions
Security and quality8 (8)https://github.com/angular/angular-cli/security
Insightshttps://github.com/angular/angular-cli/insights
https://github.com/angular/angular-cli
New issuehttps://github.com/login?return_to=https://github.com/angular/angular-cli/issues/33064
New issuehttps://github.com/login?return_to=https://github.com/angular/angular-cli/issues/33064
TestBed.overrideComponent breaks module imports with @angular/build:unit-testhttps://github.com/angular/angular-cli/issues/33064#top
angular/build:unit-testhttps://github.com/angular/angular-cli/issues?q=state%3Aopen%20label%3A%22angular%2Fbuild%3Aunit-test%22
area: @angular/buildhttps://github.com/angular/angular-cli/issues?q=state%3Aopen%20label%3A%22area%3A%20%40angular%2Fbuild%22
https://github.com/m-yst-ery
m-yst-eryhttps://github.com/m-yst-ery
on Apr 28, 2026https://github.com/angular/angular-cli/issues/33064#issue-4341555354
angular/angular#68363https://github.com/angular/angular/issues/68363
alan-agius4https://github.com/alan-agius4
area: @angular/buildhttps://github.com/angular/angular-cli/issues?q=state%3Aopen%20label%3A%22area%3A%20%40angular%2Fbuild%22
angular/build:unit-testhttps://github.com/angular/angular-cli/issues?q=state%3Aopen%20label%3A%22angular%2Fbuild%3Aunit-test%22
on Apr 28, 2026https://github.com/angular/angular-cli/issues/33064#event-24949397788
https://github.com/abercrave
abercravehttps://github.com/abercrave
on May 29, 2026https://github.com/angular/angular-cli/issues/33064#issuecomment-4577394145
the OP's clarificationhttps://github.com/angular/angular/issues/68363#issuecomment-4314399577
https://github.com/johncrim
johncrimhttps://github.com/johncrim
on Jul 4, 2026https://github.com/angular/angular-cli/issues/33064#issuecomment-4883963119
https://github.com/johncrim
johncrimhttps://github.com/johncrim
on Jul 5, 2026https://github.com/angular/angular-cli/issues/33064#issuecomment-4887371539
https://github.com/johncrim/ng-testbed-compile-bughttps://github.com/johncrim/ng-testbed-compile-bug
TestBed.overrideComponent doesn't update standalone components angular#48432https://github.com/angular/angular/issues/48432
https://github.com/johncrim
johncrimhttps://github.com/johncrim
on Jul 5, 2026https://github.com/angular/angular-cli/issues/33064#issuecomment-4887531868
This code blockhttps://github.com/johncrim/ng-testbed-compile-bug/blob/main/src/tests/testbedNotStandaloneOverrideImports.spec.ts#L28
https://github.com/JeanMeche
JeanMechehttps://github.com/JeanMeche
on Jul 5, 2026https://github.com/angular/angular-cli/issues/33064#issuecomment-4887679125
angular/angular#65665https://github.com/angular/angular/issues/65665
https://github.com/johncrim
johncrimhttps://github.com/johncrim
on Jul 6, 2026https://github.com/angular/angular-cli/issues/33064#issuecomment-4897072455
@JeanMechehttps://github.com/JeanMeche
angular#65665https://github.com/angular/angular/issues/65665
angular#65665https://github.com/angular/angular/issues/65665
run the testshttps://github.com/johncrim/ng-testbed-compile-bug/blob/main/README.md
https://github.com/johncrim/ng-testbed-compile-bughttps://github.com/johncrim/ng-testbed-compile-bug
johncrimhttps://github.com/johncrim
on Jul 6, 2026https://github.com/angular/angular-cli/issues/33064#event-27629512423
improve(tests): Add support for running legacy karma builder with aot…https://github.com/johncrim/ng-testbed-compile-bug/commit/6199e7aa8703c70f9d9133e4bd5d080a5da765c3
6199e7ahttps://github.com/johncrim/ng-testbed-compile-bug/commit/6199e7aa8703c70f9d9133e4bd5d080a5da765c3
Sign up for freehttps://github.com/signup?return_to=https://github.com/angular/angular-cli/issues/33064
Sign in to commenthttps://github.com/login?return_to=https://github.com/angular/angular-cli/issues/33064
angular/build:unit-testhttps://github.com/angular/angular-cli/issues?q=state%3Aopen%20label%3A%22angular%2Fbuild%3Aunit-test%22
area: @angular/buildhttps://github.com/angular/angular-cli/issues?q=state%3Aopen%20label%3A%22area%3A%20%40angular%2Fbuild%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.