Closed Nielsb85 closed 3 years ago
Did you run ngcc
before running tests?
The stacktrace indicates that Angular uses VE compiler instead of Ivy which throws the error.
You must always run ngcc
before running tests to make sure everything works like Karma + Jasmine.
Did you run
ngcc
before running tests? The stacktrace indicates that Angular uses VE compiler instead of Ivy which throws the error.You must always run
ngcc
before running tests to make sure everything works like Karma + Jasmine.
I also tried adding require('jest-preset-angular/ngcc-jest-processor'); in the jest config but it gave the same result
Maybe try with yarn ngcc
?
that seems to solve the issue on the demo repo I created. What is different that adding the require('jest-preset-angular/ngcc-jest-processor'); i which also seems to be running the ngcc command?
require('jest-preset-angular/ngcc-jest-processor')
is a custom utility script https://github.com/thymikee/jest-preset-angular/blob/master/src/utils/ngcc-jest-processor.ts which invokes ngcc
under the hood. It works normally with Angular 11 but I don't know about Angular 12. So far my project with Angular 11 doesn't have issues with that script.
for the example project I created it seemed to work.
For the actual project it is still failing.
This constructor is not compatible with Angular Dependency Injection because its dependency at index 0 of the parameter list is invalid.
This can happen if the dependency type is a primitive like a string or if an ancestor of this class is missing an Angular decorator.
Please check that 1) the type for the parameter at index 0 is correct and 2) the correct Angular decorators are defined for this class and its ancestors.
For the actual project it is still failing.
This constructor is not compatible with Angular Dependency Injection because its dependency at index 0 of the parameter list is invalid. This can happen if the dependency type is a primitive like a string or if an ancestor of this class is missing an Angular decorator. Please check that 1) the type for the parameter at index 0 is correct and 2) the correct Angular decorators are defined for this class and its ancestors.
This error is also related to ngcc
.
running ngcc --tsconfig "./tsconfig.spec.json" && npx jest fixes the problem. Thanks @ahnpnl
update: it eventually started failing again without being able to fix it. ngcc command seems not to be the solution.
@ahnpnl https://github.com/kamilkisiela/apollo-angular/issues/1703 Still seems to be an issue. Not just for me.
Could be related to https://github.com/thymikee/jest-preset-angular/issues/963 if you try to import namespaces.
This is definitely a duplicate of https://github.com/thymikee/jest-preset-angular/issues/963
🐛 Bug Report
I migrated jest and jest-preset-angular to the latest version (jest 27 and jest-preset-angular 9.0.4)
When I now run unit tests, it will fail on the generated gql not able to resolve all parameters.
for example
will now fail on
Error: Can't resolve all parameters for ExampleGQL: (?).
In previous version of jest-preset-angular and jest 26.x this all worked fine.
To Reproduce
setup testbed and add a generated GQL to the providers list I created a repo where I simulated the situation (very light) but the error is the same
Expected behavior
I expect the test not to fail with Can't resolve all parameters for ExampleGql: (?) with "emitDecoratorMetadata": true Just like on the old version of jest and jest-preset-angular
Link to repo (highly encouraged)
https://github.com/Nielsb85/jest-preset-angular
Error log:
● example › should not fail on missing deps
envinfo