ng-mocks: ng-mocks is not in JIT mode and cannot resolve declarations
ng-mocks is not in JIT mode and cannot resolve declarations
I’m getting this error after did some refactoring on moving some code to external libraries. What does this error mean and how to fix it?
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 33 (13 by maintainers)
Commits related to this issue
- fix(#354): better error instead of is not in JIT mode — committed to help-me-mom/ng-mocks by satanTime 3 years ago
- Upgrade ng-mocks to fix mocking issues ( See https://github.com/help-me-mom/ng-mocks/issues/354) — committed to MauroDataMapper/mdm-ui by jamesrwelch 2 years ago
- Upgrade ng-mocks to fix mocking issues ( See https://github.com/help-me-mom/ng-mocks/issues/354) — committed to MauroDataMapper/mdm-ui by jamesrwelch 2 years ago
- Upgrade ng-mocks to fix mocking issues ( See https://github.com/help-me-mom/ng-mocks/issues/354) — committed to MauroDataMapper/mdm-ui by jamesrwelch 2 years ago
I have experienced the same issue. For testing I created a new angular 13 project, installed ng-mocks, changed the generated app-component test to use ng-mocks (MockBuilder and MockRender) and it has the same issue.
I have this error after upgrading to Angular 13. I have the latest version of ng-mocks installed (I even deleted node_modules) and re-installed. “ng-mocks”: “^12.5.0”, I focused one test that IS NOT USING ng-mocks and I STILL get this error?
@satanTime can you reopen this please? any updates? Same error here with Angular 13.
I had this error because I’ve accidentally added a pipe as a MockComponents argument
If you are here because of the error in your tests:
ng-mocksto the latest, it works with all Angular versionsjest.mock('lib/path')?ng-mocks@12.3.1should have a solution for it, please drop a comment here if it doesn’t work for youI hope it helps. Thanks in advance!
Hi all, this is the issue to follow: https://github.com/ike18t/ng-mocks/issues/1427
Hi @rbirkgit,
Thanks for the info. I’ll comment in a different issue. This one is correct. For angular 13, you need ng-mocks 13.
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 modeMy 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:
Good lucky, hope this help someone else.
Same issue here. We do use @ngneat/spectator though but I did a rewrite on one Test to only use TestBed and got the same result. Since @vorant94 already shared a repo that reproduces the error, I’ll not try to extract ours (though I could if that would help you further in any way).
@satanTime Actually I got this error because the component I tried to mock was imported from a wrong directory. So probably this error also falls on attempts to mock undefined.