-
-
Notifications
You must be signed in to change notification settings - Fork 282
Description
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 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
- Yes
- No