Skip to content
This repository was archived by the owner on Aug 4, 2021. It is now read-only.

Commit 18013b0

Browse files
author
Tynarus
committed
Adding new 'coverage' command to run unit test coverage reporting, reverting 'test' command to run auto-updating chrome test reporter.
1 parent 5f18da0 commit 18013b0

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ A basic Angular 4 seed project utilizing the following technologies:
1313

1414
* `npm start` - start the development webpack server (access via http://localhost:3000/)
1515
* `npm test` - run the project unit tests (*.spec.ts files)
16+
* `npm run coverage` - run the project unit tests one time and print out a coverage report, generated under **/coverage/index.html**
1617
* `npm run lint` - run the project linting (will be run every time `npm test` is run)
1718
* `npm run build` - generate a production build for the project, which will be inserted into dist/

config/test/karma.conf.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ module.exports = function(config) {
2424
require('karma-sourcemap-loader')
2525
],
2626
client:{
27-
clearContext: false
27+
clearContext: false,
28+
args: [ '--coverage', config.coverage ]
2829
},
2930
webpack: webpackConfig,
3031
coverageIstanbulReporter: {
@@ -34,14 +35,12 @@ module.exports = function(config) {
3435
exclude: /\*.spec.ts/
3536
}
3637
},
37-
// TODO build flag/param to specify coverage mode
38-
reporters: [ 'progress', /*'kjhtml', */'coverage-istanbul' ],
38+
reporters: config.coverage ? [ 'progress', 'coverage-istanbul' ] : [ 'progress', 'kjhtml' ],
3939
port: 9876,
4040
colors: true,
4141
logLevel: config.LOG_INFO,
4242
autoWatch: true,
4343
browsers: [ 'Chrome' ],
44-
// TODO coverage param applies to this, too!
45-
singleRun: true
44+
singleRun: config.coverage
4645
});
4746
};

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"scripts": {
1111
"start": "webpack-dev-server --inline --config config/build/webpack.dev.js --progress --port 3000",
1212
"test": "karma start config/test/karma.conf.js",
13+
"coverage": "npm run lint && karma start config/test/karma.conf.js --coverage=true",
1314
"lint": "tslint -c config/tslint.json \"src/app/**/*.ts\"",
1415
"pretest": "npm run lint",
1516
"build": "rimraf dist && webpack --config config/build/webpack.prod.js --progress --profile --bail"

0 commit comments

Comments
 (0)