<commit_before>// @flow weak

const path = require('path');
const argv = process.argv.slice(2);
const opts = {
  grep: undefined,
  watch: false,
};

argv.forEach((arg) => {
  if (/^--grep=/.test(arg)) {
    opts.grep = arg.replace('--grep=', '').trim();
  }

  if (/^--watch/.test(arg)) {
    opts.watch = true;
  }
});

// Karma configuration
module.exports = function setKarmaConfig(config) {
  config.set({
    autoWatch: opts.watch,
    basePath: '../',
    browsers: ['PhantomJS'],
    client: {
      mocha: {
        grep: opts.grep,
      },
    },
    colors: true,
    frameworks: ['mocha'],
    files: [
      'node_modules/babel-polyfill/dist/polyfill.js',
      {
        pattern: 'test/karma.tests.js',
        watched: opts.watch,
        served: true,
        included: true,
      },
    ],
    plugins: [
      'karma-phantomjs-launcher',
      'karma-firefox-launcher',
      'karma-mocha',
      'karma-sourcemap-loader',
      'karma-webpack',<commit_msg>[Tests] Attempt to fix phantomjs disconnect issues on travis<commit_after>// @flow weak

const path = require('path');
const argv = process.argv.slice(2);
const opts = {
  grep: undefined,
  watch: false,
};

argv.forEach((arg) => {
  if (/^--grep=/.test(arg)) {
    opts.grep = arg.replace('--grep=', '').trim();
  }

  if (/^--watch/.test(arg)) {
    opts.watch = true;
  }
});

// Karma configuration
module.exports = function setKarmaConfig(config) {
  config.set({
    autoWatch: opts.watch,
    basePath: '../',
    browsers: ['PhantomJS'],
    // to avoid DISCONNECTED messages on travis
    browserDisconnectTimeout: 10000, // default 2000
    browserDisconnectTolerance: 1, // default 0
    browserNoActivityTimeout: 60000, // default 10000
    client: {
      mocha: {
        grep: opts.grep,
      },
    },
    colors: true,
    frameworks: ['mocha'],
    files: [
      'node_modules/babel-polyfill/dist/polyfill.js',
      {
        pattern: 'test/karma.tests.js',
        watched: opts.watch,
        served: true,
        included: true,
      },
    ],
    plugins: [
      'karma-phantomjs-launcher',
      'karma-firefox-launcher',
      'karma-mocha',
      'karma-sourcemap-loader',
      'karma-webpack',
{'fraction_non_alphanumeric': 0.1705989110707804, 'fraction_numerical': 0.010435571687840291, 'mean_word_length': 2.3767228177641653, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5243165', 'n_tokens_mistral': 800, 'n_tokens_neox': 754, 'n_words': 145}