Skip to content

Commit 3a312a0

Browse files
committed
Add test coverage for protractor and ability to combine reports with
Karma. Add some base karma tests and update readme.
1 parent bc578fc commit 3a312a0

File tree

8 files changed

+90
-13
lines changed

8 files changed

+90
-13
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ node_modules
22
bower_components
33
dist
44
test_out
5-
coverage
5+
coverage
6+
instrument

.travis.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,8 @@ before_install:
1313
script:
1414
- npm run start
1515
- sleep 3
16+
- npm run instrument
1617
- npm run test-single
17-
- npm run protractor
18+
- npm run protractor
19+
- npm run cover-combined
20+
- cat ./coverage/final/lcov.info | coveralls

README.md

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#Ignite UI directives for AngularJS
22

3-
[![Build Status](https://travis-ci.org/IgniteUI/igniteui-angular.svg?branch=master)](https://travis-ci.org/IgniteUI/igniteui-angular) [![Codacy Badge](https://api.codacy.com/project/badge/grade/f7b38e525b504be0aabc891079530521)](https://www.codacy.com/app/kdinev/igniteui-angular)
3+
[![Build Status](https://travis-ci.org/IgniteUI/igniteui-angular.svg?branch=master)](https://travis-ci.org/IgniteUI/igniteui-angular)
4+
[![Coverage Status](https://coveralls.io/repos/github/IgniteUI/igniteui-angular/badge.svg?branch=master)](https://coveralls.io/github/IgniteUI/igniteui-angular?branch=master)
5+
[![Codacy Badge](https://api.codacy.com/project/badge/grade/f7b38e525b504be0aabc891079530521)](https://www.codacy.com/app/kdinev/igniteui-angular)
46

57
Use the directives found in `igniteui-angular.js` to use [Ignite UI](http://igniteui.com) controls in [AngularJS](http://angularjs.com) pages. [Work with the running samples here](http://igniteui.github.io/igniteui-angular).
68

@@ -150,7 +152,11 @@ Simply do:
150152

151153
npm install
152154

153-
The command is preconfigured and it will also call `bower install` behind the scenes.
155+
The command is preconfigured and it will also call `bower install` behind the scenes.
156+
157+
Then you need to instrument the source file with:
158+
159+
npm run instrument
154160

155161
####Running Unit Tests
156162
The easiest way to run the unit tests is to use the npm script:
@@ -190,6 +196,25 @@ Running the tests is done with:
190196

191197
**Note:** You will need to run the protractor on a separate bash
192198

199+
###Code coverage
200+
After running the Karma or Protractor tests by default a coverage will be created for each of them.
201+
202+
To combine the both reports into one single report you need to execute:
203+
204+
npm run cover-combined
205+
206+
After that the default directory where you can open the code coverage is igniteui-angular/coverage/final/lcov/src.
207+
208+
**Running specific coverage:**
209+
210+
To view only the Karma coverage you can see it under *coverage/karma/**/lcov-report/src*.
211+
212+
To view the code coverage only for the Protractor you need to run the command:
213+
214+
npm run cover-protractor
215+
216+
After that the location is the same(igniteui-angular/coverage/final/lcov/src). That is because the Protractor report is not easily readable by default.
217+
193218
---------------------------------------
194219

195220
##What is Ignite UI?

package.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,33 @@
22
"name": "igniteui-angular",
33
"dependencies": {},
44
"devDependencies": {
5+
"mkdirp": "",
56
"coveralls": "",
67
"grunt": "",
78
"grunt-contrib-jshint": "",
89
"grunt-contrib-uglify": "",
910
"grunt-contrib-watch": "",
1011
"jshint-stylish": "",
1112
"protractor": "",
13+
"protractor-istanbul-plugin": "",
1214
"http-server": "",
1315
"bower": "",
1416
"shelljs": "",
17+
"istanbul-coveralls": "",
1518
"karma": "",
1619
"karma-jasmine": "",
1720
"karma-coverage": "",
1821
"karma-chrome-launcher": "",
1922
"karma-firefox-launcher": "",
2023
"karma-junit-reporter": ""
21-
2224
},
2325
"scripts": {
2426
"postinstall": "bower install",
25-
27+
"instrument": "istanbul instrument ./src/ -o ./instrument/",
28+
29+
"cover-protractor": "rm -rf coverage/tmp && mkdirp coverage/tmp/ && cp coverage/protractor/*.json coverage/tmp/ && istanbul report --include=./coverage/tmp/*.json -dir coverage/final",
30+
"cover-combined": "rm -rf coverage/tmp && mkdirp coverage/tmp/ && cp coverage/karma/**/coverage*.json coverage/tmp/ && cp coverage/protractor/*.json coverage/tmp/ && istanbul report --include=./coverage/tmp/*.json -dir coverage/final",
31+
2632
"prestart": "npm install",
2733
"start": "http-server -a localhost -p 8000 &",
2834

test/app/index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ <h1>igEditors</h1>
141141

142142
<script src="http://cdn-na.infragistics.com/igniteui/latest/js/infragistics.core.js"></script>
143143
<script src="http://cdn-na.infragistics.com/igniteui/latest/js/infragistics.lob.js"></script>
144-
<script type="text/javascript" src="../../src/igniteui-angular.js"></script>
144+
<!-- <script type="text/javascript" src="../../src/igniteui-angular.js"></script> -->
145+
<script type="text/javascript" src="../../instrument/igniteui-angular.js"></script>
145146
<script type="text/javascript" src="js/my-app-utils.js"></script>
146147
<script type="text/javascript" src="js/my-app.js"></script>
147148
</body>

test/karma.conf.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ module.exports = function(config){
3737

3838
coverageReporter: {
3939
reporters:[
40-
{ type: 'lcov', dir:'coverage/' },
41-
{ type: 'json', dir:'coverage/', file: 'coverage.json' },
40+
{ type: 'lcov', dir:'coverage/karma/' },
41+
{ type: 'json', dir:'coverage/karma/', file: 'coverage.json' },
4242
],
4343
},
4444

test/protractor-conf.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,17 @@ var cfg = {
22

33
allScriptsTimeout: 11000,
44

5+
plugins : [{
6+
path: "../node_modules/protractor-istanbul-plugin",
7+
outputPath: "coverage/protractor"
8+
}],
9+
510
specs: [
611
"e2e/*.js"
712
],
813
//chromeOnly: true, //https://github.com/angular/protractor/issues/187
9-
capabilities: {
10-
"browserName": "chrome"
14+
capabilities: {
15+
'browserName': "chrome"
1116
},
1217

1318
baseUrl: "http://localhost:8000/test/app/",
@@ -21,7 +26,7 @@ var cfg = {
2126

2227
if (process.env.TRAVIS) {
2328
cfg.capabilities.chromeOptions = {
24-
'args': ['--no-sandbox']
29+
'args': ["--no-sandbox"]
2530
};
2631
}
2732

test/unit/directiveSpecs.js

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ describe('Ignite directives', function() {
104104
}));
105105

106106
it('should create tree', inject(function($compile, $rootScope) {
107-
var treeTpl ='<ig-tree id="tree1" data-source="ProductCategories">';
107+
var treeTpl ='<ig-tree id="tree1" data-source="ProductCategories">' +
108108
'<bindings child-data-property="ProductSubcategories" text-key="Name" value-key="ProductCategoryID"></bindings>' +
109109
'</ig-tree>';
110110
var tree = angular.element('<div ng-app="my-app"><div ng-controller="NorthwindCtrl">' + treeTpl + '</div>');
@@ -116,4 +116,40 @@ describe('Ignite directives', function() {
116116
expect(treeElement.data('igTree')).not.toBeUndefined();
117117
expect(treeElement.data('igTree').options.bindings.constructor).toBe(Object);
118118
}));
119+
120+
it('should create data chart', inject(function($compile, $rootScope) {
121+
var dataChartTpl ='<ig-data-chart id="datachart1" data-source="dataChart">' +
122+
'<axes><axis name="NameAxis" type="categoryX" title="Country" label="CountryName"></axis>' +
123+
'<axis name="PopulationAxis" type="numericY" minimumvalue="0" title="Milions of People"></axis></axes>' +
124+
'<series><series name="2015Population" type="column" is-highlighting-enabled="true" is-transition-in-enabled="true" x-axis="NameAxis" y-axis="PopulationAxis" value-member-path="Pop2015">' +
125+
'</series></series></ig-data-chart>';
126+
var dataChart = angular.element('<div ng-app="my-app"><div ng-controller="NorthwindCtrl">' + dataChartTpl + '</div>');
127+
var scope = $rootScope.$new();
128+
$compile(dataChart)(scope);
129+
scope.$digest();
130+
var dataChartElement = dataChart.find('#datachart1');
131+
expect(dataChartElement.length).toBe(1);
132+
expect(dataChartElement.data('igDataChart')).not.toBeUndefined();
133+
}));
134+
135+
it('should create hierarchical grid', inject(function($compile, $rootScope) {
136+
var hierarchicalGridTpl ='<ig-hierarchical-grid id="hgrid1" data-source="northwindEmployees" width="100%" height="400px" auto-commit="true" auto-generate-columns="false" auto-generate-layouts="false">' +
137+
'<columns> <column key="FirstName" header-text="First Name" width="25%" data-type="string"></column>' +
138+
'<column key="LastName" header-text="Last Name" width="25%" data-type="string"></column>' +
139+
'<column key="Title" header-text="Title" width="25%" data-type="string"></column>' +
140+
'<column key="BirthDate" header-text="Birth Date" width="25%" data-type="date"></column></columns>' +
141+
'<column-layouts><column-layout key="Orders" response-data-key="results" primary-key="OrderID" auto-generate-columns="false" width="100%">' +
142+
'<columns><column key="OrderID" header-text="OrderID" width="25%" data-type="string"></column>' +
143+
'<column key="Freight" header-text="Freight" width="25%" data-type="string"></column>' +
144+
'<column key="ShipName" header-text="ShipName" width="25%" data-type="string"></column>' +
145+
'<column key="ShipAddress" header-text="ShipAddress" width="25%" data-type="string"></column></columns>' +
146+
'<features><feature name="Paging" page-size="10"></feature></features></column-layout></column-layouts>ig-hierarchical-grid>';
147+
var hierarchicalGrid = angular.element('<div ng-app="my-app"><div ng-controller="NorthwindCtrl">' + hierarchicalGridTpl + '</div>');
148+
var scope = $rootScope.$new();
149+
$compile(hierarchicalGrid)(scope);
150+
scope.$digest();
151+
var hGridElement = hierarchicalGrid.find('#hgrid1');
152+
expect(hGridElement.length).toBe(1);
153+
expect(hGridElement.data('igHierarchicalGrid')).not.toBeUndefined();
154+
}));
119155
});

0 commit comments

Comments
 (0)