diff --git a/.travis.yml b/.travis.yml index a804745..76d852d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,9 @@ language: node_js sudo: true +addons: + sauce_connect: + username: 'leolin' + access_key: '2d69d455-a8ff-45bd-8a93-5ba373ddf6a3' node_js: - '4.4.2' services: mongodb diff --git a/karma.conf.js b/karma.conf.js index 33f2faf..6282a00 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -2,86 +2,155 @@ // Generated on Sun Jul 31 2016 18:14:21 GMT+0800 (CST) module.exports = function(config) { - config.set({ + var customLaunchers = { + // the cool kids + sl_chrome: { + base: 'SauceLabs', + browserName: 'chrome', + platform: 'Windows 7' + }, + sl_firefox: { + base: 'SauceLabs', + browserName: 'firefox' + }, + sl_mac_safari: { + base: 'SauceLabs', + browserName: 'safari', + platform: 'OS X 10.10' + }, + // ie family + sl_ie_8: { + base: 'SauceLabs', + browserName: 'internet explorer', + platform: 'Windows 7', + version: '8' + }, + sl_ie_9: { + base: 'SauceLabs', + browserName: 'internet explorer', + platform: 'Windows 7', + version: '9' + }, + sl_ie_10: { + base: 'SauceLabs', + browserName: 'internet explorer', + platform: 'Windows 8', + version: '10' + }, + sl_ie_11: { + base: 'SauceLabs', + browserName: 'internet explorer', + platform: 'Windows 8.1', + version: '11' + }, + // mobile + sl_ios_safari: { + base: 'SauceLabs', + browserName: 'iphone', + platform: 'OS X 10.9', + version: '8.1' + }, + sl_android: { + base: 'SauceLabs', + browserName: 'android', + platform: 'Linux', + version: '4.2' + } + }; + + if (!process.env.SAUCE_USERNAME) { + process.env.SAUCE_USERNAME = 'leolin'; + process.env.SAUCE_ACCESS_KEY = '2d69d455-a8ff-45bd-8a93-5ba373ddf6a3'; + } - // base path that will be used to resolve all patterns (eg. files, exclude) - basePath: '', + config.set({ - client: { - mocha: { - timeout: 6000 - } - }, + // base path that will be used to resolve all patterns (eg. files, exclude) + basePath: '', - // frameworks to use - // available frameworks: https://npmjs.org/browse/keyword/karma-adapter - frameworks: ['mocha', 'chai'], + client: { + mocha: { + timeout: 6000 + } + }, + // mobile emulators are really slow + captureTimeout: 300000, + browserNoActivityTimeout: 300000, - // list of files / patterns to load in the browser - files: [ - 'test/**/*.test.js' - ], + // frameworks to use + // available frameworks: https://npmjs.org/browse/keyword/karma-adapter + frameworks: ['mocha', 'chai'], - // list of files to exclude - exclude: [ - '**/*.swp' - ], + // list of files / patterns to load in the browser + files: [ + 'test/**/*.test.js' + ], - // preprocess matching files before serving them to the browser - // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor - preprocessors: { - 'test/**/*.test.js': ['webpack'] - }, + // list of files to exclude + exclude: [ + '**/*.swp' + ], - // test results reporter to use - // possible values: 'dots', 'progress' - // available reporters: https://npmjs.org/browse/keyword/karma-reporter - reporters: ['mocha'], + // preprocess matching files before serving them to the browser + // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor + preprocessors: { + 'test/**/*.test.js': ['webpack'] + }, - // web server port - port: 9876, + // test results reporter to use + // possible values: 'dots', 'progress' + // available reporters: https://npmjs.org/browse/keyword/karma-reporter + reporters: ['coverage', 'mocha', 'saucelabs'], - // enable / disable colors in the output (reporters and logs) - colors: true, + // web server port + port: 9876, - // 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 colors in the output (reporters and logs) + colors: true, - // enable / disable watching file and executing tests whenever any file changes - autoWatch: false, + // level of logging + // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG + logLevel: config.LOG_INFO, - // start these browsers - // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher - browsers: ['Chrome'], + // enable / disable watching file and executing tests whenever any file changes + autoWatch: false, - // Continuous Integration mode - // if true, Karma captures browsers, runs the tests and exits - singleRun: true, + sauceLabs: { + testName: 'bugReport unit tests', + public: 'public' + }, - // Concurrency level - // how many browser should be started simultaneous - concurrency: Infinity, + customLaunchers: customLaunchers, - customLaunchers: { - Chrome_travis_ci: { - base: 'Chrome', - flags: ['--no-sandbox'] - } - } - }); + browsers: Object.keys(customLaunchers), + + // Continuous Integration mode + // if true, Karma captures browsers, runs the tests and exits + singleRun: true, + + // Concurrency level + // how many browser should be started simultaneous + concurrency: Infinity + + // customLaunchers: { + // Chrome_travis_ci: { + // base: 'Chrome', + // flags: ['--no-sandbox'] + // } + // } + }); - if(process.env.TRAVIS){ - config.browsers = ['Chrome_travis_ci']; - } + // if(process.env.TRAVIS){ + // config.browsers = ['Chrome_travis_ci']; + // } } diff --git a/package.json b/package.json index ddc11a3..4f69065 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,7 @@ "karma-mocha": "^1.1.1", "karma-mocha-reporter": "^2.1.0", "karma-safari-launcher": "^1.0.0", + "karma-sauce-launcher": "^1.0.0", "karma-webpack": "^1.7.0", "mocha": "^2.5.3", "webpack": "^1.13.1"