Title: Regression TestBed.overrideComponent in Angular 17 · Issue #52817 · angular/angular · GitHub
Open Graph Title: Regression TestBed.overrideComponent in Angular 17 · Issue #52817 · angular/angular
X Title: Regression TestBed.overrideComponent in Angular 17 · Issue #52817 · angular/angular
Description: Which @angular/* package(s) are the source of the bug? core Is this a regression? Yes Description TestBed.overrideComponent doesn't override standalone components if the components have been used in other tests before. Might be related t...
Open Graph Description: Which @angular/* package(s) are the source of the bug? core Is this a regression? Yes Description TestBed.overrideComponent doesn't override standalone components if the components have been used i...
X Description: Which @angular/* package(s) are the source of the bug? core Is this a regression? Yes Description TestBed.overrideComponent doesn't override standalone components if the components have been us...
Opengraph URL: https://github.com/angular/angular/issues/52817
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Regression TestBed.overrideComponent in Angular 17","articleBody":"### Which @angular/* package(s) are the source of the bug?\r\n\r\ncore\r\n\r\n### Is this a regression?\r\n\r\nYes\r\n\r\n### Description\r\n\r\n`TestBed.overrideComponent` doesn't override standalone components if the components have been used in other tests before. Might be related to https://github.com/angular/angular/issues/48432.\r\n\r\nTo reproduce, run the next test in any Angular 17 project.\r\nIt looks like there is a race, something isn't awaited properly.\r\nThe first test is skipped with `x`, remove `x` to reproduce the issue.\r\nIf you've got success, simply add `x` back and remove it again.\r\nIn this case, you can see that the 2nd test fails time to time because `overrideComponent` wasn't applied.\r\n\r\n```ts\r\nimport { TestBed } from '@angular/core/testing';\r\nimport { Component } from '@angular/core';\r\nimport { RouterOutlet } from '@angular/router';\r\n\r\n@Component({\r\n selector: '\u003crouter-outlet>\u003c/router-outlet>',\r\n standalone: true,\r\n template: 'mock',\r\n})\r\nexport class MockRouterOutlet {}\r\n\r\n@Component({\r\n selector: 'app-root',\r\n standalone: true,\r\n imports: [RouterOutlet],\r\n template: '\u003crouter-outlet>\u003c/router-outlet>',\r\n})\r\nexport class AppComponent {\r\n title = 'a17';\r\n}\r\n\r\ndescribe('AppComponent with real router', () => {\r\n beforeEach(async () => {\r\n await TestBed.configureTestingModule({\r\n imports: [AppComponent],\r\n }).compileComponents();\r\n });\r\n\r\n // REMOVE \"x\" TO REPRODUCE THE ISSUE\r\n xit('should create the app', () => {\r\n const fixture = TestBed.createComponent(AppComponent);\r\n expect(fixture.nativeElement.innerHTML).toEqual('\u003crouter-outlet>\u003c/router-outlet>\u003c!--container-->');\r\n });\r\n});\r\n\r\ndescribe('AppComponent with mock router', () => {\r\n beforeEach(async () => {\r\n await TestBed.configureTestingModule({\r\n imports: [AppComponent],\r\n }).overrideComponent(AppComponent, {\r\n set: {\r\n imports: [MockRouterOutlet],\r\n }\r\n }).compileComponents();\r\n });\r\n\r\n it('should create the app', () => {\r\n const fixture = TestBed.createComponent(AppComponent);\r\n expect(fixture.nativeElement.innerHTML).toEqual('\u003crouter-outlet>mock\u003c/router-outlet>');\r\n });\r\n});\r\n```\r\n\r\n### Please provide a link to a minimal reproduction of the bug\r\n\r\n_No response_\r\n\r\n### Please provide the exception or error you saw\r\n\r\n```true\r\nNo errors, `TestBed.overrideComponent` doesn't simply do anything.\r\n```\r\n\r\n\r\n### Please provide the environment you discovered this bug in (run `ng version`)\r\n\r\n```true\r\nngular CLI: 17.0.0\r\nNode: 20.9.0\r\nPackage Manager: npm 10.1.0\r\nOS: darwin x64\r\n\r\nAngular: 17.0.2\r\n... animations, common, compiler, compiler-cli, core, forms\r\n... platform-browser, platform-browser-dynamic, router\r\n\r\nPackage Version\r\n---------------------------------------------------------\r\n@angular-devkit/architect 0.1700.0\r\n@angular-devkit/build-angular 17.0.0\r\n@angular-devkit/core 17.0.0\r\n@angular-devkit/schematics 17.0.0\r\n@angular/cli 17.0.0\r\n@schematics/angular 17.0.0\r\nrxjs 7.8.1\r\ntypescript 5.2.2\r\nzone.js 0.14.2\r\n```\r\n\r\n\r\n### Anything else?\r\n\r\n_No response_","author":{"url":"https://github.com/satanTime","@type":"Person","name":"satanTime"},"datePublished":"2023-11-11T13:36:07Z","url":"https://github.com/angular/angular/issues/52817"}
| 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:cd2458a4-10b4-3b4b-a2b3-812b426ba5a1 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9068:76F02:36A34A9:45E55AD:6B01E9A8 |
| html-safe-nonce | 525558d8e841e34d85dd956e23d917db769ade0d779291223b417939ee8211ef |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MDY4Ojc2RjAyOjM2QTM0QTk6NDVFNTVBRDo2QjAxRTlBOCIsInZpc2l0b3JfaWQiOiIxNjA5ODY0MjkyNDk5MzE5MjA4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | b9db8d5c0538eea1257ae88145154fb6d76fb38b6c5b76ca83057e81ab75e94a |
| hovercard-subject-tag | issue:1988951642 |
| 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/52817/issue_layout |
| twitter:image | https://opengraph.githubassets.com/336c992a5bb951d79db87f3b9fd20d2db2dd1ab8e6a8a59795451bbb8dbaef06/angular/angular/issues/52817 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/336c992a5bb951d79db87f3b9fd20d2db2dd1ab8e6a8a59795451bbb8dbaef06/angular/angular/issues/52817 |
| og:image:alt | Which @angular/* package(s) are the source of the bug? core Is this a regression? Yes Description TestBed.overrideComponent doesn't override standalone components if the components have been used i... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | satanTime |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angular git https://github.com/angular/angular.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 24195339 |
| octolytics-dimension-repository_nwo | angular/angular |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 24195339 |
| octolytics-dimension-repository_network_root_nwo | angular/angular |
| 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