module.exports = function (karma) {
  karma.set({
    frameworks: ['browserify', 'mocha', 'chai'],

    files: [
      'src/**/*.js',
      'test/**/*.spec.js',
    ],

    preprocessors: {
      'src/**/*.js': ['browserify'],
      'test/**/*.spec.js': ['browserify'],
    },

    browserify: {
      debug: true,
      transform: [
        ['babelify', {
          presets: ['es2015'],
          sourceMapsAbsolute: true,
        }],
        ['browserify-istanbul', {
          ignore: ['test/**', '**/node_modules/**'],
          instrumenterConfig: {
            embedSource: true,
          },
        }],
      ],
    },

    autoWatch: false,
    colors: true,
    concurrency: 5,
    singleRun: true,

    browserDisconnectTimeout: 60 * 1000,
    browserDisconnectTolerance: 1,
    browserNoActivityTimeout: 60 * 1000,
    captureTimeout: 4 * 60 * 1000,
  });

  if (process.env.TRAVIS) {
    const customLaunchers = require('./saucelabs-browsers');

    karma.set({
      browsers: Object.keys(customLaunchers),
      coverageReporter: {
        type: 'lcovonly',
      },
      customLaunchers,
      reporters: ['progress', 'saucelabs', 'coverage', 'coveralls'],
      sauceLabs: {
        testName: 'ScrollReveal',
        build: process.env.TRAVIS_BUILD_NUMBER || 'manual',
        tunnelIdentifier: process.env.TRAVIS_BUILD_NUMBER || 'autoGeneratedTunnelID',
        recordVideo: true,
      },
    });

  } else {
    process.env.PHANTOMJS_BIN = './node_modules/phantomjs-prebuilt/bin/phantomjs';
    karma.set({
      browsers: ['PhantomJS'],
      coverageReporter: {
        type: 'lcov',
        dir: 'coverage/',
      },
      reporters: ['progress', 'coverage'],
    });
  }
};

module.exports = function (karma) {
  karma.set({
    frameworks: ['browserify', 'mocha', 'chai'],

    files: [
      'src/**/*.js',
      'test/**/*.spec.js',
    ],

    preprocessors: {
      'src/**/*.js': ['browserify'],
      'test/**/*.spec.js': ['browserify'],
    },

    browserify: {
      debug: true,
      transform: [
        ['babelify', {
          presets: ['es2015'],
          sourceMapsAbsolute: true,
        }],
        ['browserify-istanbul', {
          ignore: ['test/**', '**/node_modules/**'],
          instrumenterConfig: {
            embedSource: true,
          },
        }],
      ],
    },

    autoWatch: false,
    colors: true,
    concurrency: 5,
    logLevel: karma.LOG_DISABLE,
    singleRun: true,

    browserDisconnectTimeout: 60 * 1000,
    browserDisconnectTolerance: 1,
    browserNoActivityTimeout: 60 * 1000,
    captureTimeout: 4 * 60 * 1000,
  });

  if (process.env.TRAVIS) {
    const customLaunchers = require('./saucelabs-browsers');

    karma.set({
      browsers: Object.keys(customLaunchers),
      coverageReporter: {
        type: 'lcovonly',
      },
      customLaunchers,
      reporters: ['progress', 'saucelabs', 'coverage', 'coveralls'],
      sauceLabs: {
        testName: 'ScrollReveal',
        build: process.env.TRAVIS_BUILD_NUMBER || 'manual',
        tunnelIdentifier: process.env.TRAVIS_BUILD_NUMBER || 'autoGeneratedTunnelID',
        recordVideo: true,
      },
    });

  } else {
    process.env.PHANTOMJS_BIN = './node_modules/phantomjs-prebuilt/bin/phantomjs';
    karma.set({
      browsers: ['PhantomJS'],
      coverageReporter: {
        type: 'lcov',
        dir: 'coverage/',
      },
      reporters: ['progress', 'coverage'],
    });
  }
};

disable karma log