NX单仓库Angular环境下测试无Ngxs依赖组件报ɵmod属性缺失错误
问题:NX单仓库Angular项目测试报错"NgxsFeatureModule does not have a module def (ɵmod property)"
项目依赖版本
"@nrwl/angular": "15.2.4", "@angular/core": "~15.0.0", "@ngxs/store": "^3.7.6", "jest": "28.1.1", "@nrwl/jest": "15.2.4",
测试组件与测试代码
需测试的OperationPlanTaskFormComponent组件与Ngxs无任何关联,对应的测试文件代码如下:
describe('OperationPlanTaskFormComponent', () => { let component: OperationPlanTaskFormComponent; let fixture: ComponentFixture<OperationPlanTaskFormComponent>; beforeEach(async () => { await TestBed.configureTestingModule({ declarations: [OperationPlanTaskFormComponent], imports: [ ButtonModule, ConfirmDialogModule, ] }).compileComponents(); fixture = TestBed.createComponent(OperationPlanTaskFormComponent); component = fixture.componentInstance; fixture.detectChanges(); }); it('should create', () => { expect(component).toBeTruthy(); }); });
报错信息
运行测试文件时,出现错误提示:
"NgxsFeatureModule does not have a module def (ɵmod property)"
已尝试的解决方法
- 删除
node_modules文件夹并执行npm ci重新安装 - 删除
.angular缓存目录 - 执行
nx reset命令
以上方法均未解决问题,确认测试组件无Ngxs相关依赖,求可行解决方案。
内容的提问来源于stack exchange,提问作者Hadi
相关产品推荐
相关产品推荐

