Skip to content

Commit

Permalink
Implement Browser testing by means of Coveralls
Browse files Browse the repository at this point in the history
  • Loading branch information
evilaliv3 committed Jan 5, 2016
1 parent c97f3fd commit bebdb83
Show file tree
Hide file tree
Showing 9 changed files with 201 additions and 98 deletions.
29 changes: 25 additions & 4 deletions .travis.yml
@@ -1,5 +1,26 @@
language: node_js
node_js:
- 0.10
before_script:
- 'npm install -g grunt-cli bower && bower install'
sudo: false
cache:
directories:
- node_modules
env:
global:
- SAUCE_USERNAME=ng-flow
- SAUCE_ACCESS_KEY=008c40ec-dbaf-4edc-abad-6c6afcc5d13a
matrix:
fast_finish: true
include:
- env: TEST='unit-tests'
node_js: "4.2"
- env: TEST='browser-tests'
node_js: "4.2"
addons:
sauce_connect: true
allow_failures:
- env: TEST='browser-tests'
before_install: npm install -g grunt-cli bower
install:
- npm install
- bower update
script:
- $TRAVIS_BUILD_DIR/travis.sh
69 changes: 35 additions & 34 deletions Gruntfile.js
Expand Up @@ -34,49 +34,47 @@ module.exports = function(grunt) {
}
}
},
coveralls: {
options: {
coverageDir: 'coverage/'
}
},
karma: {
options: {
configFile: 'karma.conf.js'
},
watch: {

},
continuous: {
singleRun: true
},
travis: {
coverage: {
singleRun: true,
browsers: ['PhantomJS'],
browsers: ['Firefox'],
reporters: ['progress', 'coverage'],
preprocessors: {
// source files, that you wanna generate coverage for
// do not include tests or libraries
// (these files will be instrumented by Istanbul)
'src/**/*.js': ['coverage']
'src/**/*.js': 'coverage'
},
coverageReporter: {
reporters: [
{
type: 'lcov',
dir: 'test-results/',
subdir: '.'
}
]
type: "lcov",
dir: "coverage"
}
}
},
coveralls: {
options: {
force: true
},
main: {
src: 'test-results/lcov.info'
}
},
david: {
main: {
options: {
update: false
saucelabs: {
singleRun: true,
reporters: ['progress', 'saucelabs'],
preprocessors: {
'src/**/*.js': 'coverage'
},
coverageReporter: {
type: "lcov",
dir: "coverage/"
},
// global config for SauceLabs
sauceLabs: {
testName: 'ng-flow',
username: grunt.option('sauce-username') || process.env.SAUCE_USERNAME,
accessKey: grunt.option('sauce-access-key') || process.env.SAUCE_ACCESS_KEY,
tunnelIdentifier: process.env.TRAVIS_JOB_NUMBER,
startConnect: false
}
}
},
Expand Down Expand Up @@ -105,15 +103,18 @@ module.exports = function(grunt) {
if (key !== "grunt" && key.indexOf("grunt") === 0) grunt.loadNpmTasks(key);
}

grunt.registerTask('build', ['concat', 'uglify']);
grunt.registerTask('test', ['karma:continuous']);
grunt.registerTask('travis', ['karma:travis','coveralls:main','david:main']);
grunt.registerTask('watch', ['karma:watch']);
// Default task.
grunt.registerTask('default', ['test']);

// Release tasks
grunt.registerTask('build', ['concat', 'uglify']);
grunt.registerTask('release', function(type) {
type = type ? type : 'patch';
grunt.task.run('bump-only:' + type);
grunt.task.run('clean', 'build');
grunt.task.run('bump-commit');
});
};

// Development
grunt.registerTask('test', ["karma:coverage"]);
};
11 changes: 3 additions & 8 deletions README.md
@@ -1,13 +1,8 @@
[![Build Status](https://travis-ci.org/flowjs/ng-flow.svg)](https://travis-ci.org/flowjs/ng-flow)
[![devDependency Status](https://david-dm.org/flowjs/ng-flow/dev-status.svg)](https://david-dm.org/flowjs/ng-flow#info=devDependencies)
[![Coverage Status](https://coveralls.io/repos/flowjs/ng-flow/badge.svg?branch=master)](https://coveralls.io/r/flowjs/ng-flow?branch=master)
# 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)

What is ng-flow?
============

Flow.js extensions for angular.js framework, no 3rd party JS dependencies required!
[![Saucelabs Test Status](https://saucelabs.com/browser-matrix/ng-flow.svg)](https://saucelabs.com/u/ng-flow)

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

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

Expand Down
118 changes: 92 additions & 26 deletions karma.conf.js
@@ -1,70 +1,136 @@
module.exports = function(config) {
config.set({
// define SL browsers
var customLaunchers = {
sl_ie10: {
base: 'SauceLabs',
browserName: 'internet explorer',
platform: 'Windows 8',
version: '10.0'
},
sl_ie11: {
base: 'SauceLabs',
browserName: 'internet explorer',
platform: 'Windows 10',
version: '11.0'
},
sl_edge: {
base: 'SauceLabs',
browserName: 'microsoftedge',
platform: 'Windows 10',
version: '20.10240'
},
sl_chrome_1: {
base: 'SauceLabs',
browserName: 'chrome',
platform: 'Linux',
version: '26'
},
sl_chrome_2: {
base: 'SauceLabs',
browserName: 'chrome',
platform: 'Linux',
version: '46'
},
sl_firefox_1: {
base: 'SauceLabs',
browserName: 'firefox',
platform: 'Linux',
version: '13'
},
sl_firefox_2: {
base: 'SauceLabs',
browserName: 'firefox',
platform: 'Linux',
version: '42'
},
sl_android_1: {
base: 'SauceLabs',
browserName: 'android',
platform: 'Linux',
version: '4.4'
},
sl_android_2: {
base: 'SauceLabs',
browserName: 'android',
platform: 'Linux',
version: '5.1'
},
sl_iphone_1: {
base: 'SauceLabs',
browserName: 'iPhone',
platform: 'OS X 10.10',
deviceName: 'iPad Simulator',
version: '7.1'
},
sl_iphone_2: {
base: 'SauceLabs',
browserName: 'iPhone',
platform: 'OS X 10.10',
deviceName: 'iPad Simulator',
deviceOrientation: 'portrait',
version: '9.2'
},
sl_safari_1: {
base: 'SauceLabs',
browserName: 'safari',
platform: 'OS X 10.8',
version: '6.0'
},
sl_safari_2: {
base: 'SauceLabs',
browserName: 'safari',
platform: 'OS X 10.11',
version: '9.0'
}
}

config.set({
// base path, that will be used to resolve files and exclude
basePath: '',

basePath: './',

// frameworks to use
frameworks: ['jasmine'],


// list of files / patterns to load in the browser
files: [
'bower_components/angular/angular.js',
'bower_components/angular-mocks/angular-mocks.js',
'bower_components/flow.js/dist/flow.js',

'src/**/*.js',
'test/*.spec.js'
],


// list of files to exclude
exclude: [

],


// test results reporter to use
// possible values: 'dots', 'progress', 'junit', 'growl', 'coverage'
reporters: ['progress'],

reporters: ['progress', 'coverage', 'saucelabs'],

// web server port
port: 9876,


// enable / disable colors in the output (reporters and logs)
colors: true,


// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,


// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,


// Start these browsers, currently available:
// - Chrome
// - ChromeCanary
// - Firefox
// - Opera (has to be installed with `npm install karma-opera-launcher`)
// - Safari (only Mac; has to be installed with `npm install karma-safari-launcher`)
// - PhantomJS
// - IE (only Windows; has to be installed with `npm install karma-ie-launcher`)
browsers: ['Chrome'],


// If browser does not capture in given timeout [ms], kill it
captureTimeout: 60000,


// Continuous Integration mode
// if true, it capture browsers, run tests and exit
singleRun: false
singleRun: true,

customLaunchers: customLaunchers,

browsers: Object.keys(customLaunchers),
});
};
3 changes: 1 addition & 2 deletions package.js
Expand Up @@ -22,5 +22,4 @@ Package.onUse(function(api) {
api.use('digimet:flowjs@2.9.0', where);

api.addFiles('./dist/ng-flow.js', where); // Files in use

});
});
22 changes: 12 additions & 10 deletions package.json
Expand Up @@ -3,7 +3,7 @@
"version": "2.6.1",
"description": "Flow.js html5 file upload extension on angular.js framework",
"scripts": {
"test": "grunt travis"
"test": "grunt test"
},
"main": "dist/ng-flow.js",
"repository": {
Expand All @@ -26,14 +26,16 @@
"readmeFilename": "README.md",
"devDependencies": {
"grunt": "~0.4",
"grunt-contrib-uglify": "~0.4",
"grunt-contrib-concat": "~0.3.0",
"grunt-karma": "~0.6.2",
"grunt-coveralls": "~1.0.0",
"grunt-david": "~0.3.0",
"grunt-bump": "0.0.13",
"grunt-contrib-clean": "~0.5.0",
"karma-coverage": "~0.3.1",
"karma-phantomjs-launcher": "~0.1.4"
"grunt-bump": "0.7.0",
"grunt-contrib-clean": "~0.7.0",
"grunt-contrib-concat": "~0.5.1",
"grunt-contrib-uglify": "~0.11",
"grunt-karma": "~0.12.1",
"grunt-karma-coveralls": "^2.5.4",
"karma": "0.13",
"karma-coverage": "0.5.3",
"karma-firefox-launcher": "0.1.7",
"karma-jasmine": "^0.3.6",
"karma-sauce-launcher": "0.3.0"
}
}
12 changes: 6 additions & 6 deletions test/events.spec.js
Expand Up @@ -29,8 +29,8 @@ describe('events', function () {
}));
it('should catch event on element scope', function () {
expect(ngFileProgress).toHaveBeenCalled();
expect(ngFileProgress.callCount).toBe(1);
var args = ngFileProgress.mostRecentCall.args;
expect(ngFileProgress.calls.count()).toBe(1);
var args = ngFileProgress.calls.mostRecent().args;
expect(args[1]).toBe(elementScope.$flow);
expect(args[2]).toBe('file');
});
Expand All @@ -52,18 +52,18 @@ describe('events', function () {
uploadStart = jasmine.createSpy('uploadStart');
elementScope.$on('flow::uploadStart', uploadStart);
elementScope.$flow.fire('uploadStart');
expect(uploadStart.callCount).toBe(1);
expect(uploadStart.calls.count()).toBe(1);
});
it('should execute scope function', function () {
elementScope.$flow.fire('uploadStart');
expect($rootScope.uploadStart.callCount).toBe(1);
expect($rootScope.uploadStart.calls.count()).toBe(1);
});
});

it('should call event', function () {
elementScope.$flow.fire('fileProgress', 'file');
expect($rootScope.fileProgress).toHaveBeenCalledWith('file');
expect($rootScope.fileProgress.callCount).toBe(2);
expect($rootScope.fileProgress.calls.count()).toBe(2);
});

describe('nested flow directives', function () {
Expand All @@ -90,4 +90,4 @@ describe('events', function () {
expect($rootScope.fileProgress1).not.toHaveBeenCalled();
});
});
});
});

0 comments on commit bebdb83

Please sign in to comment.