// Inspired by https://github.com/angular/angular/blob/master/karma-js.conf.js

import { SAUCE_LAUNCHERS } from './sauce.config';

let sauceLabsConfig = {
	testName: 'NG2 Lab - UNIT',
	startConnect: false,
	recordVideo: false,
	recordScreenshots: false,
	options:  {
		'selenium-version': '2.45.0',
		'command-timeout': 600,
		'idle-timeout': 600,
		'max-duration': 5400
	}
};

if (process.env.TRAVIS) {
	sauceLabsConfig.build = 'TRAVIS #' + process.env.TRAVIS_BUILD_NUMBER + ' (' + process.env.TRAVIS_BUILD_ID + ')';
	sauceLabsConfig.tunnelIdentifier = process.env.TRAVIS_JOB_NUMBER;
}

export default function (config) {
	config.set({
		frameworks: [
			'jasmine'
		],
		files: [
			'node_modules/es6-shim/es6-shim.js',
			'node_modules/systemjs/dist/system.js', // Including systemjs because it defines `__eval`, which produces correct stack traces
			'node_modules/angular2/bundles/angular2.dev.js',
			'node_modules/angular2/bundles/router.dev.js',
			'node_modules/angular2/node_modules/zone.js/dist/jasmine-patch.js',
			'node_modules/angular2/bundles/http.dev.js',
			'node_modules/angular2/bundles/test_lib.dev.js',
			// Sources and specs
			// Loaded through systemjs, in `test.js`
			{
				pattern: 'dist/**',
				included: false,
				watched: false
			},
			'test.js'
		],
		exclude: [],
		customLaunchers: SAUCE_LAUNCHERS,
		browsers: [
			'Chrome'
		],
		sauceLabs: sauceLabsConfig 
	});
};
@@ -71,16 +71,52 @@
 .conf.js
+%0Aimport assign from 'object-assign';
 %0A%0Aimport
@@ -160,16 +160,38 @@
 nfig';%0A%0A
+let karmaConfig = %7B%7D;%0A
 let sauc
@@ -640,61 +640,210 @@
 ER;%0A
-%7D%0A%0Aexport default function (config) %7B%0A%09config.set(
+%09// TODO: remove once SauceLabs supports websockets.%0A%09// This speeds up the capturing a bit, as browsers don't even try to use websocket.%0A%09karmaConfig.transports = %5B'polling'%5D;%0A%7D%0A%0Aassign(karmaConfig, 
 %7B%0A
-%09
 %09fra
@@ -853,17 +853,16 @@
 orks: %5B%0A
-%09
 %09%09'jasmi
@@ -865,22 +865,20 @@
 asmine'%0A
-%09
 %09%5D,%0A
-%09
 %09files: 
@@ -879,17 +879,16 @@
 iles: %5B%0A
-%09
 %09%09'node_
@@ -914,25 +914,24 @@
 6-shim.js',%0A
-%09
 %09%09'node_modu
@@ -1047,17 +1047,16 @@
  traces%0A
-%09
 %09%09'node_
@@ -1092,33 +1092,32 @@
 lar2.dev.js',%0A%09%09
-%09
 'node_modules/an
@@ -1139,33 +1139,32 @@
 router.dev.js',%0A
-%09
 %09%09'node_modules/
@@ -1211,33 +1211,32 @@
 ne-patch.js',%0A%09%09
-%09
 'node_modules/an
@@ -1264,17 +1264,16 @@
 ev.js',%0A
-%09
 %09%09'node_
@@ -1317,17 +1317,16 @@
 .js',%0A%09%09
-%09
 // Sourc
@@ -1338,17 +1338,16 @@
 d specs%0A
-%09
 %09%09// Loa
@@ -1387,12 +1387,10 @@
 %60%0A%09%09
-%09
 %7B%0A
-%09
 %09%09%09p
@@ -1411,17 +1411,16 @@
 **',%0A%09%09%09
-%09
 included
@@ -1428,17 +1428,16 @@
  false,%0A
-%09
 %09%09%09watch
@@ -1452,13 +1452,11 @@
 e%0A%09%09
-%09
 %7D,%0A
-%09
 %09%09't
@@ -1463,22 +1463,20 @@
 est.js'%0A
-%09
 %09%5D,%0A
-%09
 %09exclude
@@ -1481,17 +1481,16 @@
 de: %5B%5D,%0A
-%09
 %09customL
@@ -1516,17 +1516,16 @@
 NCHERS,%0A
-%09
 %09browser
@@ -1529,17 +1529,16 @@
 sers: %5B%0A
-%09
 %09%09'Chrom
@@ -1544,14 +1544,12 @@
 me'%0A
-%09
 %09%5D,%0A
-%09
 %09sau
@@ -1573,15 +1573,76 @@
 Config %0A
-%09
 %7D
+);%0A%0Aexport default function (config) %7B%0A%09config.set(karmaConfig
 );%0A%7D;

set transports to pooling to speed up sauce's browser capturing on Travis