DIR = if process.env.CI then 'dist' else 'build'
LIB_FILE = if process.env.minified then "#{DIR}/simplybind.js" else "#{DIR}/simplybind.debug.js"


module.exports = (config)-> config.set
	basePath: '../'
	client: captureConsole: true unless process.env.sauce
	browserConsoleLogOptions: level:'log', terminal:true
	
	files: [
		LIB_FILE
		'node_modules/jquery/dist/jquery.min.js'
		'test/testHelpers.js'
		'test/browser.js'
	]
	exclude: [
		'**/*.git'
	]

	preprocessors: {"#{LIB_FILE}":'coverage'} if process.env.coverage
	
	frameworks: ['mocha', 'chai']

	reporters: do ()->
		reporters = ['mocha']
		reporters.push('coverage') if process.env.coverage
		reporters.push('saucelabs') if process.env.sauce
		return reporters
	
	mochaReporter: 
		output: 'minimal'

	coverageReporter:
		type: 'lcov'
		dir: './coverage/'
		subdir: 'browser'
	
	electronOpts:
		show: false

	port: 9876
	colors: true
	logLevel: config.LOG_INFO
	# autoWatch: if process.env.sauce then false else true
	# autoWatchBatchDelay: 1000
	# restartOnFileChange: true
	singleRun: true
	concurrency: if process.env.sauce then 2 else 5
	captureTimeout: 1.8e5 if process.env.sauce
	browserNoActivityTimeout: 1.8e5 if process.env.sauce
	browserDisconnectTimeout: 1e4 if process.env.sauce
	browserDisconnectTolerance: 3 if process.env.sauce
	browsers: if process.env.sauce then Object.keys(require('./sauceTargets')) else ['Chrome', 'Firefox', 'Opera', 'Safari']
	customLaunchers: require('./sauceTargets')
	sauceLabs: 
		testName: 'SimplyBind Test Suite'
		recordVideo: true
		build: require('../package.json').version+'-'+Math.round(Math.random()*1e6).toString(16)
		username: 'simplybind'
		accessKey: 'eb46ffb0-e314-4150-8618-53bcf157d0d2'
