Even though I found a similar solution on Stackoverflow, it didn't resolve my issue. So, let me explain my scenario. When running the ng test command, I encountered the following error:
Failed: Unexpected directive 'InformationComponent' imported by the module 'DynamicTestModule'. Please add a @NgModule annotation. error properties: Object({ ngSyntaxError: true }) ...
I've attempted various solutions but none seem to work, as I still encounter this error.
uploadcomponent.spec.ts
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { UploadComponent } from './upload.component';
...
describe('UploadComponent', () => {
...
});
information-component.ts
import { Component, OnInit, Input, OnChanges } from '@angular/core';
import * as InformationMessages from '../../../json/InformationMessages.json';
@Component({
selector: 'app-information',
templateUrl: './information.component.html',
styleUrls: ['./information.component.css']
})
export class InformationComponent implements OnInit {
...
}
Your assistance in resolving this would be greatly appreciated.
app.module.ts
import {BrowserModule} from '@angular/platform-browser';
import {ErrorHandler, NgModule} from '@angular/core';
...
@NgModule({
declarations: [
AppComponent, HomeComponent, MenuComponent, HeadComponent, ArianeComponent,
PlanComponent, SeparatorComponent, FooterComponent, ErrorComponent
],
imports: [
BrowserModule,
AppRoutingModule,
BreadcrumbModule,
HttpClientModule,
...
],
providers: [...],
exports: [],
bootstrap: [AppComponent]
})
export class AppModule {
constructor(library: FaIconLibrary) {
library.addIcons(faArrowRight);
}
}