You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Execute the tests by running npm test in the provided reproduction repository.
What is expected?
No warning/error is logged while executing the tests
What is actually happening?
NG0912: Component ID generation collision detected. Components 'CdkVirtualScrollViewport' and 'CdkVirtualScrollViewport' with selector 'cdk-virtual-scroll-viewport' generated the same component ID. To fix this, you can change the selector of one of those components or add an extra host attribute to force a different ID. Find more at https://angular.dev/errors/NG0912 is logged while executing the tests. At regular runtime of the application, I was unable to reproduce the error.
Please provide the exception or error you saw
NG0912: Component ID generation collision detected. Components 'CdkVirtualScrollViewport' and 'CdkVirtualScrollViewport' with selector 'cdk-virtual-scroll-viewport' generated the same component ID. To fix this, you can change the selector of one of those components or add an extra host attribute to force a different ID. Find more at https://angular.dev/errors/NG0912
Other information
The error does not appear if one of the imports in app.component.ts from the cdk or from ng-zorro is removed. Then the test runs without any error.
The tests are executed with vitest.
I assume that somehow during test execution two different versions of the mentioned component are imported.
I also raised an issue in ng-zorro in case it is related to the bundle they produce: NG-ZORRO/ng-zorro-antd#9354 and in vitest in case it is related to how the imports are resolved during test execution: vitest-dev/vitest#8480
I would be willing to submit a PR to fix this issue
This discussion was converted from issue #1853 on November 07, 2025 16:24.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Please provide the environment you discovered this bug in.
Reproduction link
https://github.com/troehling/ng0912-component-id-collision
Which area/package is the issue in?
vitest-angular
Description
Steps to reproduce
Execute the tests by running
npm testin the provided reproduction repository.What is expected?
No warning/error is logged while executing the tests
What is actually happening?
NG0912: Component ID generation collision detected. Components 'CdkVirtualScrollViewport' and 'CdkVirtualScrollViewport' with selector 'cdk-virtual-scroll-viewport' generated the same component ID. To fix this, you can change the selector of one of those components or add an extra host attribute to force a different ID. Find more at https://angular.dev/errors/NG0912is logged while executing the tests. At regular runtime of the application, I was unable to reproduce the error.Please provide the exception or error you saw
Other information
The error does not appear if one of the imports in
app.component.tsfrom the cdk or from ng-zorro is removed. Then the test runs without any error.The tests are executed with vitest.
I assume that somehow during test execution two different versions of the mentioned component are imported.
I also raised an issue in ng-zorro in case it is related to the bundle they produce: NG-ZORRO/ng-zorro-antd#9354 and in vitest in case it is related to how the imports are resolved during test execution: vitest-dev/vitest#8480
I would be willing to submit a PR to fix this issue
Beta Was this translation helpful? Give feedback.
All reactions