Issue with Running Tests using Angular CLI

UI Components for Angular
Post Reply
Posts: 13
Joined: 30 Nov 2016, 00:33

25 Jan 2017, 04:59

I am running the latest version 2.0.0-rc.1 plus this also happened with 1.4.0

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 {
} from 'primeng/primeng';

describe('ManualTransactionsComponent', () => {
  let component: ManualTransactionsComponent;
  let fixture: ComponentFixture<ManualTransactionsComponent>;
  let mockBackend: MockBackend;
  let testBed: TestBed;

  beforeEach(async(() => {
      imports: [ 
      declarations: [ ManualTransactionsComponent ],
      providers: [
        { provide: XHRBackend, useClass: MockBackend },
        { provide: AlertService, useValue: {} } 

  beforeEach(() => {
    fixture = TestBed.createComponent(ManualTransactionsComponent);
    component = fixture.componentInstance;

  it('should create', () => {
Am I declaring the CUSTOM_ELEMENTS_SCHEMA wrong? Can someone tell me what I am missing?

Posts: 13
Joined: 30 Nov 2016, 00:33

25 Jan 2017, 21:58

I'm not sure if this is the right fix but I was able to eliminate the error by also adding schemas: [CUSTOM_ELEMENTS_SCHEMA] to my app.component.spec.ts file

Posts: 13
Joined: 30 Nov 2016, 00:33

26 Jan 2017, 17:48

Well, after further review, it looks like user error. I had neglected to add my other PrimeNG modules to the imports property of TestBed.configureTestingModule.

Post Reply

Return to “PrimeNG”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 27 guests