You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.26 20:10:13