Company logo
  • Jobs
  • Bootcamp
  • About Us
  • For professionals
    • Home
    • Jobs
    • Courses
    • Questions
    • Teachers
    • Bootcamp
  • For business
    • Home
    • Our process
    • Plans
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Calculator

0

191
Views
NG0303: Can't bind to 'ngbTooltip' since it isn't a known property of 'button'

ERROR: 'NG0303: Can't bind to 'ngbTooltip' since it isn't a known property of 'button'.'

When I run tests locally for my Angular 12 project, I get this error, in all .spec files where ngbTooltip is used I use CUSTOM_ELEMENT_SCHEMA, it is impossible to track the line on which the error occurs. It is noteworthy that the error is absent with ng serve, but appears with ng test. Tell me how to solve this problem, I tried using CUSTOM_ELEMENT_SCHEMA in the application module, it did not help.

Console output Console output 2

7 months ago · Juan Pablo Isaza
1 answers
Answer question

0

Try adding NgbModule to imports array in TestBed.configureTestingModule({.

TestBed.configureTestingModule({
  imports: [NgbModule],
...

If you don't want to import NgbModule or it causes issues in your unit tests, you can mock the directive and provide the mock.

@Directive({
  selector: '[ngbTooltip]'
})
class MockNgbTooltip {}
...
TestBed.configureTestingModule({
  // add the mock to the declarations array
  declarations: [MockNgbTooltip],
7 months ago · Juan Pablo Isaza Report
Answer question
Find remote jobs