Hi I am developing web application in angular 5. I am using toast messages to display messages. I am using toast messages from https://www.npmjs.com/package/angular2-toaster. The implementation is correct and working fine. I am facing issue with writing unit test cases. Below is my implementation in component. I have added below line of code in component.
import { ToasterModule, ToasterService } from 'angular2-toaster';
I have added below code in constructor.
private toasterService: ToasterService
I am showing toast message as below.
this.toasterService.pop('success', 'Args Title', 'Args Body');
I have added below code in HTML file.
<toaster-container></toaster-container>
This implementation works fine. I am writing unit test case as below.
describe('Component: TenantEditorComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
HttpClientModule,
RouterTestingModule,
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useClass: TranslateLanguageLoader
}
}),
NgxDatatableModule,
FormsModule,
UiSwitchModule,
TooltipModule.forRoot(),
ModalModule.forRoot(),
ToasterModule
],
providers: [ ToasterService ]
}).compileComponents();
fixture = TestBed.createComponent(TenantEditorComponent);
component = fixture.componentInstance;
submitEl = fixture.debugElement;
fixture.detectChanges();
}));
This is giving me error
No Toaster Containers have been initialized to receive toasts.
I have added screenshot below.
Can someone help me to figure it out the issue? Any help would be appreciated. Thank you