This error occurs when the Angular compiler cannot find the component under test in the declarations of the spec file.
The fix is to add the component under test in declarations of your spec file like this:
describe('YourComponent', () => {
let component: YourComponent;
let fixture: ComponentFixture<YourComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [
YourComponent,
.....,
],
...