1
votes

I have used PrimeNG p-dialog. It works OK when running the program. However, when I tried to test the program using "ng Test" (Karma). I got this error:

Failed: Template parse errors: Can't bind to 'visible' since it isn't a known property of 'p-dialog'. 1. If 'p-dialog' is an Angular component and it has 'visible' input, then verify that it is part of this module. 2. If 'p-dialog' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. 3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("....

What seems to be reason why?

1

1 Answers

1
votes

You have to tell Angular you are working with custom/3rd party components. To do so, add this:

schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA]

to your beforeEach part of component test. Full beforeEach will look like this:

beforeEach(async(() => {
   TestBed.configureTestingModule({
     declarations: [YourComponentDeclaration],
     schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA]
   }).compileComponents();

   fixture = TestBed.createComponent(YourComponentDeclaration);
   component = fixture.componentInstance;
   fixture.detectChanges();
}));