When I run any test I get the error below. I added @Directive() and @Injectable() decorators wherever they were needed and I changed the order in constructors of the derived classes to fit the abstract base classes.
My project runs great with npm serve and with npm run storybook. only npm test faults.
I can't even find out which class is at fault from the stacktrace :\
Steps to reproduce the behavior:
No error
# content of error stacktrace :
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.
at ɵɵinvalidFactoryDep (../packages/core/src/di/injector_compatibility.ts:140:9)
at NodeInjectorFactory.EditableTextComponent_Factory [as factory] (ng:\EditableTextComponent\ɵfac.js:5:49)
at getNodeInjectable (../packages/core/src/render3/di.ts:548:38)
at instantiateRootComponent (../packages/core/src/render3/instructions/shared.ts:1131:21)
at createRootComponent (../packages/core/src/render3/component.ts:219:21)
at ComponentFactory.Object.<anonymous>.ComponentFactory.create (../packages/core/src/render3/component_ref.ts:223:19)
at initComponent (../../packages/core/testing/src/r3_test_bed.ts:355:28)
at ZoneDelegate.Object.<anonymous>.ZoneDelegate.invoke (node_modules/zone.js/dist/zone.js:386:30)
at ProxyZoneSpec.Object.<anonymous>.ProxyZoneSpec.onInvoke (node_modules/zone.js/dist/proxy.js:117:43)
at ZoneDelegate.Object.<anonymous>.ZoneDelegate.invoke (node_modules/zone.js/dist/zone.js:385:36)
at Object.onInvoke (../packages/core/src/zone/ng_zone.ts:308:29)
at ZoneDelegate.Object.<anonymous>.ZoneDelegate.invoke (node_modules/zone.js/dist/zone.js:385:36)
at Zone.Object.<anonymous>.Zone.run (node_modules/zone.js/dist/zone.js:143:47)
at NgZone.Object.<anonymous>.NgZone.run (../packages/core/src/zone/ng_zone.ts:180:50)
at TestBedRender3.Object.<anonymous>.TestBedRender3.createComponent (../../packages/core/testing/src/r3_test_bed.ts:358:37)
at Function.Object.<anonymous>.TestBedRender3.createComponent (../../packages/core/testing/src/r3_test_bed.ts:183:33)
at beforeEach (app/new_environment/shared/grid/custom-components/editable-text/editable-text.component.spec.ts:33:23)
at ZoneDelegate.Object.<anonymous>.ZoneDelegate.invoke (node_modules/zone.js/dist/zone.js:386:30)
at ProxyZoneSpec.Object.<anonymous>.ProxyZoneSpec.onInvoke (node_modules/zone.js/dist/proxy.js:117:43)
at ZoneDelegate.Object.<anonymous>.ZoneDelegate.invoke (node_modules/zone.js/dist/zone.js:385:36)
at Zone.Object.<anonymous>.Zone.run (node_modules/zone.js/dist/zone.js:143:47)
System:
OS: Windows 10
Npm packages:
jest: 25.5.4
jest-preset-angular: 8.1.3
typescript: 3.8.3
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI: 9.1.12
Node: 10.22.0
OS: win32 x64
Angular: 9.1.12
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, localize, platform-browser
... platform-browser-dynamic, router, upgrade
Ivy Workspace: Yes
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.901.12
@angular-devkit/build-angular 0.901.12
@angular-devkit/build-optimizer 0.901.12
@angular-devkit/build-webpack 0.901.12
@angular-devkit/core 9.1.12
@angular-devkit/schematics 9.1.12
@angular/cdk 9.2.4
@angular/material 9.2.4
@ngtools/webpack 9.1.12
@schematics/angular 9.1.12
@schematics/update 0.901.12
rxjs 6.6.0
typescript 3.8.3
webpack 4.44.0
Hi, it would be great if you can provide us your minimal repo. We are working on ivy compatibility so we really appreciate to have many examples to test with.
@ahnpnl I don't even know which component is at fault. I get this error for 95% of my UTs.
Can you please tell me how to properly debug it, so that I'll be able to reproduce it in a plankr?
the stacktrace points to editable-text.component.spec.ts. TestBedRenderer3 is an instance of TestBed which is created when Angular detects that Ivy mode is enabled (I assume you already ran ngcc before running tests). I think something happens in the test file editable-text.component.spec.ts. Would you please check that ?
@ahnpnl spec file looks ok
do you use class inheritance in your code ?
@ahnpnl solved it!!
we need emitDecoratorMetadata: true for jest
nice ! At least it's not another Ivy compatibility issue 😃
@ronyf so this is solved for now, no? Can you close the issue?
Most helpful comment
@ahnpnl solved it!!
we need
emitDecoratorMetadata: truefor jest