我不能在单元测试中从ng-zorro- any导入模块,但是我可以构建这个应用程序,没有任何错误。我使用的是角12.2.4和ng-zorro- and 12.1.1
我得到以下错误:
Error: Unexpected value 'NzButtonModule' imported by the module 'DynamicTestModule'. Please add an @NgModule annotation.这里是我的规范文件:
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导入和使用模块,但是我不能在单元测试中运行。
发布于 2022-04-12 16:08:23
使用较早版本的ng-zorro- an解决了这个问题(12.0.1)。
https://stackoverflow.com/questions/71645365
复制相似问题