diff --git a/config/karma-sauce.conf.js b/config/karma-sauce.conf.js index bf67d61701..b4dea1eace 100644 --- a/config/karma-sauce.conf.js +++ b/config/karma-sauce.conf.js @@ -1,61 +1,59 @@ +var _ = require('lodash'); +var shared = require('./karma.conf.js'); -module.exports = function(config) { - require('./karma.conf.js')(config); - - config.set({ - reporters: ['dots'], - sauceLabs: { - testName: 'Ionic unit tests', - username: process.env.SAUCE_USER, - accessKey: process.env.SAUCE_KEY, - startConnect: false, - tunnelIdentifier: process.env.TRAVIS_JOB_NUMBER +module.exports = _.assign(shared, { + reporters: ['dots'], + sauceLabs: { + testName: 'Ionic unit tests', + username: process.env.SAUCE_USER, + accessKey: process.env.SAUCE_KEY, + startConnect: false, + tunnelIdentifier: process.env.TRAVIS_BUILD_NUMBER + }, + //Saucelabs mobile emulation (esp android emulator) + //can be really slow sometimes, we need to give it time to connectk + captureTimeout: 60 * 1000, + browserDisconnectTimeout: 60 * 1000, + browserNoActivityTimeout: 60 * 1000, + browserDisconnectTolerance: 2, + browsers: [ + 'sauce_ios', + // 'sauce_safari', + 'sauce_android', + // 'sauce_chrome', + // 'sauce_firefox', + // 'sauce_ie9', + // 'sauce_ie10', + // 'sauce_ie11' + ], + customLaunchers: { + 'sauce_ios': { + base: 'SauceLabs', + platform: 'OS X 10.9', + browserName: 'iphone', + version: '7.1' }, - //Saucelabs mobile emulation (esp android emulator) - //can be really slow sometimes, we need to give it time to connectk - captureTimeout: 60 * 1000, - browserDisconnectTimeout: 60 * 1000, - browserNoActivityTimeout: 60 * 1000, - browserDisconnectTolerance: 2, - browsers: [ - // 'sauce_ios', - // 'sauce_safari', - 'sauce_android', - 'sauce_chrome', - // 'sauce_firefox', - // 'sauce_ie9', - // 'sauce_ie10', - // 'sauce_ie11' - ], - customLaunchers: { - 'sauce_ios': { - base: 'SauceLabs', - platform: 'OS X 10.9', - browserName: 'iphone', - version: '7' - }, - 'sauce_safari': { - base: 'SauceLabs', - browserName: 'safari', - platform: 'OS X 10.9', - version: '7' - }, - 'sauce_android': { - base: 'SauceLabs', - platform: 'Linux', - browserName: 'android', - version: '4.0' - }, - 'sauce_chrome': { - base: 'SauceLabs', - browserName: 'chrome' - }, - 'sauce_firefox': { - base: 'SauceLabs', - platform: 'Linux', - browserName: 'firefox', - version: '26' - } + 'sauce_safari': { + base: 'SauceLabs', + browserName: 'safari', + platform: 'OS X 10.9', + version: '7' }, - }); -}; + 'sauce_android': { + base: 'SauceLabs', + platform: 'Linux', + browserName: 'android', + version: '4.3' + }, + 'sauce_chrome': { + base: 'SauceLabs', + browserName: 'chrome' + }, + 'sauce_firefox': { + base: 'SauceLabs', + platform: 'Linux', + browserName: 'firefox', + version: '26' + } + } +}); diff --git a/config/karma.conf.js b/config/karma.conf.js index f1d9db898f..c225a6ae82 100644 --- a/config/karma.conf.js +++ b/config/karma.conf.js @@ -1,70 +1,42 @@ var buildConfig = require('./build.config.js'); +var path = require('canonical-path'); -module.exports = function(config) { - config.set({ - - // base path, that will be used to resolve files and exclude - basePath: '../', - - - // frameworks to use - frameworks: ['jasmine'], - - - // list of files / patterns to load in the browser - files: [ - // Include jQuery only for testing convience (lots of DOM checking for unit tests on directives) - 'http://codeorigin.jquery.com/jquery-1.10.2.min.js', - 'config/lib/js/angular/angular.js', - 'config/lib/js/angular/angular-animate.js', - 'config/lib/js/angular/angular-sanitize.js', - 'config/lib/js/angular/angular-mocks.js', - 'config/lib/js/angular-ui/angular-ui-router.js', - 'config/lib/testutil.js' - ] +module.exports = { + files: [ + // Include jQuery only for testing convience (lots of DOM checking for unit tests on directives) + 'http://codeorigin.jquery.com/jquery-1.10.2.min.js', + 'config/lib/js/angular/angular.js', + 'config/lib/js/angular/angular-animate.js', + 'config/lib/js/angular/angular-sanitize.js', + 'config/lib/js/angular/angular-mocks.js', + 'config/lib/js/angular-ui/angular-ui-router.js', + 'config/lib/testutil.js' + ] .concat(buildConfig.ionicFiles) .concat(buildConfig.angularIonicFiles) - .concat([ - 'test/unit/**/*.js' - ]), + .concat('test/unit/**/*.js'), - // list of files to exclude - exclude: [ - 'js/ext/angular/test/dom-trace.js' - ], + exclude: [ + 'js/ext/angular/test/dom-trace.js' + ], - // test results reporter to use - // possible values: 'dots', 'progress', 'junit', 'growl', 'coverage' - reporters: ['progress'], + frameworks: ['jasmine'], + reporters: ['progress'], + port: 9876, + colors: true, + // possible values: 'OFF', 'ERROR', 'WARN', 'INFO', 'DEBUG' + logLevel: 'INFO', + autoWatch: true, + captureTimeout: 60000, + singleRun: false, - // 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, - - // 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, - - // 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'] - }); + // 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'] }; diff --git a/gulpfile.js b/gulpfile.js index 420ec4fe6e..a8fc1a4401 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,4 +1,5 @@ var gulp = require('gulp'); +var karma = require('karma').server; var pkg = require('./package.json'); var semver = require('semver'); var through = require('through'); @@ -376,10 +377,15 @@ gulp.task('cloudtest', ['protractor-sauce'], function(cb) { }); gulp.task('karma', function(cb) { - return karma(cb, [__dirname + '/config/karma.conf.js', '--single-run=true']); + return karma.start(_.assign(require('./config/karma.conf.js'), {singleRun: true}), cb); }); gulp.task('karma-watch', function(cb) { - return karma(cb, [__dirname + '/config/karma.conf.js']); + return karma.start(_.assign(require('./config/karma.conf.js'), {singleRun: false}), cb); +}); +gulp.task('karma-sauce', ['sauce-connect'], function(cb) { + return karma.start(require('./config/karma-sauce.conf.js'), function() { + sauceDisconnect(cb); + }); }); var connectServer; diff --git a/package.json b/package.json index f94dd6dd80..1c04bb8d9f 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "url": "git://github.com/driftyco/ionic.git" }, "devDependencies": { - "karma": "~0.11.13", + "karma": "^0.12.16", "karma-chrome-launcher": "~0.1.2", "karma-jasmine": "~0.1.5", "karma-phantomjs-launcher": "~0.1.2",