Skip to content

Commit ca0da30

Browse files
authored
Merge pull request #68 from leifwells/chore/validating-coverage
Added coverage per @lathonez
2 parents e3f44b7 + 209e800 commit ca0da30

File tree

4 files changed

+36
-12
lines changed

4 files changed

+36
-12
lines changed

README.md

+18-11
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,14 @@ To run the end-to-end tests, run (while the app is being served) `npm run e2e`.
4444
See the example end-to-end test in `e2e/app.e2e-spec.ts`.
4545

4646
UPDATES:
47-
==========
48-
### **2017-08-26: Update to `ionic-angular` version 3.6.0**
49-
50-
We updated the project to `ionic-angular` version `3.6.0`. Developers wishing to use this should also update Ionic CLI for a better experience. With today's update, this project is now at version `0.0.5`.
47+
--------
48+
### **2017-09-05: Added Code Coverage Functionality**
5149

52-
### **Also of note:**
50+
Thanks to @lathonez, we now have functioning code coverage functionality. With this update, developers can run `npm run test-coverage` which will run the project's unit tests with Karma and produce documentation that gives guidance on how well the project's tests cover the code.
5351

54-
#### **Added: Fix for assets not being found by Karma**
52+
![Example Image of Completed Code Coverage](https://user-images.githubusercontent.com/1648535/30074946-54a36e50-9241-11e7-9ca8-6263d0353c58.png)
5553

56-
Thanks to [@datencia](https://github.com/datencia) for providing an update to our Karma configuration that properly sets the Karma base path so that image assets can be found during testing. This fix should also work any JSON data files you might want to use for testing. He also provided an image and updated our sample unit test spec file that tests that the image is found.
57-
58-
#### **Added: Update code to match Ionic templates**
59-
60-
Thanks (again) to [@danielsogl](https://github.com/danielsogl/) for providing a code update to the project so that our code matches code created by using the `ionic start` command. Having this code properly match is important as it provides the best practice guidance for handling application start up.
54+
The documentation is created inside the `/coverage` folder (ignored by git).
6155

6256
## Looking for Version 2?
6357

@@ -69,6 +63,19 @@ This repository is based on the awesome [unit testing example](https://github.co
6963

7064
Past Updates
7165
==========
66+
67+
### **2017-08-26: Update to `ionic-angular` version 3.6.0**
68+
69+
We updated the project to `ionic-angular` version `3.6.0`. Developers wishing to use this should also update Ionic CLI for a better experience. With today's update, this project is now at version `0.0.5`.
70+
71+
## **Added: Fix for assets not being found by Karma**
72+
73+
Thanks to [@datencia](https://github.com/datencia) for providing an update to our Karma configuration that properly sets the Karma base path so that image assets can be found during testing. This fix should also work any JSON data files you might want to use for testing. He also provided an image and updated our sample unit test spec file that tests that the image is found.
74+
75+
#### **Added: Update code to match Ionic templates**
76+
77+
Thanks (again) to [@danielsogl](https://github.com/danielsogl/) for providing a code update to the project so that our code matches code created by using the `ionic start` command. Having this code properly match is important as it provides the best practice guidance for handling application start up.
78+
7279
#### *2017-05-28: Update to Version 3.3.0*
7380

7481
Thanks to [@danielsogl](https://github.com/danielsogl/) for getting us up-to-date with Ionic 3.3.0, Angular 4.1.2 and Ionic Native 3.10.2.

package.json

+3
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

+6-1
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

+9
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)