Skip to content

Commit

Permalink
fix(Test): Fix UTs coverage with Istanbul configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
emyann committed Feb 10, 2018
1 parent 91a40c5 commit aff34e0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 40 deletions.
54 changes: 22 additions & 32 deletions packages/cli/template/karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
var webpackConf = require('./webpack.config.js');
module.exports = function (config) {
var webpackConf = require('./webpack.config.js')
module.exports = function(config) {
config.set({
basePath:'',
basePath: '',
frameworks: ['jasmine'],
files: [{ pattern: './tests/unit/spec-bundle.js', watched: false }],
preprocessors: { './tests/unit/spec-bundle.js': ['coverage', 'webpack', 'sourcemap'] },
preprocessors: { './tests/unit/spec-bundle.js': ['webpack', 'sourcemap'] },
webpack: {
module: webpackConf.module,
resolve: webpackConf.resolve
Expand All @@ -13,31 +13,22 @@ module.exports = function (config) {
noInfo: true,
stats: 'errors-only'
},
reporters: ['kjhtml', 'spec', 'coverage'],
// optionally, configure the reporter
coverageReporter: {
// specify a common output directory
dir: './tests/build/reports/coverage',
reporters: [
// reporters not supporting the `file` property
{ type: 'html', subdir: 'report-html' },
{ type: 'lcov', subdir: 'report-lcov' },
// reporters supporting the `file` property, use `subdir` to directly
// output them in the `dir` directory
{ type: 'cobertura', subdir: '.', file: 'cobertura.txt' },
{ type: 'lcovonly', subdir: '.', file: 'report-lcovonly.txt' },
{ type: 'teamcity', subdir: '.', file: 'teamcity.txt' },
{ type: 'text', subdir: '.', file: 'text.txt' },
{ type: 'text-summary', subdir: '.', file: 'text-summary.txt' },
]
},
reporters: ['spec', 'coverage-istanbul'],
specReporter: {
maxLogLines: 5, // limit number of lines logged per test
suppressErrorSummary: true, // do not print error summary
suppressFailed: false, // do not print information about failed tests
suppressPassed: false, // do not print information about passed tests
suppressSkipped: true, // do not print information about skipped tests
showSpecTiming: false // print the time elapsed for each spec
maxLogLines: 5, // limit number of lines logged per test
suppressErrorSummary: true, // do not print error summary
suppressFailed: false, // do not print information about failed tests
suppressPassed: false, // do not print information about passed tests
suppressSkipped: true, // do not print information about skipped tests
showSpecTiming: false // print the time elapsed for each spec
},
coverageIstanbulReporter: {
reports: ['html', 'lcov', 'text-summary'],
dir: './tests/coverage', // coverage results needs to be saved under coverage/
fixWebpackSourcePaths: true,
query: {
esModules: true
}
},
customLaunchers: {
Chrome_travis_ci: {
Expand All @@ -52,10 +43,9 @@ module.exports = function (config) {
browsers: ['Chrome'],
singleRun: true,
concurrency: Infinity
});

})

if (process.env.TRAVIS) {
config.browsers = ['Chrome_travis_ci'];
config.browsers = ['Chrome_travis_ci']
}
};
}
12 changes: 4 additions & 8 deletions packages/cli/template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,14 @@
"css-loader": "^0.28.4",
"ejs-loader": "^0.3.0",
"eslint": "^4.2.0",
"expose-loader": "^0.7.3",
"html-loader": "^0.4.5",
"html-webpack-plugin": "^2.29.0",
"istanbul-instrumenter-loader": "^3.0.0",
"jasmine": "^2.6.0",
"jasmine-core": "^2.6.4",
"karma": "^1.7.0",
"karma-babel-preprocessor": "^6.0.1",
"karma-chrome-launcher": "^2.2.0",
"karma-coverage": "^1.1.1",
"karma-firefox-launcher": "^1.0.1",
"karma-jasmine": "^1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"karma-phantomjs-launcher": "^1.0.4",
"karma-sourcemap-loader": "^0.3.7",
"karma-spec-reporter": "0.0.31",
"karma-webpack": "^2.0.4",
Expand All @@ -43,10 +38,11 @@
"style-loader": "^0.18.2",
"tslint": "^5.5.0",
"tslint-loader": "^3.5.3",
"typescript": "^2.4.1",
"typescript": "^2.7.1",
"webpack": "^3.3.0",
"webpack-dashboard": "^0.4.0",
"webpack-dev-server": "2.5.1"
"webpack-dev-server": "2.5.1",
"karma-coverage-istanbul-reporter": "^1.4.1"
},
"dependencies": {
"lodash": "^4.17.4"
Expand Down

0 comments on commit aff34e0

Please sign in to comment.