Skip to content

Commit 4209c99

Browse files
committed
Added coverage per @lathonez
1 parent 8bfe80d commit 4209c99

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"ionic:serve": "ionic-app-scripts serve",
1111
"test": "karma start ./test-config/karma.conf.js",
1212
"test-ci": "karma start ./test-config/karma.conf.js --single-run",
13+
"test-coverage": "karma start ./test-config/karma.conf.js --coverage",
1314
"e2e": "npm run e2e-update && npm run e2e-test",
1415
"e2e-test": "protractor ./test-config/protractor.conf.js",
1516
"e2e-update": "webdriver-manager update --standalone false --gecko false"
@@ -40,10 +41,12 @@
4041
"@types/node": "^7.0.8",
4142
"angular2-template-loader": "^0.6.2",
4243
"html-loader": "^0.4.5",
44+
"istanbul-instrumenter-loader": "^3.0.0",
4345
"jasmine": "^2.5.3",
4446
"jasmine-spec-reporter": "^4.1.0",
4547
"karma": "^1.5.0",
4648
"karma-chrome-launcher": "^2.0.0",
49+
"karma-coverage-istanbul-reporter": "^1.3.0",
4750
"karma-jasmine": "^1.1.0",
4851
"karma-jasmine-html-reporter": "^0.2.2",
4952
"karma-sourcemap-loader": "^0.3.7",

test-config/karma.conf.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,12 @@ module.exports = function(config) {
4444
terminal: true
4545
},
4646

47-
reporters: ['kjhtml', 'dots'],
47+
coverageIstanbulReporter: {
48+
reports: [ 'html', 'lcovonly' ],
49+
fixWebpackSourcePaths: true
50+
},
51+
52+
reporters: config.coverage ? ['kjhtml', 'dots', 'coverage-istanbul'] : ['kjhtml', 'dots'],
4853
port: 9876,
4954
colors: true,
5055
logLevel: config.LOG_INFO,

test-config/webpack.test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,15 @@ module.exports = {
1515
loader: 'ts-loader'
1616
}, 'angular2-template-loader']
1717
},
18+
{
19+
test: /.+\.ts$/,
20+
exclude: /(index.ts|mocks.ts|\.spec\.ts$)/,
21+
loader: 'istanbul-instrumenter-loader',
22+
enforce: 'post',
23+
query: {
24+
esModules: true
25+
}
26+
},
1827
{
1928
test: /\.html$/,
2029
loader: 'html-loader?attrs=false'

0 commit comments

Comments
 (0)