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
I got this error after upgrading my project from angular @12.2.16 to @13.2.4. However I was getting the exact same error:
MyComponent declaration has been passed into ng-mocks without Angular decorators. Therefore, it cannot be properly handled. Highly likely, jest.mock() has been used on its file, or ng-mocks is not in JIT mode
My project versions:
After trying a lot of possible solutions a could solve my problem just reinstalling ng-mocks with the latest version and everything got fixed up and all tests were passing successfully.
Update ng-mocks to the latest version with:
$ npm uninstall ng-mocks
$ npm install ng-mocks@latest --save-dev
Good lucky, hope this help someone else.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With