From 92b835db158d5f84bc3619b4fe422e3546d6093e Mon Sep 17 00:00:00 2001 From: Justin DuJardin Date: Tue, 5 Jan 2016 06:07:26 -0800 Subject: [PATCH] feat: add sauce labs test execution --- .travis.yml | 9 ++ karma.conf.js | 2 + karma.ie.shims.js | 253 ++++++++++++++++++++++++++++++++++++++++++++ karma.sauce.conf.js | 79 ++++++++++++++ package.json | 4 +- 5 files changed, 346 insertions(+), 1 deletion(-) create mode 100644 karma.ie.shims.js create mode 100644 karma.sauce.conf.js diff --git a/.travis.yml b/.travis.yml index b98d0f49..0ce2ccaa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,6 +14,11 @@ before_script: script: - karma start karma.conf.js --single-run + - karma start karma.sauce.conf.js --browsers FIREFOX_V40,FIREFOX_V30,FIREFOX_V35 + - karma start karma.sauce.conf.js --browsers CHROME_VBETA,CHROME_VDEV,CHROME_V39,CHROME_V26 + - karma start karma.sauce.conf.js --browsers MICROSOFTEDGE_V20.10240 + - karma start karma.sauce.conf.js --browsers ANDROID_V5.1,ANDROID_V4.4 + - karma start karma.sauce.conf.js --browsers IE_V9,IE_V10,IE_V11 before_install: - npm install -g karma-cli @@ -22,3 +27,7 @@ after_script: - ./node_modules/.bin/grunt remapIstanbul - ./node_modules/.bin/coveralls < .coverage/lcov.info +env: + global: + - secure: MBodlIJNiw2sdPQZFtWLNXoHWBr6pNz1bPG5QxhckKnU+JzTvlQ34+hG3oYjOFMItLm/TvH/qvHUP9PA9Yh+0TwQJtH3Y2em6L3pGiAdmvzmvWXSEPavkm2sggWoB3zlhTLAH+PlanKuAIbxLe/XgxsEtLRz/WFyylohidGDNsEEz8KPALvS8KJk0TqI9ASHvxru2b2SuqjSIjX3O3ljMsVrwecphB4+RFPMf4ZtiHqsyhdITQdNQoJzJdMLu9zbHNo34SjUXUaftkjysUuEZQ+3DdvzCy6tAvrKfwHVtFGr5ztuYNGPfeRJw3aWCy+uPDFgDRXZALwFVFUyJJnRFqYg3sCN2/G1+FVpQOpDzbTuusyCNOGmJB2sP7bZYhBKAy5Uv1IaaDhEaPBuJl3BYFu1Ax8J9rgeiI/CvV96E3Tco9j0J6DLHgCx0Kn+hBATnql1KvUwlWTy5FRhSjdhte9Er2vw90oJwHawzq4yKbxwBbl/slWxmO2tAKfC2gx45LipdHk7SUzqjldKyQzsGLI0OwOA5rcCrheV6ZbUUtazkA4IletFi83tWZcIWUTrRnNh4UPeJ7f5LKipbrQicOr4P1tQa49NxIYQOS0bcgqBiav5qbFi9tMH0Cu4lCVFEe2dJBr3Z58zBPavCtUzJsDdakVuTTVJIxqP7IcF+QM= + - secure: lbC1OyQnHkW5HoK23YMYyxWp6mg9uYcoh9g755/Tkw3nCET3GKcZ4jKp0Ef13yJEtac0uFsHwNMCMTaWA3LdBJcp44vm8xR0dckVSPPCp/VKKV4Ho9MkbcQqE1K8Bl5voVvP9Q9jrqw2APfauS1vxPYnEI7JLce1MkXyn6VOVUv9aoWDeNOmX/SxIaWw+QPIiyN9ELVvRvkBtRNbwK+VuIovg5l9zGGSmz1BoSsDNsX1KAOElo5uaOAlqrgaoRdPZm0KjZDtdetuSpp8os4QTzCqT1aW06sTyFqMbeC6FwfcpUvD1emkXk9pILDymnjhQANbibLoEbR7ZhF2zGyyaME1k7Hr5C9qN0YHmh1h2PIDwlg2BuDjil/S/KYulKq/5Y2+WNJ3MToM4aA7fPr785e/fvfx68qp/SdJt00PfLSKw/cGA42OUZjr7Dr+fYJFeui/OTjCcFstpPaO0uyRBMqIKOhitG5RqYQjFYudqD4UdTWgtzzrkqUnDTNj4U/gYp9Us/HtWL9fNpcmof/ys8vdZjjodf9Pqx8db43IFmVqmbk0QEysnDABlqE60ykJD2oosRMRXfEkudwEw+ylUDud65z2KqDtE+JNkC0h/yCaBU4MQxibhYJkiepsBz9SJS18VBJgRzlgFKe/ot+DlB8XkbVhhTxDrxi+R3h+vAE= diff --git a/karma.conf.js b/karma.conf.js index c0d044e4..3dfb8cc2 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -16,6 +16,8 @@ module.exports = function (config) { basePath: '', frameworks: ['jasmine'], files: [ + 'node_modules/es6-shim/es6-shim.js', + 'karma.ie.shims.js', 'node_modules/zone.js/dist/zone-microtask.js', 'node_modules/zone.js/dist/long-stack-trace-zone.js', 'node_modules/zone.js/dist/jasmine-patch.js', diff --git a/karma.ie.shims.js b/karma.ie.shims.js new file mode 100644 index 00000000..75a5bbf1 --- /dev/null +++ b/karma.ie.shims.js @@ -0,0 +1,253 @@ +// function.name (all IE) +/*! @source http://stackoverflow.com/questions/6903762/function-name-not-supported-in-ie*/ +if (!Object.hasOwnProperty('name')) { + Object.defineProperty(Function.prototype, 'name', { + get: function() { + var matches = this.toString().match(/^\s*function\s*(\S*)\s*\(/); + var name = matches && matches.length > 1 ? matches[1] : ""; + // For better performance only parse once, and then cache the + // result through a new accessor for repeated access. + Object.defineProperty(this, 'name', {value: name}); + return name; + } + }); +} + +// URL polyfill for SystemJS (all IE) +/*! @source https://github.com/ModuleLoader/es6-module-loader/blob/master/src/url-polyfill.js*/ +// from https://gist.github.com/Yaffle/1088850 +(function(global) { + function URLPolyfill(url, baseURL) { + if (typeof url != 'string') { + throw new TypeError('URL must be a string'); + } + var m = String(url).replace(/^\s+|\s+$/g, "").match(/^([^:\/?#]+:)?(?:\/\/(?:([^:@\/?#]*)(?::([^:@\/?#]*))?@)?(([^:\/?#]*)(?::(\d*))?))?([^?#]*)(\?[^#]*)?(#[\s\S]*)?/); + if (!m) { + throw new RangeError(); + } + var protocol = m[1] || ""; + var username = m[2] || ""; + var password = m[3] || ""; + var host = m[4] || ""; + var hostname = m[5] || ""; + var port = m[6] || ""; + var pathname = m[7] || ""; + var search = m[8] || ""; + var hash = m[9] || ""; + if (baseURL !== undefined) { + var base = baseURL instanceof URLPolyfill ? baseURL : new URLPolyfill(baseURL); + var flag = protocol === "" && host === "" && username === ""; + if (flag && pathname === "" && search === "") { + search = base.search; + } + if (flag && pathname.charAt(0) !== "/") { + pathname = (pathname !== "" ? (((base.host !== "" || base.username !== "") && base.pathname === "" ? "/" : "") + base.pathname.slice(0, base.pathname.lastIndexOf("/") + 1) + pathname) : base.pathname); + } + // dot segments removal + var output = []; + pathname.replace(/^(\.\.?(\/|$))+/, "") + .replace(/\/(\.(\/|$))+/g, "/") + .replace(/\/\.\.$/, "/../") + .replace(/\/?[^\/]*/g, function (p) { + if (p === "/..") { + output.pop(); + } else { + output.push(p); + } + }); + pathname = output.join("").replace(/^\//, pathname.charAt(0) === "/" ? "/" : ""); + if (flag) { + port = base.port; + hostname = base.hostname; + host = base.host; + password = base.password; + username = base.username; + } + if (protocol === "") { + protocol = base.protocol; + } + } + + // convert windows file URLs to use / + if (protocol == 'file:') + pathname = pathname.replace(/\\/g, '/'); + + this.origin = protocol + (protocol !== "" || host !== "" ? "//" : "") + host; + this.href = protocol + (protocol !== "" || host !== "" ? "//" : "") + (username !== "" ? username + (password !== "" ? ":" + password : "") + "@" : "") + host + pathname + search + hash; + this.protocol = protocol; + this.username = username; + this.password = password; + this.host = host; + this.hostname = hostname; + this.port = port; + this.pathname = pathname; + this.search = search; + this.hash = hash; + } +global.URLPolyfill = URLPolyfill; +})(typeof self != 'undefined' ? self : global); + +//classList (IE9) +/*! @license please refer to http://unlicense.org/ */ +/*! @author Eli Grey */ +/*! @source https://github.com/eligrey/classList.js */ +;if("document" in self&&!("classList" in document.createElement("_"))){(function(j){"use strict";if(!("Element" in j)){return}var a="classList",f="prototype",m=j.Element[f],b=Object,k=String[f].trim||function(){return this.replace(/^\s+|\s+$/g,"")},c=Array[f].indexOf||function(q){var p=0,o=this.length;for(;p ie + var label = platform[0].split(' '); + if (label.length > 1) { + label = _.invoke(label, 'charAt', 0) + } + label = (label.join("") + '_v' + platform[1]).replace(' ', '_').toUpperCase(); + memo[label] = { + 'base': 'SauceLabs', + 'browserName': platform[0], + 'version': platform[1], + 'platform': platform[2] + }; + return memo; + }, {}); + + config.set({ + captureTimeout: 240000, + browserNoActivityTimeout: 120000, + + sauceLabs: { + testName: 'ng2-material', + startConnect: true, + recordVideo: false, + recordScreenshots: false, + options: { + 'selenium-version': '2.47.1', + 'command-timeout': 600, + 'idle-timeout': 600, + 'max-duration': 5400 + } + }, + + customLaunchers: sauceBrowsers, + + browsers: Object.keys(sauceBrowsers), + + reporters: ['dots', 'saucelabs', 'coverage'], + + singleRun: true, + + plugins: [ + 'karma-*' + ] + }); + + if (process.env.TRAVIS) { + config.sauceLabs.build = 'TRAVIS #' + process.env.TRAVIS_BUILD_NUMBER + ' (' + process.env.TRAVIS_BUILD_ID + ')'; + config.sauceLabs.tunnelIdentifier = process.env.TRAVIS_JOB_NUMBER; + } + +}; diff --git a/package.json b/package.json index a3e7ab96..069f28e8 100644 --- a/package.json +++ b/package.json @@ -50,10 +50,12 @@ "karma-coverage": "0.5.3", "karma-firefox-launcher": "0.1.7", "karma-jasmine": "0.2.2", + "karma-sauce-launcher": "0.3.0", "lcov-parse": "0.0.10", "marked": "0.3.5", "remap-istanbul": "0.4.0", - "systemjs-builder": "justindujardin/builder.git#typescript-source-maps" + "systemjs-builder": "justindujardin/builder.git#typescript-source-maps", + "underscore": "1.8.3" }, "contributors": [ "Jaroslav Řehořka ",