我用的是有棱角的纳克模型。在运行测试用例时,我会遇到以下错误
console.error NG0304:‘ng-mocks ButtonComponent’不是一个已知的元素(在'i‘组件>模板中使用):
如果‘ng-
-ButtonComponent’是一个Web组件,则添加'CUSTOM_ELEMENTS_SCHEMA‘到>该组件的'@NgModule.schemas’,以抑制此消息。
describe('ButtonComponent', () => {
beforeEach(() => {
return MockBuilder(ButtonComponent, ButtonModule);
});
it('should create', () => {
const fixture = MockRender(ButtonComponent);
expect(fixture.point.componentInstance).toBeDefined();
});
it('should have icon as input decorator for the button component', () => {
const fixture = MockRender(ButtonComponent);
expect(fixture.point.componentInstance.icon).toBeDefined();
});发布于 2022-10-10 07:29:52
这一问题已被报道并得到解决:https://github.com/help-me-mom/ng-mocks/issues/3515
请将ng-mock升级到最新版本。
https://stackoverflow.com/questions/73864509
复制相似问题