Running NX mono repo and Angular
"@nrwl/angular": "15.2.4",
"@angular/core": "~15.0.0",
"@ngxs/store": "^3.7.6",
"jest": "28.1.1",
"@nrwl/jest": "15.2.4",
The exciting part is, the component I am testing has nothing to do with Ngxs and spec file is simple.
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();
});
});
So, when I run test file for this it shows error "NgxsFeatureModule does not have a module def (ɵmod property)"
Tried deleting node_modules
folder and clean install with npm ci
. Tried delete .angular
and including the cache. Even tried nx reset
. No luck. I am sure that the component I am trying to test doesn't have any dependency which can cause this issue.
I would really appreciate if anyone has any idea about what is actually going on.
I found a workaround for the issue. Update package.json
and add -
"postinstall-ng": "ngcc",
in scripts. Then run it
npm run postinstall-ng
What it does is
So, it basically changes the legacy library compatible with runtime IVY.
The ngcc (Angular Compatibility Compiler) is a tool used to compile Angular libraries that have been published in the legacy format, which is not compatible with the Angular Ivy runtime, to a format that is compatible with Ivy.
ref https://iq.js.org/questions/angular/what-is-ngcc
Finally, my two cents is - ngxs
library got some issues. They need to provide Ivy distribution.