x)
- [ ] new
- [ ] build
- [ ] serve
- [x] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc
Yes, the previous version in which this bug was not present was: 7.2
Running with code coverage enabled breaks constructor inheritance.
Inserting a constructor in the ValidationDirective also fixes the error.
https://github.com/CSchulz/angular-code-coverage-breaks-constructor-inheritance
Run npm test results into
TypeError: Cannot read property 'get' of undefined
Run npm test -- --codeCoverage false succeeds.
For some reason the dependencies of the ValidationDirective don't get resolved correctly.
You can see in the createClass method that the deps of ValidationDirective are empty.
Angular CLI: 8.0.3
Node: 10.15.3
OS: darwin x64
Angular: 8.0.2
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Package Version
------------------------------------------------------------
@angular-devkit/architect 0.800.3
@angular-devkit/build-angular 0.800.3
@angular-devkit/build-ng-packagr 0.800.3
@angular-devkit/build-optimizer 0.800.3
@angular-devkit/build-webpack 0.800.3
@angular-devkit/core 8.0.3
@angular-devkit/schematics 8.0.3
@angular/cli 8.0.3
@ngtools/json-schema 1.1.0
@ngtools/webpack 8.0.3
@schematics/angular 8.0.3
@schematics/update 0.800.3
ng-packagr 5.3.0
rxjs 6.4.0
typescript 3.4.5
webpack 4.30.0
Hi, as a workaround you can change the target to es5 in your tsconfig.spec.json.
Example:
"compilerOptions": {
"target": "es5",
"types": [
"jasmine",
"node"
]
}
This issue is still present in 8.2.2 ...
I have a component that inherits a base class and the base class constructor does not receive injected services (they are all undefined) when using code coverage.
I'm on 8.2.13 and just ran into this problem.
Hi, as a workaround you can change the
targettoes5in yourtsconfig.spec.json.Example:
"compilerOptions": { "target": "es5", "types": [ "jasmine", "node" ] }
As a workaround works, but is there any news on this? I'm having this problem with jest and its coverage too. If you need a repro with jest I can create one to help :+1:
Hi, as a workaround you can change the
targettoes5in yourtsconfig.spec.json.Example:
"compilerOptions": { "target": "es5", "types": [ "jasmine", "node" ] }
its not working on my side
in our case, changing the compiler target to es5 was fixing the problem. It only fails for us if a direct property assignment public validation = true; is present in the child class inheriting from a parent class with a non-empty constructor definition. This all fits with the reproduction in the original post.
Enabling code coverage should never change the test results... this is a big no-go and it loses confidence in the tech stack used for production!
Most helpful comment
Hi, as a workaround you can change the
targettoes5in yourtsconfig.spec.json.Example: