Issue
I am using ng-mocks this way -
import { MockDirective, MockComponent, ngMocks } from 'ng-mocks';
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [
MockComponent(ComponentName),
],
schemas: [ NO_ERRORS_SCHEMA ]
})
.compileComponents();
}));
I am seeing the below error -
Failed: ng-mocks is not in JIT mode and cannot resolve declarations
Solution
this issue has been fixed recently. In your case, it means that ComponentName
has been imported wrongly, or has a wrong type.
MockComponent
accepts classes. Therefore, it should be used like:
import { MockDirective, MockComponent, ngMocks } from 'ng-mocks';
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [
MockComponent(ComponentClass), // <- its class instead of its name.
],
}).compileComponents();
}));
Answered By - satanTime
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.