Skip to content

Commit aff34e0

Browse files
committed
fix(Test): Fix UTs coverage with Istanbul configuration
1 parent 91a40c5 commit aff34e0

File tree

2 files changed

+26
-40
lines changed

2 files changed

+26
-40
lines changed

packages/cli/template/karma.conf.js

Lines changed: 22 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
var webpackConf = require('./webpack.config.js');
2-
module.exports = function (config) {
1+
var webpackConf = require('./webpack.config.js')
2+
module.exports = function(config) {
33
config.set({
4-
basePath:'',
4+
basePath: '',
55
frameworks: ['jasmine'],
66
files: [{ pattern: './tests/unit/spec-bundle.js', watched: false }],
7-
preprocessors: { './tests/unit/spec-bundle.js': ['coverage', 'webpack', 'sourcemap'] },
7+
preprocessors: { './tests/unit/spec-bundle.js': ['webpack', 'sourcemap'] },
88
webpack: {
99
module: webpackConf.module,
1010
resolve: webpackConf.resolve
@@ -13,31 +13,22 @@ module.exports = function (config) {
1313
noInfo: true,
1414
stats: 'errors-only'
1515
},
16-
reporters: ['kjhtml', 'spec', 'coverage'],
17-
// optionally, configure the reporter
18-
coverageReporter: {
19-
// specify a common output directory
20-
dir: './tests/build/reports/coverage',
21-
reporters: [
22-
// reporters not supporting the `file` property
23-
{ type: 'html', subdir: 'report-html' },
24-
{ type: 'lcov', subdir: 'report-lcov' },
25-
// reporters supporting the `file` property, use `subdir` to directly
26-
// output them in the `dir` directory
27-
{ type: 'cobertura', subdir: '.', file: 'cobertura.txt' },
28-
{ type: 'lcovonly', subdir: '.', file: 'report-lcovonly.txt' },
29-
{ type: 'teamcity', subdir: '.', file: 'teamcity.txt' },
30-
{ type: 'text', subdir: '.', file: 'text.txt' },
31-
{ type: 'text-summary', subdir: '.', file: 'text-summary.txt' },
32-
]
33-
},
16+
reporters: ['spec', 'coverage-istanbul'],
3417
specReporter: {
35-
maxLogLines: 5, // limit number of lines logged per test
36-
suppressErrorSummary: true, // do not print error summary
37-
suppressFailed: false, // do not print information about failed tests
38-
suppressPassed: false, // do not print information about passed tests
39-
suppressSkipped: true, // do not print information about skipped tests
40-
showSpecTiming: false // print the time elapsed for each spec
18+
maxLogLines: 5, // limit number of lines logged per test
19+
suppressErrorSummary: true, // do not print error summary
20+
suppressFailed: false, // do not print information about failed tests
21+
suppressPassed: false, // do not print information about passed tests
22+
suppressSkipped: true, // do not print information about skipped tests
23+
showSpecTiming: false // print the time elapsed for each spec
24+
},
25+
coverageIstanbulReporter: {
26+
reports: ['html', 'lcov', 'text-summary'],
27+
dir: './tests/coverage', // coverage results needs to be saved under coverage/
28+
fixWebpackSourcePaths: true,
29+
query: {
30+
esModules: true
31+
}
4132
},
4233
customLaunchers: {
4334
Chrome_travis_ci: {
@@ -52,10 +43,9 @@ module.exports = function (config) {
5243
browsers: ['Chrome'],
5344
singleRun: true,
5445
concurrency: Infinity
55-
});
56-
46+
})
5747

5848
if (process.env.TRAVIS) {
59-
config.browsers = ['Chrome_travis_ci'];
49+
config.browsers = ['Chrome_travis_ci']
6050
}
61-
};
51+
}

packages/cli/template/package.json

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,14 @@
2222
"css-loader": "^0.28.4",
2323
"ejs-loader": "^0.3.0",
2424
"eslint": "^4.2.0",
25-
"expose-loader": "^0.7.3",
2625
"html-loader": "^0.4.5",
2726
"html-webpack-plugin": "^2.29.0",
27+
"istanbul-instrumenter-loader": "^3.0.0",
2828
"jasmine": "^2.6.0",
2929
"jasmine-core": "^2.6.4",
3030
"karma": "^1.7.0",
31-
"karma-babel-preprocessor": "^6.0.1",
3231
"karma-chrome-launcher": "^2.2.0",
33-
"karma-coverage": "^1.1.1",
34-
"karma-firefox-launcher": "^1.0.1",
3532
"karma-jasmine": "^1.1.0",
36-
"karma-jasmine-html-reporter": "^0.2.2",
37-
"karma-phantomjs-launcher": "^1.0.4",
3833
"karma-sourcemap-loader": "^0.3.7",
3934
"karma-spec-reporter": "0.0.31",
4035
"karma-webpack": "^2.0.4",
@@ -43,10 +38,11 @@
4338
"style-loader": "^0.18.2",
4439
"tslint": "^5.5.0",
4540
"tslint-loader": "^3.5.3",
46-
"typescript": "^2.4.1",
41+
"typescript": "^2.7.1",
4742
"webpack": "^3.3.0",
4843
"webpack-dashboard": "^0.4.0",
49-
"webpack-dev-server": "2.5.1"
44+
"webpack-dev-server": "2.5.1",
45+
"karma-coverage-istanbul-reporter": "^1.4.1"
5046
},
5147
"dependencies": {
5248
"lodash": "^4.17.4"

0 commit comments

Comments
 (0)