javascript - NG0303: Can't bind to 'ngbTooltip' since it isn't a known property of 'butt

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

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

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

Share Improve this question edited Oct 13, 2021 at 22:15 Alex Kim asked Oct 13, 2021 at 19:05 Alex KimAlex Kim 331 silver badge4 bronze badges 2
  • Just add the CUSTOM_ELEMENT_SCHEMA in the related module.ts file – Aman Gojariya Commented Oct 13, 2021 at 20:08
  • It doesn't work, I already said it – Alex Kim Commented Oct 13, 2021 at 20:15
Add a ment  | 

1 Answer 1

Reset to default 5

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],

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744638828a4585311.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信