首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >NG0304:“ng-mocks ButtonComponent”不是一个已知的元素

NG0304:“ng-mocks ButtonComponent”不是一个已知的元素
EN

Stack Overflow用户
提问于 2022-09-27 08:28:08
回答 1查看 75关注 0票数 1

我用的是有棱角的纳克模型。在运行测试用例时,我会遇到以下错误

console.error NG0304:‘ng-mocks ButtonComponent’不是一个已知的元素(在'i‘组件>模板中使用):

如果‘ng-

  • -ButtonComponent’是一个角组件,则验证它是声明该组件的@NgModule的一部分>;

  • 如果‘ng-

-ButtonComponent’是一个Web组件,则添加'CUSTOM_ELEMENTS_SCHEMA‘到>该组件的'@NgModule.schemas’,以抑制此消息。

代码语言:javascript
复制
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();
  });
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-10-10 07:29:52

这一问题已被报道并得到解决:https://github.com/help-me-mom/ng-mocks/issues/3515

请将ng-mock升级到最新版本。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73864509

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档