Skip to content

Commit bebdb83

Browse files
committed
Implement Browser testing by means of Coveralls
1 parent c97f3fd commit bebdb83

9 files changed

+201
-98
lines changed

.travis.yml

+25-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,26 @@
11
language: node_js
2-
node_js:
3-
- 0.10
4-
before_script:
5-
- 'npm install -g grunt-cli bower && bower install'
2+
sudo: false
3+
cache:
4+
directories:
5+
- node_modules
6+
env:
7+
global:
8+
- SAUCE_USERNAME=ng-flow
9+
- SAUCE_ACCESS_KEY=008c40ec-dbaf-4edc-abad-6c6afcc5d13a
10+
matrix:
11+
fast_finish: true
12+
include:
13+
- env: TEST='unit-tests'
14+
node_js: "4.2"
15+
- env: TEST='browser-tests'
16+
node_js: "4.2"
17+
addons:
18+
sauce_connect: true
19+
allow_failures:
20+
- env: TEST='browser-tests'
21+
before_install: npm install -g grunt-cli bower
22+
install:
23+
- npm install
24+
- bower update
25+
script:
26+
- $TRAVIS_BUILD_DIR/travis.sh

Gruntfile.js

+35-34
Original file line numberDiff line numberDiff line change
@@ -34,49 +34,47 @@ module.exports = function(grunt) {
3434
}
3535
}
3636
},
37+
coveralls: {
38+
options: {
39+
coverageDir: 'coverage/'
40+
}
41+
},
3742
karma: {
3843
options: {
3944
configFile: 'karma.conf.js'
40-
},
41-
watch: {
42-
4345
},
4446
continuous: {
4547
singleRun: true
4648
},
47-
travis: {
49+
coverage: {
4850
singleRun: true,
49-
browsers: ['PhantomJS'],
51+
browsers: ['Firefox'],
5052
reporters: ['progress', 'coverage'],
5153
preprocessors: {
52-
// source files, that you wanna generate coverage for
53-
// do not include tests or libraries
54-
// (these files will be instrumented by Istanbul)
55-
'src/**/*.js': ['coverage']
54+
'src/**/*.js': 'coverage'
5655
},
5756
coverageReporter: {
58-
reporters: [
59-
{
60-
type: 'lcov',
61-
dir: 'test-results/',
62-
subdir: '.'
63-
}
64-
]
57+
type: "lcov",
58+
dir: "coverage"
6559
}
66-
}
67-
},
68-
coveralls: {
69-
options: {
70-
force: true
7160
},
72-
main: {
73-
src: 'test-results/lcov.info'
74-
}
75-
},
76-
david: {
77-
main: {
78-
options: {
79-
update: false
61+
saucelabs: {
62+
singleRun: true,
63+
reporters: ['progress', 'saucelabs'],
64+
preprocessors: {
65+
'src/**/*.js': 'coverage'
66+
},
67+
coverageReporter: {
68+
type: "lcov",
69+
dir: "coverage/"
70+
},
71+
// global config for SauceLabs
72+
sauceLabs: {
73+
testName: 'ng-flow',
74+
username: grunt.option('sauce-username') || process.env.SAUCE_USERNAME,
75+
accessKey: grunt.option('sauce-access-key') || process.env.SAUCE_ACCESS_KEY,
76+
tunnelIdentifier: process.env.TRAVIS_JOB_NUMBER,
77+
startConnect: false
8078
}
8179
}
8280
},
@@ -105,15 +103,18 @@ module.exports = function(grunt) {
105103
if (key !== "grunt" && key.indexOf("grunt") === 0) grunt.loadNpmTasks(key);
106104
}
107105

108-
grunt.registerTask('build', ['concat', 'uglify']);
109-
grunt.registerTask('test', ['karma:continuous']);
110-
grunt.registerTask('travis', ['karma:travis','coveralls:main','david:main']);
111-
grunt.registerTask('watch', ['karma:watch']);
106+
// Default task.
107+
grunt.registerTask('default', ['test']);
112108

109+
// Release tasks
110+
grunt.registerTask('build', ['concat', 'uglify']);
113111
grunt.registerTask('release', function(type) {
114112
type = type ? type : 'patch';
115113
grunt.task.run('bump-only:' + type);
116114
grunt.task.run('clean', 'build');
117115
grunt.task.run('bump-commit');
118116
});
119-
};
117+
118+
// Development
119+
grunt.registerTask('test', ["karma:coverage"]);
120+
};

README.md

+3-8
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
1-
[![Build Status](https://travis-ci.org/flowjs/ng-flow.svg)](https://travis-ci.org/flowjs/ng-flow)
2-
[![devDependency Status](https://david-dm.org/flowjs/ng-flow/dev-status.svg)](https://david-dm.org/flowjs/ng-flow#info=devDependencies)
3-
[![Coverage Status](https://coveralls.io/repos/flowjs/ng-flow/badge.svg?branch=master)](https://coveralls.io/r/flowjs/ng-flow?branch=master)
1+
# ng-flow [![Build Status](https://travis-ci.org/flowjs/ng-flow.svg)](https://travis-ci.org/flowjs/ng-flow) [![Coverage Status](https://coveralls.io/repos/flowjs/ng-flow/badge.svg?branch=master)](https://coveralls.io/r/flowjs/ng-flow?branch=master)
42

5-
What is ng-flow?
6-
============
7-
8-
Flow.js extensions for angular.js framework, no 3rd party JS dependencies required!
3+
[![Saucelabs Test Status](https://saucelabs.com/browser-matrix/ng-flow.svg)](https://saucelabs.com/u/ng-flow)
94

10-
ng-flow extension is based on [Flow.js](https://github.com/flowjs/flow.js) library.
5+
ng-flow is a [Flow.js](https://github.com/flowjs/flow.js) extensions for angular.js framework, no 3rd party JS dependencies required!
116

127
Demo: http://flowjs.github.io/ng-flow/
138

karma.conf.js

+92-26
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,136 @@
11
module.exports = function(config) {
2-
config.set({
2+
// define SL browsers
3+
var customLaunchers = {
4+
sl_ie10: {
5+
base: 'SauceLabs',
6+
browserName: 'internet explorer',
7+
platform: 'Windows 8',
8+
version: '10.0'
9+
},
10+
sl_ie11: {
11+
base: 'SauceLabs',
12+
browserName: 'internet explorer',
13+
platform: 'Windows 10',
14+
version: '11.0'
15+
},
16+
sl_edge: {
17+
base: 'SauceLabs',
18+
browserName: 'microsoftedge',
19+
platform: 'Windows 10',
20+
version: '20.10240'
21+
},
22+
sl_chrome_1: {
23+
base: 'SauceLabs',
24+
browserName: 'chrome',
25+
platform: 'Linux',
26+
version: '26'
27+
},
28+
sl_chrome_2: {
29+
base: 'SauceLabs',
30+
browserName: 'chrome',
31+
platform: 'Linux',
32+
version: '46'
33+
},
34+
sl_firefox_1: {
35+
base: 'SauceLabs',
36+
browserName: 'firefox',
37+
platform: 'Linux',
38+
version: '13'
39+
},
40+
sl_firefox_2: {
41+
base: 'SauceLabs',
42+
browserName: 'firefox',
43+
platform: 'Linux',
44+
version: '42'
45+
},
46+
sl_android_1: {
47+
base: 'SauceLabs',
48+
browserName: 'android',
49+
platform: 'Linux',
50+
version: '4.4'
51+
},
52+
sl_android_2: {
53+
base: 'SauceLabs',
54+
browserName: 'android',
55+
platform: 'Linux',
56+
version: '5.1'
57+
},
58+
sl_iphone_1: {
59+
base: 'SauceLabs',
60+
browserName: 'iPhone',
61+
platform: 'OS X 10.10',
62+
deviceName: 'iPad Simulator',
63+
version: '7.1'
64+
},
65+
sl_iphone_2: {
66+
base: 'SauceLabs',
67+
browserName: 'iPhone',
68+
platform: 'OS X 10.10',
69+
deviceName: 'iPad Simulator',
70+
deviceOrientation: 'portrait',
71+
version: '9.2'
72+
},
73+
sl_safari_1: {
74+
base: 'SauceLabs',
75+
browserName: 'safari',
76+
platform: 'OS X 10.8',
77+
version: '6.0'
78+
},
79+
sl_safari_2: {
80+
base: 'SauceLabs',
81+
browserName: 'safari',
82+
platform: 'OS X 10.11',
83+
version: '9.0'
84+
}
85+
}
386

87+
config.set({
488
// base path, that will be used to resolve files and exclude
5-
basePath: '',
6-
89+
basePath: './',
790

891
// frameworks to use
992
frameworks: ['jasmine'],
1093

11-
1294
// list of files / patterns to load in the browser
1395
files: [
1496
'bower_components/angular/angular.js',
1597
'bower_components/angular-mocks/angular-mocks.js',
1698
'bower_components/flow.js/dist/flow.js',
17-
1899
'src/**/*.js',
19100
'test/*.spec.js'
20101
],
21102

22-
23103
// list of files to exclude
24104
exclude: [
25105

26106
],
27107

28-
29108
// test results reporter to use
30109
// possible values: 'dots', 'progress', 'junit', 'growl', 'coverage'
31-
reporters: ['progress'],
32-
110+
reporters: ['progress', 'coverage', 'saucelabs'],
33111

34112
// web server port
35113
port: 9876,
36114

37-
38115
// enable / disable colors in the output (reporters and logs)
39116
colors: true,
40117

41-
42118
// level of logging
43119
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
44120
logLevel: config.LOG_INFO,
45121

46-
47122
// enable / disable watching file and executing tests whenever any file changes
48123
autoWatch: true,
49124

50-
51-
// Start these browsers, currently available:
52-
// - Chrome
53-
// - ChromeCanary
54-
// - Firefox
55-
// - Opera (has to be installed with `npm install karma-opera-launcher`)
56-
// - Safari (only Mac; has to be installed with `npm install karma-safari-launcher`)
57-
// - PhantomJS
58-
// - IE (only Windows; has to be installed with `npm install karma-ie-launcher`)
59-
browsers: ['Chrome'],
60-
61-
62125
// If browser does not capture in given timeout [ms], kill it
63126
captureTimeout: 60000,
64127

65-
66128
// Continuous Integration mode
67129
// if true, it capture browsers, run tests and exit
68-
singleRun: false
130+
singleRun: true,
131+
132+
customLaunchers: customLaunchers,
133+
134+
browsers: Object.keys(customLaunchers),
69135
});
70136
};

package.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,4 @@ Package.onUse(function(api) {
2222
api.use('digimet:[email protected]', where);
2323

2424
api.addFiles('./dist/ng-flow.js', where); // Files in use
25-
26-
});
25+
});

package.json

+12-10
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "2.6.1",
44
"description": "Flow.js html5 file upload extension on angular.js framework",
55
"scripts": {
6-
"test": "grunt travis"
6+
"test": "grunt test"
77
},
88
"main": "dist/ng-flow.js",
99
"repository": {
@@ -26,14 +26,16 @@
2626
"readmeFilename": "README.md",
2727
"devDependencies": {
2828
"grunt": "~0.4",
29-
"grunt-contrib-uglify": "~0.4",
30-
"grunt-contrib-concat": "~0.3.0",
31-
"grunt-karma": "~0.6.2",
32-
"grunt-coveralls": "~1.0.0",
33-
"grunt-david": "~0.3.0",
34-
"grunt-bump": "0.0.13",
35-
"grunt-contrib-clean": "~0.5.0",
36-
"karma-coverage": "~0.3.1",
37-
"karma-phantomjs-launcher": "~0.1.4"
29+
"grunt-bump": "0.7.0",
30+
"grunt-contrib-clean": "~0.7.0",
31+
"grunt-contrib-concat": "~0.5.1",
32+
"grunt-contrib-uglify": "~0.11",
33+
"grunt-karma": "~0.12.1",
34+
"grunt-karma-coveralls": "^2.5.4",
35+
"karma": "0.13",
36+
"karma-coverage": "0.5.3",
37+
"karma-firefox-launcher": "0.1.7",
38+
"karma-jasmine": "^0.3.6",
39+
"karma-sauce-launcher": "0.3.0"
3840
}
3941
}

test/events.spec.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ describe('events', function () {
2929
}));
3030
it('should catch event on element scope', function () {
3131
expect(ngFileProgress).toHaveBeenCalled();
32-
expect(ngFileProgress.callCount).toBe(1);
33-
var args = ngFileProgress.mostRecentCall.args;
32+
expect(ngFileProgress.calls.count()).toBe(1);
33+
var args = ngFileProgress.calls.mostRecent().args;
3434
expect(args[1]).toBe(elementScope.$flow);
3535
expect(args[2]).toBe('file');
3636
});
@@ -52,18 +52,18 @@ describe('events', function () {
5252
uploadStart = jasmine.createSpy('uploadStart');
5353
elementScope.$on('flow::uploadStart', uploadStart);
5454
elementScope.$flow.fire('uploadStart');
55-
expect(uploadStart.callCount).toBe(1);
55+
expect(uploadStart.calls.count()).toBe(1);
5656
});
5757
it('should execute scope function', function () {
5858
elementScope.$flow.fire('uploadStart');
59-
expect($rootScope.uploadStart.callCount).toBe(1);
59+
expect($rootScope.uploadStart.calls.count()).toBe(1);
6060
});
6161
});
6262

6363
it('should call event', function () {
6464
elementScope.$flow.fire('fileProgress', 'file');
6565
expect($rootScope.fileProgress).toHaveBeenCalledWith('file');
66-
expect($rootScope.fileProgress.callCount).toBe(2);
66+
expect($rootScope.fileProgress.calls.count()).toBe(2);
6767
});
6868

6969
describe('nested flow directives', function () {
@@ -90,4 +90,4 @@ describe('events', function () {
9090
expect($rootScope.fileProgress1).not.toHaveBeenCalled();
9191
});
9292
});
93-
});
93+
});

0 commit comments

Comments
 (0)