I added a PrimeNG components and was able to do a successful build but then when I run "ng test" to run the unit tests, I get errors like this for all of the PrimeNG components I use:
p-calendar' is not a known element.
1. If 'p-calendar' is an Angular component, then verify that it is part of this module.
2. If 'p-calendar' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message.
My spec file:
Code: Select all
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import {Response, ResponseOptions, HttpModule, XHRBackend} from '@angular/http';
import {MockBackend, MockConnection} from '@angular/http/testing';
import { By } from '@angular/platform-browser';
import { DebugElement } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { ManualTransactionsComponent } from '../../components';
import { ManualTransactionsService } from '../../services';
import { ManualTransactionEntity } from '../../models';
import { AlertService } from '../../framework/services';
import {
DataTableModule,
CalendarModule,
ToolbarModule,
TabViewModule
} from 'primeng/primeng';
describe('ManualTransactionsComponent', () => {
let component: ManualTransactionsComponent;
let fixture: ComponentFixture<ManualTransactionsComponent>;
let mockBackend: MockBackend;
let testBed: TestBed;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
HttpModule,
FormsModule,
CalendarModule
],
declarations: [ ManualTransactionsComponent ],
providers: [
{ provide: XHRBackend, useClass: MockBackend },
ManualTransactionsService,
{ provide: AlertService, useValue: {} }
],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
}).compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ManualTransactionsComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});