Repository navigation
Closed as duplicate
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
v20
Description
Standalone components added to imports in TestBed.configureTestingModule are not available to non-standalone components in declarations. This was working in v20 with Karma. See the reproduction below.
Minimal Reproduction
ng new my-app- Add this test file:
import { TestBed } from '@angular/core/testing';
import { Component } from '@angular/core';
it('should create', async () => {
@Component({
selector: 'comp-a',
template: `Component A`,
})
class ComponentA {}
@Component({
standalone: false,
selector: 'comp-b',
template: `<comp-a />`,
})
class ComponentB {}
TestBed.configureTestingModule({
imports: [ComponentA],
declarations: [ComponentB],
});
TestBed.createComponent(ComponentB);
});ng test
Exception or Error
✘ [ERROR] NG8001: 'comp-a' is not a known element:
1. If 'comp-a' is an Angular component, then verify that it is part of this module.
2. If 'comp-a' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. [plugin angular-compiler]
Your Environment
Angular CLI : 21.0.3
Angular : 21.0.4
Node.js : 22.20.0
Package Manager : npm 10.9.3
Operating System : darwin arm64
┌───────────────────────────────────┬───────────────────┬───────────────────┐
│ Package │ Installed Version │ Requested Version │
├───────────────────────────────────┼───────────────────┼───────────────────┤
│ @angular-devkit/architect │ 0.2100.3 │ ^0.2100.0 │
│ @angular-devkit/build-angular │ 21.0.3 │ ^21.0.0 │
│ @angular-devkit/core │ 21.0.3 │ ^21.0.0 │
│ @angular/build │ 21.0.3 │ ^21.0.3 │
│ @angular/cli │ 21.0.3 │ ^21.0.3 │
│ @angular/common │ 21.0.4 │ ^21.0.0 │
│ @angular/compiler │ 21.0.4 │ ^21.0.0 │
│ @angular/compiler-cli │ 21.0.4 │ ^21.0.0 │
│ @angular/core │ 21.0.4 │ ^21.0.0 │
│ @angular/forms │ 21.0.4 │ ^21.0.0 │
│ @angular/platform-browser │ 21.0.4 │ ^21.0.0 │
│ @angular/platform-browser-dynamic │ 21.0.4 │ ^21.0.0 │
│ @angular/router │ 21.0.4 │ ^21.0.0 │
│ ng-packagr │ 21.0.0 │ ^21.0.0 │
│ rxjs │ 7.8.2 │ ~7.8.0 │
│ typescript │ 5.9.3 │ ~5.9.2 │
│ vitest │ 4.0.15 │ ^4.0.8 │
└───────────────────────────────────┴───────────────────┴───────────────────┘
Anything else relevant?
No response
Metadata
Metadata
Assignees
Labels
No labels
Activity
[-]TestBed imports not shared with non-standalone declarations[/-][+]TestBed imports not shared with non-standalone declarations (AOT)[/+]angular-automatic-lock-bot commentedon Jan 11, 2026
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.