angular-cli: Test-coverage says that coverage is not 100%, but it truly is!
Bug Report or Feature Request (mark with an x
)
- [x] bug report -> please search issues before submitting
- [ ] feature request
Versions.
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
@angular/cli: 1.0.0
node: 6.9.5
os: darwin x64
@angular/animations: 4.0.1
@angular/common: 4.0.1
@angular/compiler: 4.0.1
@angular/core: 4.0.1
@angular/forms: 4.0.1
@angular/http: 4.0.1
@angular/platform-browser: 4.0.1
@angular/platform-browser-dynamic: 4.0.1
@angular/platform-server: 4.0.1
@angular/router: 4.0.1
@angular/cli: 1.0.0
@angular/compiler-cli: 4.0.1
Repro steps.
Upgrade your 100% tested angular 2.4.8 app to 4.0.1, along with Angular CLI 1.0.0
The log given by the failure.
There’s no actual failure (stacktrace thown), but the behaviour of the text-coverage is wrong. I’m hitting every line, statement, branch and function of the code, but coverage does not “cover” constructor signature.
Desired functionality.
The test coverage should be 100%, and was until I upgraded from Angular 2.4.8 (CLI 1.0.0 RC.0) to Angular 4.01 (CLI 1.0.0).
Before
After
Coverage error (example)
Mention any other details that might be useful.
My karma.conf.js file looks like:
// Karma configuration file, see link for more information
// https://karma-runner.github.io/0.13/config/configuration-file.html
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular/cli'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular/cli/plugins/karma'),
require('karma-spec-reporter'),
require('karma-appveyor-reporter')
],
files: [
{pattern: './src/test.ts', watched: false}
],
preprocessors: {
'./src/test.ts': ['@angular/cli']
},
mime: {
'text/x-typescript': ['ts', 'tsx']
},
coverageIstanbulReporter: {
reports: [ 'html', 'lcovonly', 'text' ],
fixWebpackSourcePaths: true
},
angularCli: {
environment: 'dev'
},
reporters: config.angularCli && config.angularCli.codeCoverage
? ['spec', 'coverage-istanbul', 'appveyor']
: ['spec', 'appveyor'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false
});
};
I’m unfortunately not permitted to share the code-base, since it’s a closed source, propriatary product I’m working on. I can however provide you with various configuration files. So, do not refrain from asking for these.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 37
- Comments: 16 (3 by maintainers)
@rg1220
Well, not exactly… since we’re not only experiencing it in constructors, but also in class parameters.
Going to close this one as duplicate of #5526, they are the same and the other one has a lot more info on the problem.
fix it please 😃
Same issue but I’m looking into the matter. Will start looking at what exactly the karma plugin is doing.
Same problem
We have the same problem on this opensource project: https://gitlab.com/linagora/petals-cockpit (at commit 78c6928e4f78279a2a105fe357981a6cff88da21).