Permalink
Browse files

Add configuration for running client tests using Sauce Labs

This gives us the capability to test the client-side JS
rewriting against a suite of different browsers on different
platforms.

Note that getting Karma running on Travis CI requires some
additional configuration documented at
github.com/karma-runner/karma-sauce-launcher/issues/73
which is not made clear in the original documentation.

In order to run the Karma tests, the Sauce Labs username
and access keys need to be passed in via the SAUCE_USERNAME
and SAUCE_ACCESS_KEYS env vars.
  • Loading branch information...
1 parent f4a43a1 commit a4d05d469f0c3986b900eba37228155065567955 @robertknight robertknight committed Nov 25, 2015
Showing with 58 additions and 32 deletions.
  1. +1 −1 .travis.yml
  2. +53 −31 karma-tests/karma.conf.js
  3. +3 −0 karma-tests/wombat.spec.js
  4. +1 −0 package.json
View
@@ -6,7 +6,7 @@ python:
os:
- linux
-# - osx
+
sudo: false
@@ -1,18 +1,56 @@
+if (!process.env['SAUCE_USERNAME'] || !process.env['SAUCE_ACCESS_KEY']) {
+ console.error('Sauce Labs account details not set, skipping Karma tests');
+ process.exit(0);
+}
+
+var sauceLabsConfig = {
+ testName: 'PyWB Client Tests',
+};
+
+// see https://github.com/karma-runner/karma-sauce-launcher/issues/73
+if (process.env.TRAVIS_JOB_NUMBER) {
+ sauceLabsConfig.startConnect = false;
+ sauceLabsConfig.tunnelIdentifier = process.env.TRAVIS_JOB_NUMBER;
+}
+
var WOMBAT_JS_PATH = 'pywb/static/wombat.js';
+var customLaunchers = {
+ sl_chrome: {
+ base: 'SauceLabs',
+ browserName: 'chrome',
+ },
+
+ sl_firefox: {
+ base: 'SauceLabs',
+ browserName: 'firefox',
+ },
+
+/* Safari and Edge are currently broken in
+ pywb.
+
+ See: https://github.com/ikreymer/pywb/issues/148 (Edge)
+ https://github.com/ikreymer/pywb/issues/147 (Safari)
+
+ sl_safari: {
+ base: 'SauceLabs',
+ browserName: 'safari',
+ platform: 'OS X 10.11',
+ version: '9.0',
+ },
+ sl_edge: {
+ base: 'SauceLabs',
+ browserName: 'MicrosoftEdge',
+ },
+*/
+};
+
module.exports = function(config) {
config.set({
-
- // 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'],
-
- // list of files / patterns to load in the browser
files: [
{
pattern: WOMBAT_JS_PATH,
@@ -23,46 +61,30 @@ module.exports = function(config) {
'karma-tests/*.spec.js',
],
-
- // preprocess matching files before serving them to the browser
- // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {},
-
- // test results reporter to use
- // possible values: 'dots', 'progress'
- // available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress'],
-
- // 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,
+ sauceLabs: sauceLabsConfig,
- // start these browsers
- // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
- browsers: ['Chrome'],
+ // use an extended timeout for capturing Sauce Labs
+ // browsers in case the service is busy
+ captureTimeout: 3 * 60000,
+ customLaunchers: customLaunchers,
+
+ browsers: Object.keys(customLaunchers),
- // Continuous Integration mode
- // if true, Karma captures browsers, runs the tests and exits
singleRun: false,
- // Concurrency level
- // how many browser should be started simultanous
concurrency: Infinity
})
-}
+};
@@ -1,4 +1,5 @@
var WOMBAT_SRC = '../pywb/static/wombat.js';
+var DEFAULT_TIMEOUT = 20000;
// creates a new document in an <iframe> and runs
// a WombatJS test case in it.
@@ -80,6 +81,8 @@ function runWombatTest(testCase, done) {
}
describe('WombatJS', function () {
+ this.timeout(DEFAULT_TIMEOUT);
+
var wombatScript;
before(function (done) {
View
@@ -28,6 +28,7 @@
"karma-firefox-launcher": "^0.1.7",
"karma-html2js-preprocessor": "^0.1.0",
"karma-mocha": "^0.2.1",
+ "karma-sauce-launcher": "^0.3.0",
"mocha": "^2.3.4"
}
}

0 comments on commit a4d05d4

Please sign in to comment.