首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >测试时无法导入ng-zorro-antd模块。

测试时无法导入ng-zorro-antd模块。
EN

Stack Overflow用户
提问于 2022-03-28 09:42:50
回答 1查看 376关注 0票数 0

我不能在单元测试中从ng-zorro- any导入模块,但是我可以构建这个应用程序,没有任何错误。我使用的是角12.2.4和ng-zorro- and 12.1.1

我得到以下错误:

代码语言:javascript
复制
Error: Unexpected value 'NzButtonModule' imported by the module 'DynamicTestModule'. Please add an @NgModule annotation.

这里是我的规范文件:

代码语言:javascript
复制
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import {NzButtonModule} from 'ng-zorro-antd/button';

import { AntViewComponent } from './ant-view.component';

describe('AntViewComponent', () => {
  let component: AntViewComponent;
  let fixture: ComponentFixture<AntViewComponent>;

  beforeEach(
    waitForAsync(() => {
      TestBed.configureTestingModule({
        imports: [NzButtonModule],
        declarations: [AntViewComponent],
        schemas: [NO_ERRORS_SCHEMA]
      }).compileComponents();
    })
  );

  beforeEach(() => {
    fixture = TestBed.createComponent(AntViewComponent);
    component = fixture.componentInstance;
    fixture.detectChanges();
  });

  it('should create', () => {
    expect(component).toBeDefined();
  });
});

我做错什么了吗?这很奇怪,因为我可以很好地运行应用程序,从ng-zorro- and导入和使用模块,但是我不能在单元测试中运行。

EN

回答 1

Stack Overflow用户

发布于 2022-04-12 16:08:23

使用较早版本的ng-zorro- an解决了这个问题(12.0.1)。

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

https://stackoverflow.com/questions/71645365

复制
相关文章

相似问题

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