[英]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.当我运行测试,在本地为我角12个项目,我得到这个错误,在所有的.spec文件
ngbTooltip
用我用CUSTOM_ELEMENT_SCHEMA
,这是不可能的跟踪发生错误的行。 It is noteworthy that the error is absent with ng serve
, but appears with ng test
.值得注意的是,该错误在
ng serve
不存在,但在ng test
出现。 Tell me how to solve this problem, I tried using CUSTOM_ELEMENT_SCHEMA
in the application module, it did not help.告诉我如何解决这个问题,我尝试在应用程序模块中使用
CUSTOM_ELEMENT_SCHEMA
,但没有帮助。
Try adding NgbModule
to imports
array in TestBed.configureTestingModule({
.尝试添加
NgbModule
到imports
在阵列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.如果你不想导入
NgbModule
或者它在你的单元测试中导致问题,你可以模拟指令并提供模拟。
@Directive({
selector: '[ngbTooltip]'
})
class MockNgbTooltip {}
...
TestBed.configureTestingModule({
// add the mock to the declarations array
declarations: [MockNgbTooltip],
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.