<commit_before>'use strict';

/* global process */

let chromeFlags = [];

if (process.version.startsWith('v14.')) {
  // See https://github.com/puppeteer/puppeteer/issues/5719
  console.warn(
    'Using system Chrome instead of Puppeteer due to issue with Node 14'
  );
} else {
  process.env.CHROME_BIN = require('puppeteer').executablePath();
}

// On Travis and in Docker, the tests run as root, so the sandbox must be
// disabled.
if (process.env.TRAVIS || process.env.RUNNING_IN_DOCKER) {
  chromeFlags = ['--no-sandbox'];
}

if (process.env.RUNNING_IN_DOCKER) {
  // Disable `/dev/shm` usage as this can cause Chrome to fail to load large
  // HTML pages, such as the one Karma creates with all the tests loaded.
  //
  // See https://github.com/GoogleChrome/puppeteer/issues/1834 and
  // https://github.com/karma-runner/karma-chrome-launcher/issues/198.
  chromeFlags.push('--disable-dev-shm-usage');

  // Use Chromium from Alpine packages. The one that Puppeteer downloads won't
  // load in Alpine.
  process.env.CHROME_BIN = 'chromium-browser';
}

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: ['browserify', 'mocha', 'chai', 'sinon'],

    // list of files / patterns to load in the browser
    files: [
      {
        pattern: './settings.json',
        included: false,
      },
      './bootstrap.js',
      './background/*.js',
    ],

    // list of files to exclude
    exclude: [],

    // preprocess matching files before serving them to the browser
    // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
    preprocessors: {
      '../src/background/*.js': ['browserify'],
      './**/*.js': ['browserify'],
    },

    browserify: {
      debug: true,
      configure: function (bundle) {
        bundle.transform('babelify', {
          // Use the "env" preset without any browsers listed, overriding the
          // defaults in .babelrc to enable ES2015 => ES5 transformation for all
          // language features.
          presets: ['@babel/preset-env'],
          plugins: [['mockable-imports', { excludeDirs: ['tests'] }]],
        });
      },
    },

    mochaReporter: {
      // Display a helpful diff when comparing complex objects
      // See https://www.npmjs.com/package/karma-mocha-reporter#showdiff
      showDiff: true,
      // Only show the total test counts and details for failed tests
      output: 'minimal',
    },

    // Use https://www.npmjs.com/package/karma-mocha-reporter
    // for more helpful rendering of test failures
    reporters: ['mocha'],

    // web server port
    port: 9877,

    // 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,

    // start these browsers<commit_msg>Use same compilation settings in tests and bundle build<commit_after>'use strict';

/* global __dirname, process */

let chromeFlags = [];

if (process.version.startsWith('v14.')) {
  // See https://github.com/puppeteer/puppeteer/issues/5719
  console.warn(
    'Using system Chrome instead of Puppeteer due to issue with Node 14'
  );
} else {
  process.env.CHROME_BIN = require('puppeteer').executablePath();
}

// On Travis and in Docker, the tests run as root, so the sandbox must be
// disabled.
if (process.env.TRAVIS || process.env.RUNNING_IN_DOCKER) {
  chromeFlags = ['--no-sandbox'];
}

if (process.env.RUNNING_IN_DOCKER) {
  // Disable `/dev/shm` usage as this can cause Chrome to fail to load large
  // HTML pages, such as the one Karma creates with all the tests loaded.
  //
  // See https://github.com/GoogleChrome/puppeteer/issues/1834 and
  // https://github.com/karma-runner/karma-chrome-launcher/issues/198.
  chromeFlags.push('--disable-dev-shm-usage');

  // Use Chromium from Alpine packages. The one that Puppeteer downloads won't
  // load in Alpine.
  process.env.CHROME_BIN = 'chromium-browser';
}

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: ['browserify', 'mocha', 'chai', 'sinon'],

    // list of files / patterns to load in the browser
    files: [
      {
        pattern: './settings.json',
        included: false,
      },
      './bootstrap.js',
      './background/*.js',
    ],

    // list of files to exclude
    exclude: [],

    // preprocess matching files before serving them to the browser
    // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
    preprocessors: {
      '../src/background/*.js': ['browserify'],
      './**/*.js': ['browserify'],
    },

    browserify: {
      debug: true,
      configure: function (bundle) {
        bundle.transform('babelify', {
          plugins: [['mockable-imports', { excludeDirs: ['tests'] }]],

          // Enable Babel to load configuration from the `.babelrc` file when
          // processing source files outside of the `tests/` directory.
          root: `${__dirname}/../`,
        });
      },
    },

    mochaReporter: {
      // Display a helpful diff when comparing complex objects
      // See https://www.npmjs.com/package/karma-mocha-reporter#showdiff
      showDiff: true,
      // Only show the total test counts and details for failed tests
      output: 'minimal',
    },

    // Use https://www.npmjs.com/package/karma-mocha-reporter
    // for more helpful rendering of test failures
    reporters: ['mocha'],

    // web server port
    port: 9877,

    // 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,

    // start these browsers
{'fraction_non_alphanumeric': 0.13249260470185273, 'fraction_numerical': 0.006694690954382687, 'mean_word_length': 2.625282167042889, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 14, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1165725', 'n_tokens_mistral': 2020, 'n_tokens_neox': 1908, 'n_words': 564}