Skip to content

Added coverage per @lathonez #68

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 18 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,14 @@ To run the end-to-end tests, run (while the app is being served) `npm run e2e`.
See the example end-to-end test in `e2e/app.e2e-spec.ts`.

UPDATES:
==========
### **2017-08-26: Update to `ionic-angular` version 3.6.0**

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`.
--------
### **2017-09-05: Added Code Coverage Functionality**

### **Also of note:**
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.

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

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.

#### **Added: Update code to match Ionic templates**

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.
The documentation is created inside the `/coverage` folder (ignored by git).

## Looking for Version 2?

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

Past Updates
==========

### **2017-08-26: Update to `ionic-angular` version 3.6.0**

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`.

## **Added: Fix for assets not being found by Karma**

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.

#### **Added: Update code to match Ionic templates**

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.

#### *2017-05-28: Update to Version 3.3.0*

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.
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"ionic:serve": "ionic-app-scripts serve",
"test": "karma start ./test-config/karma.conf.js",
"test-ci": "karma start ./test-config/karma.conf.js --single-run",
"test-coverage": "karma start ./test-config/karma.conf.js --coverage",
"e2e": "npm run e2e-update && npm run e2e-test",
"e2e-test": "protractor ./test-config/protractor.conf.js",
"e2e-update": "webdriver-manager update --standalone false --gecko false"
Expand Down Expand Up @@ -40,10 +41,12 @@
"@types/node": "^7.0.8",
"angular2-template-loader": "^0.6.2",
"html-loader": "^0.4.5",
"istanbul-instrumenter-loader": "^3.0.0",
"jasmine": "^2.5.3",
"jasmine-spec-reporter": "^4.1.0",
"karma": "^1.5.0",
"karma-chrome-launcher": "^2.0.0",
"karma-coverage-istanbul-reporter": "^1.3.0",
"karma-jasmine": "^1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"karma-sourcemap-loader": "^0.3.7",
Expand Down
7 changes: 6 additions & 1 deletion test-config/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@ module.exports = function(config) {
terminal: true
},

reporters: ['kjhtml', 'dots'],
coverageIstanbulReporter: {
reports: [ 'html', 'lcovonly' ],
fixWebpackSourcePaths: true
},

reporters: config.coverage ? ['kjhtml', 'dots', 'coverage-istanbul'] : ['kjhtml', 'dots'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
Expand Down
9 changes: 9 additions & 0 deletions test-config/webpack.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ module.exports = {
loader: 'ts-loader'
}, 'angular2-template-loader']
},
{
test: /.+\.ts$/,
exclude: /(index.ts|mocks.ts|\.spec\.ts$)/,
loader: 'istanbul-instrumenter-loader',
enforce: 'post',
query: {
esModules: true
}
},
{
test: /\.html$/,
loader: 'html-loader?attrs=false'
Expand Down