<commit_before>/**
 * Copyright (c) 2015-present, Facebook, Inc.
 * All rights reserved.
 *
 * This source code is licensed under the BSD-style license found in the
 * LICENSE file in the root directory of this source tree. An additional grant
 * of patent rights can be found in the PATENTS file in the same directory.
 *
 * @providesModule Linking
 * @flow
 */
'use strict';

const NativeEventEmitter = require('NativeEventEmitter');
const NativeModules = require('NativeModules');
const Platform = require('Platform');

const invariant = require('fbjs/lib/invariant');

const LinkingManager = Platform.OS === 'android' ?
  NativeModules.IntentAndroid : NativeModules.LinkingManager;

/**
 *

 *
Projects with Native Code Only

 *

 *     This section only applies to projects made with react-native init
 *     or to those made with Create React Native App which have since ejected. For
 *     more information about ejecting, please see
 *     the guide on
 *     the Create React Native App repository.
 *

 *

 *
 * `Linking` gives you a general interface to interact with both incoming
 * and outgoing app links.
 *
 * ### Basic Usage
 *
 * #### Handling deep links
 *
 * If your app was launched from an external url registered to your app you can
 * access and handle it from any component you want with
 *
 * ```
 * componentDidMount() {
 *   Linking.getInitialURL().then((url) => {
 *     if (url) {
 *       console.log('Initial url is: ' + url);
 *     }
 *   }).catch(err => console.error('An error occurred', err));
 * }
 * ```
 *
 * NOTE: For instructions on how to add support for deep linking on Android,
 * refer to [Enabling Deep Links for App Content - Add Intent Filters for Your Deep Links](http://developer.android.com/training/app-indexing/deep-linking.html#adding-filters).
 *
 * If you wish to receive the intent in an existing instance of MainActivity,
 * you may set the `launchMode` of MainActivity to `singleTask` in
 * `AndroidManifest.xml`. See [`<activity>`](http://developer.android.com/guide/topics/manifest/activity-element.html)
 * documentation for more information.
 *
 * ```
 * <activity
 *   android:name=".MainActivity"
 *   android:launchMode="singleTask">
 * ```
 *
 * NOTE: On iOS you'll need to link `RCTLinking` to your project by following
 * the steps described [here](docs/linking-libraries-ios.html#manual-linking).
 * In case you also want to listen to incoming app links during your app's
 * execution you'll need to add the following lines to your `*AppDelegate.m`:
 *
 * ```
 * #import <React/RCTLinkingManager.h>
 *
 * - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
 *   sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
 * {
 *   return [RCTLinkingManager application:application openURL:url
 *                       sourceApplication:sourceApplication annotation:annotation];
 * }
 *
 * // Only if your app is using [Universal Links](https://developer.apple.com/library/prerelease/ios/documentation/General/Conceptual/AppSearch/UniversalLinks.html).
 * - (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity
 *  restorationHandler:(void (^)(NSArray * _Nullable))restorationHandler
 * {
 *  return [RCTLinkingManager application:application
 *                   continueUserActivity:userActivity
 *                     restorationHandler:restorationHandler];
 * }
 *
 * ```
 *
 * And then on your React component you'll be able to listen to the events on
 * `Linking` as follows
 *
 * ```
 * componentDidMount() {
 *   Linking.addEventListener('url', this._handleOpenURL);
 * },
 * componentWillUnmount() {
 *   Linking.removeEventListener('url', this._handleOpenURL);
 * },
 * _handleOpenURL(event) {
 *   console.log(event.url);
 * }
 * ```
 * #### Opening external links
 *
 * To start the corresponding activity for a link (web URL, email, contact etc.), call
 *
 * ```
 * Linking.openURL(url).catch(err => console.error('An error occurred', err));
 * ```
 *
 * If you want to check if any installed app can handle a given URL beforehand you can call
 * ```
 * Linking.canOpenURL(url).then(supported => {
 *   if (!supported) {
 *     console.log('Can\'t handle url: ' + url);
 *   } else {
 *     return Linking.openURL(url);
 *   }
 * }).catch(err => console.error('An error occurred', err));
 * ```
 */
class Linking extends NativeEventEmitter {

  constructor() {
    super(LinkingManager);
  }

  /**
   * Add a handler to Linking changes by listening to the `url` event type
   * and providing the handler
   */
  addEventListener(type: string, handler: Function) {
    this.addListener(type, handler);
  }

  /**
   * Remove a handler by passing the `url` event type and the handler
   */
  removeEventListener(type: string, handler: Function ) {
    this.removeListener(type, handler);
  }

  /**
   * Try to open the given `url` with any of the installed apps.
   *
   * You can use other URLs, like a location (e.g. "geo:37.484847,-122.148386" on Android
   * or "http://maps.apple.com/?ll=37.484847,-122.148386" on iOS), a contact,
   * or any other URL that can be opened with the installed apps.
   *
   * NOTE: This method will fail if the system doesn't know how to open the specified URL.
   * If you're passing in a non-http(s) URL, it's best to check {@code canOpenURL} first.
   *
   * NOTE: For web URLs, the protocol ("http://", "https://") must be set accordingly!
   */
  openURL(url: string): Promise<any> {
    this._validateURL(url);
    return LinkingManager.openURL(url);
  }

  /**
   * Determine whether or not an installed app can handle a given URL.
   *
   * NOTE: For web URLs, the protocol ("http://", "https://") must be set accordingly!
   *
   * NOTE: As of iOS 9, your app needs to provide the `LSApplicationQueriesSchemes` key
   * inside `Info.plist` or canOpenURL will always return false.
   *
   * @param URL the URL to open
   */
  canOpenURL(url: string): Promise<boolean> {
    this._validateURL(url);
    return LinkingManager.canOpenURL(url);
  }

  /**
   * If the app launch was triggered by an app link,
   * it will give the link url, otherwise it will give `null`
   *
   * NOTE: To support deep linking on Android, refer http://developer.android.com/training/app-indexing/deep-linking.html#handling-intents
   */
  getInitialURL(): Promise<?string> {
    return LinkingManager.getInitialURL();
  }

  _validateURL(url: string) {
    invariant(
      typeof url === 'string',
      'Invalid URL: should be a string. Was: ' + url
    );
    invariant(
      url,
      'Invalid URL: cannot be empty'
    );
  }
}

module.exports = new Linking();
<commit_msg>update docs for Linking.openURL<commit_after>/**
 * Copyright (c) 2015-present, Facebook, Inc.
 * All rights reserved.
 *
 * This source code is licensed under the BSD-style license found in the
 * LICENSE file in the root directory of this source tree. An additional grant
 * of patent rights can be found in the PATENTS file in the same directory.
 *
 * @providesModule Linking
 * @flow
 */
'use strict';

const NativeEventEmitter = require('NativeEventEmitter');
const NativeModules = require('NativeModules');
const Platform = require('Platform');

const invariant = require('fbjs/lib/invariant');

const LinkingManager = Platform.OS === 'android' ?
  NativeModules.IntentAndroid : NativeModules.LinkingManager;

/**
 *

 *
Projects with Native Code Only

 *

 *     This section only applies to projects made with react-native init
 *     or to those made with Create React Native App which have since ejected. For
 *     more information about ejecting, please see
 *     the guide on
 *     the Create React Native App repository.
 *

 *

 *
 * `Linking` gives you a general interface to interact with both incoming
 * and outgoing app links.
 *
 * ### Basic Usage
 *
 * #### Handling deep links
 *
 * If your app was launched from an external url registered to your app you can
 * access and handle it from any component you want with
 *
 * ```
 * componentDidMount() {
 *   Linking.getInitialURL().then((url) => {
 *     if (url) {
 *       console.log('Initial url is: ' + url);
 *     }
 *   }).catch(err => console.error('An error occurred', err));
 * }
 * ```
 *
 * NOTE: For instructions on how to add support for deep linking on Android,
 * refer to [Enabling Deep Links for App Content - Add Intent Filters for Your Deep Links](http://developer.android.com/training/app-indexing/deep-linking.html#adding-filters).
 *
 * If you wish to receive the intent in an existing instance of MainActivity,
 * you may set the `launchMode` of MainActivity to `singleTask` in
 * `AndroidManifest.xml`. See [`<activity>`](http://developer.android.com/guide/topics/manifest/activity-element.html)
 * documentation for more information.
 *
 * ```
 * <activity
 *   android:name=".MainActivity"
 *   android:launchMode="singleTask">
 * ```
 *
 * NOTE: On iOS you'll need to link `RCTLinking` to your project by following
 * the steps described [here](docs/linking-libraries-ios.html#manual-linking).
 * In case you also want to listen to incoming app links during your app's
 * execution you'll need to add the following lines to your `*AppDelegate.m`:
 *
 * ```
 * #import <React/RCTLinkingManager.h>
 *
 * - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
 *   sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
 * {
 *   return [RCTLinkingManager application:application openURL:url
 *                       sourceApplication:sourceApplication annotation:annotation];
 * }
 *
 * // Only if your app is using [Universal Links](https://developer.apple.com/library/prerelease/ios/documentation/General/Conceptual/AppSearch/UniversalLinks.html).
 * - (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity
 *  restorationHandler:(void (^)(NSArray * _Nullable))restorationHandler
 * {
 *  return [RCTLinkingManager application:application
 *                   continueUserActivity:userActivity
 *                     restorationHandler:restorationHandler];
 * }
 *
 * ```
 *
 * And then on your React component you'll be able to listen to the events on
 * `Linking` as follows
 *
 * ```
 * componentDidMount() {
 *   Linking.addEventListener('url', this._handleOpenURL);
 * },
 * componentWillUnmount() {
 *   Linking.removeEventListener('url', this._handleOpenURL);
 * },
 * _handleOpenURL(event) {
 *   console.log(event.url);
 * }
 * ```
 * #### Opening external links
 *
 * To start the corresponding activity for a link (web URL, email, contact etc.), call
 *
 * ```
 * Linking.openURL(url).catch(err => console.error('An error occurred', err));
 * ```
 *
 * If you want to check if any installed app can handle a given URL beforehand you can call
 * ```
 * Linking.canOpenURL(url).then(supported => {
 *   if (!supported) {
 *     console.log('Can\'t handle url: ' + url);
 *   } else {
 *     return Linking.openURL(url);
 *   }
 * }).catch(err => console.error('An error occurred', err));
 * ```
 */
class Linking extends NativeEventEmitter {

  constructor() {
    super(LinkingManager);
  }

  /**
   * Add a handler to Linking changes by listening to the `url` event type
   * and providing the handler
   */
  addEventListener(type: string, handler: Function) {
    this.addListener(type, handler);
  }

  /**
   * Remove a handler by passing the `url` event type and the handler
   */
  removeEventListener(type: string, handler: Function ) {
    this.removeListener(type, handler);
  }

  /**
   * Try to open the given `url` with any of the installed apps.
   *
   * You can use other URLs, like a location (e.g. "geo:37.484847,-122.148386" on Android
   * or "http://maps.apple.com/?ll=37.484847,-122.148386" on iOS), a contact,
   * or any other URL that can be opened with the installed apps.
   *
   * The method returns a `Promise` object. If the user confirms the open dialog or the
   * url automatically opens, the promise is resolved.  If the user cancels the open dialog
   * or there are no registered applications for the url, the promise is rejected.
   *
   * NOTE: This method will fail if the system doesn't know how to open the specified URL.
   * If you're passing in a non-http(s) URL, it's best to check {@code canOpenURL} first.
   *
   * NOTE: For web URLs, the protocol ("http://", "https://") must be set accordingly!
   */
  openURL(url: string): Promise<any> {
    this._validateURL(url);
    return LinkingManager.openURL(url);
  }

  /**
   * Determine whether or not an installed app can handle a given URL.
   *
   * NOTE: For web URLs, the protocol ("http://", "https://") must be set accordingly!
   *
   * NOTE: As of iOS 9, your app needs to provide the `LSApplicationQueriesSchemes` key
   * inside `Info.plist` or canOpenURL will always return false.
   *
   * @param URL the URL to open
   */
  canOpenURL(url: string): Promise<boolean> {
    this._validateURL(url);
    return LinkingManager.canOpenURL(url);
  }

  /**
   * If the app launch was triggered by an app link,
   * it will give the link url, otherwise it will give `null`
   *
   * NOTE: To support deep linking on Android, refer http://developer.android.com/training/app-indexing/deep-linking.html#handling-intents
   */
  getInitialURL(): Promise<?string> {
    return LinkingManager.getInitialURL();
  }

  _validateURL(url: string) {
    invariant(
      typeof url === 'string',
      'Invalid URL: should be a string. Was: ' + url
    );
    invariant(
      url,
      'Invalid URL: cannot be empty'
    );
  }
}

module.exports = new Linking();
<|endoftext|>


<commit_before>// Karma configuration
// Generated on Sat Mar 28 2015 02:55:40 GMT-0400 (EDT)

module.exports = (config) => {
  let c = {

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

    // list of files / patterns to load in the browser
    files: [
      'node_modules/sinon/pkg/sinon.js',
      'spec/**/*.spec.+(jsx|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: {
      'spec/**/*.spec.+(jsx|js)': ['webpack']
    },

    // test results reporter to use
    // possible values: 'dots', 'progress'
    // available reporters: https://npmjs.org/browse/keyword/karma-reporter
    reporters: ['spec'],

    // web server port
    port: 9876,

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

    // start these browsers
    // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
    browsers: ['Chrome'],

    customLaunchers: {
      ChromeTravis: {
        base: 'Chrome',
        flags: ['--no-sandbox']
      }
    },

    // Continuous Integration mode
    // if true, Karma captures browsers, runs the tests and exits
    singleRun: true,

    plugins: [
      'karma-mocha',
      'karma-chai',
      'karma-webpack',
      'karma-spec-reporter',
      'karma-chrome-launcher'
    ],

    webpack: {
      module: {
        loaders: [{
          test: /\.js(x)?/,
          loaders: ['babel-loader']
        }]
      },
      resolve: {
        extensions: ['', '.js', '.jsx']
      }
    },

    webpackMiddleware: {
      noInfo: true
    }

  }

  if (process.env.TRAVIS) {
    c.browsers = ['ChromeTravis']
  }

  config.set(c)
}
<commit_msg>Increase mocha timeout<commit_after>// Karma configuration
// Generated on Sat Mar 28 2015 02:55:40 GMT-0400 (EDT)

module.exports = (config) => {
  let c = {

    // base path that will be used to resolve all patterns (eg. files, exclude)
    basePath: '',

    client: {
      mocha: {
        timeout: 5000
      }
    },

    // frameworks to use
    // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
    frameworks: ['mocha', 'chai'],

    // list of files / patterns to load in the browser
    files: [
      'node_modules/sinon/pkg/sinon.js',
      'spec/**/*.spec.+(jsx|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: {
      'spec/**/*.spec.+(jsx|js)': ['webpack']
    },

    // test results reporter to use
    // possible values: 'dots', 'progress'
    // available reporters: https://npmjs.org/browse/keyword/karma-reporter
    reporters: ['spec'],

    // web server port
    port: 9876,

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

    // start these browsers
    // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
    browsers: ['Chrome'],

    customLaunchers: {
      ChromeTravis: {
        base: 'Chrome',
        flags: ['--no-sandbox']
      }
    },

    // Continuous Integration mode
    // if true, Karma captures browsers, runs the tests and exits
    singleRun: true,

    plugins: [
      'karma-mocha',
      'karma-chai',
      'karma-webpack',
      'karma-spec-reporter',
      'karma-chrome-launcher'
    ],

    webpack: {
      module: {
        loaders: [{
          test: /\.js(x)?/,
          loaders: ['babel-loader']
        }]
      },
      resolve: {
        extensions: ['', '.js', '.jsx']
      }
    },

    webpackMiddleware: {
      noInfo: true
    }

  }

  if (process.env.TRAVIS) {
    c.browsers = ['ChromeTravis']
  }

  config.set(c)
}
<|endoftext|>


<commit_before>(function ( $ ) {
    var PLUGIN_IDENTIFIER = 'ytLoad';
    var settings;
    var ajaxError;

    function injectProgressBar() {
        var $progressBar = $('#'+settings.progressBarId);

        if ($progressBar.length == 0) {
            $('body').append('

');
            $progressBar = $('#'+settings.progressBarId);
        }

        return $progressBar;
    }

    function completeProgressBar() {
        var $progressBar = $('#'+settings.progressBarId);

        $progressBar.remove();
        settings.onComplete();
    }

    var methods = {
        init: function(options) {
            ajaxError = false;

            settings = $.extend({
                registerAjaxHandlers: true,
                startPercentage: 30,
                startDuration: null,
                completeDuration: 100,
                fadeDelay: 200,
                fadeDuration: 200,
                progressBarId: PLUGIN_IDENTIFIER,
                onStart: function() { },
                onComplete: function() { },
                onError: function() { }
            }, options);

            if(settings.registerAjaxHandlers) {
                $(document).on('ajaxStart.'+PLUGIN_IDENTIFIER, function() {
                    methods.start();
                });

                $(document).on('ajaxComplete.'+PLUGIN_IDENTIFIER, function() {
                    if($.active < 2) {
                        methods.complete();
                    }
                });

                $(document).on('ajaxError.'+PLUGIN_IDENTIFIER, function() {
                    methods.error();
                });
            }
        },

        start: function() {
            var $progressBar = injectProgressBar();
            ajaxError = false;

            methods.setProgress(settings.startPercentage, settings.startDuration);
            settings.onStart();
        },

        complete: function() {
            var $progressBar = injectProgressBar();
            methods.setProgress(100, settings.completeDuration, function() {
                $progressBar.delay(settings.fadeDelay);
                $progressBar.fadeOut({
                    duration: settings.fadeDuration
                });
            });
        },

        setProgress: function(progress, duration, finished) {
            var $progressBar = injectProgressBar();
            if(!duration) {
                duration = progress * 5;
            }
            var width = (101 / 100) * progress;
            width = Math.round(width * 100) / 100;

            if(width > 99) {
                // TODO: Bug in jquery.transit? Further research needed to submit proper bug report.
                var doubleCompleteHack = false;
            }

            $progressBar.transit({
                width: width+'%',
                duration: duration,
                complete: function() {
                    if(width > 99) {
                        if(doubleCompleteHack == true) {
                            completeProgressBar();
                        }
                        doubleCompleteHack = true;
                    }
                    if(finished) {
                        finished();
                    }
                }
            });
        },

        error: function() {
            var $progressBar = $('#'+settings.progressBarId);
            $progressBar.addClass('error');

            settings.onError();
        },

        destroy: function() {
            if(settings.registerAjaxHandlers) {
                $(document).off('ajaxStart.'+PLUGIN_IDENTIFIER);
                $(document).off('ajaxComplete.'+PLUGIN_IDENTIFIER);
                $(document).off('ajaxError.'+PLUGIN_IDENTIFIER);
            }
            var $progressBar = $('#'+settings.progressBarId);

            if ($progressBar.length != 0) {
                $progressBar.remove();
            }
        }
    };

    $.ytLoad = function(methodOrOptions) {
        if ( methods[methodOrOptions] ) {
            return methods[ methodOrOptions ].apply( this, Array.prototype.slice.call( arguments, 1 ));
        } else if ( typeof methodOrOptions === 'object' || ! methodOrOptions ) {
            return methods.init.apply( this, arguments );
        } else {
            $.error( 'Method ' +  method + ' does not exist on jQuery.'+PLUGIN_IDENTIFIER );
        }
    };
}( jQuery ));<commit_msg>proper solution for doubleCompleteHack<commit_after>(function ( $ ) {
    var PLUGIN_IDENTIFIER = 'ytLoad';
    var settings;
    var ajaxError;

    function injectProgressBar() {
        var $progressBar = $('#'+settings.progressBarId);

        if ($progressBar.length == 0) {
            $('body').append('

');
            $progressBar = $('#'+settings.progressBarId);
        }

        return $progressBar;
    }

    var methods = {
        init: function(options) {
            ajaxError = false;

            settings = $.extend({
                registerAjaxHandlers: true,
                startPercentage: 30,
                startDuration: 200,
                completeDuration: 50,
                fadeDelay: 200,
                fadeDuration: 200,
                progressBarId: PLUGIN_IDENTIFIER,
                onStart: function() { },
                onComplete: function() { },
                onError: function() { }
            }, options);

            if(settings.registerAjaxHandlers) {
                $(document).on('ajaxStart.'+PLUGIN_IDENTIFIER, function() {
                    methods.start();
                });

                $(document).on('ajaxComplete.'+PLUGIN_IDENTIFIER, function() {
                    if($.active < 2) {
                        methods.complete();
                    }
                });

                $(document).on('ajaxError.'+PLUGIN_IDENTIFIER, function() {
                    methods.error();
                });
            }
        },

        setProgress: function(progress, duration, finished) {
            var $progressBar = injectProgressBar();
            if(!duration) {
                duration = progress * 8;
            }
            var width = (101 / 100) * progress;
            width = Math.round(width * 100) / 100;

            $progressBar.transit({
                width: width+'%',
                duration: duration,
                complete: function() {
                    if(width > 99) {
                        $progressBar.delay(settings.fadeDelay);
                        $progressBar.fadeOut({
                            duration: settings.fadeDuration,
                            complete: function() {
                                $progressBar.remove();
                            }
                        });
                        settings.onComplete();
                    }
                    if(finished) {
                        finished();
                    }
                }
            });
        },

        start: function() {
            var $progressBar = injectProgressBar();
            ajaxError = false;

            methods.setProgress(settings.startPercentage, settings.startDuration);
            settings.onStart();
        },

        complete: function() {
            var $progressBar = injectProgressBar();
            methods.setProgress(100, settings.completeDuration);
        },

        error: function() {
            var $progressBar = $('#'+settings.progressBarId);
            $progressBar.addClass('error');

            settings.onError();
        },

        destroy: function() {
            if(settings.registerAjaxHandlers) {
                $(document).off('ajaxStart.'+PLUGIN_IDENTIFIER);
                $(document).off('ajaxComplete.'+PLUGIN_IDENTIFIER);
                $(document).off('ajaxError.'+PLUGIN_IDENTIFIER);
            }
            var $progressBar = $('#'+settings.progressBarId);

            if ($progressBar.length != 0) {
                $progressBar.remove();
            }
        }
    };

    $.ytLoad = function(methodOrOptions) {
        if ( methods[methodOrOptions] ) {
            return methods[ methodOrOptions ].apply( this, Array.prototype.slice.call( arguments, 1 ));
        } else if ( typeof methodOrOptions === 'object' || ! methodOrOptions ) {
            return methods.init.apply( this, arguments );
        } else {
            $.error( 'Method ' +  method + ' does not exist on jQuery.'+PLUGIN_IDENTIFIER );
        }
    };
}( jQuery ));<|endoftext|>


<commit_before>module.exports = function(config){
  config.set({

    basePath : './',

    files : [
      'app/bower_components/angular/angular.js',
      'app/bower_components/angular-route/angular-route.js',
      'bower_components/angular-resource/angular-resource.js',
      'app/bower_components/angular-mocks/angular-mocks.js',
      'app/components/**/*.js',
      'app/grocery/**/*.js'
    ],

    autoWatch : true,

    frameworks: ['jasmine'],

    browsers : ['Chrome'],

    plugins : [
            'karma-chrome-launcher',
            'karma-firefox-launcher',
            'karma-jasmine',
            'karma-junit-reporter'
            ],

    junitReporter : {
      outputFile: 'test_out/unit.xml',
      suite: 'unit'
    }

  });
};
<commit_msg>refactoring git repo 3<commit_after>module.exports = function(config){
  config.set({

    basePath : './',

    files : [
      'app/bower_components/angular/angular.js',
      'app/bower_components/angular-route/angular-route.js',
      'bower_components/angular-resource/angular-resource.js',
      'app/bower_components/angular-mocks/angular-mocks.js',
      'app/components/**/*.js',
      'app/main/**/*.js',
      'app/grocery/**/*.js'
    ],

    autoWatch : true,

    frameworks: ['jasmine'],

    browsers : ['Chrome'],

    plugins : [
            'karma-chrome-launcher',
            'karma-firefox-launcher',
            'karma-jasmine',
            'karma-junit-reporter'
            ],

    junitReporter : {
      outputFile: 'test_out/unit.xml',
      suite: 'unit'
    }

  });
};
<|endoftext|>


<commit_before>// Karma configuration
// Generated on Mon Oct 17 2016 16:21:56 GMT+0200 (CEST)

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: ['jasmine'],

    // list of files / patterns to load in the browser
    files: [
      'test/**/*.test.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: {
      'test/**/*.test.js': ['rollup']
    },

    rollupPreprocessor: {
      format: 'iife',
      moduleName: 'sigver'
    },

    // test results reporter to use
    // possible values: 'dots', 'progress'
    // available reporters: https://npmjs.org/browse/keyword/karma-reporter
    reporters: ['spec'],

    // web server port
    port: 9876,

    // 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
    // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
    browsers: ['Chrome', 'Firefox'],

    // Continuous Integration mode
    // if true, Karma captures browsers, runs the tests and exits
    singleRun: false,

    // Concurrency level
    // how many browser should be started simultaneous
    concurrency: Infinity
  })

  /*
   * Travis options
   */
  if (process.env.TRAVIS) {
    config.browsers = ['Firefox']
    config.autoWatch = false
    config.singleRun = true
  }
}
<commit_msg>test(karma): fix karma config<commit_after>// Karma configuration
// Generated on Mon Oct 17 2016 16:21:56 GMT+0200 (CEST)

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: ['jasmine'],

    // list of files / patterns to load in the browser
    files: [
      'test/**/*test.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: {
      'test/**/*test.js': ['rollup']
    },

    rollupPreprocessor: {
      format: 'iife',
      moduleName: 'sigver'
    },

    // test results reporter to use
    // possible values: 'dots', 'progress'
    // available reporters: https://npmjs.org/browse/keyword/karma-reporter
    reporters: ['spec'],

    // web server port
    port: 9876,

    // 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
    // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
    browsers: ['Chrome', 'Firefox'],

    // Continuous Integration mode
    // if true, Karma captures browsers, runs the tests and exits
    singleRun: false,

    // Concurrency level
    // how many browser should be started simultaneous
    concurrency: Infinity
  })

  /*
   * Travis options
   */
  if (process.env.TRAVIS) {
    config.browsers = ['Firefox']
    config.autoWatch = false
    config.singleRun = true
  }
}
<|endoftext|>


<commit_before>// Karma configuration
// Generated on Tue May 16 2017 15:20:44 GMT-0400 (EDT)

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: ['jasmine', 'AAT'],

    // list of files / patterns to load in the browser
    files: [
      '**/*.html',
      'test/a11yScan.test.js',
      'baselines/**/*.json'
    ],

    // list of files to exclude
    exclude: [
      'node_modules/**/*.html',
      'HTML5/**/*.html',
      'WCAG_GENERAL/extras/**/*.html',
      'WCAG_HTML/extras/**/*.html',
      'WCAG_ARIA/extras/**/*.html',
    ],

    // preprocess matching files before serving them to the browser
    // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
    preprocessors: {
      '**/*.html': ['html2js'],
      "baselines/**/*.json": ['AAT']
    },

    // test results reporter to use
    // possible values: 'dots', 'progress'
    // available reporters: https://npmjs.org/browse/keyword/karma-reporter
    reporters: ['spec', 'AAT'],

    // web server port
    port: 9876,

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

    // enable / disable watching file and executing tests whenever any file changes
    autoWatch: true,

    // start these browsers
    // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
    browsers: ['Chrome'],

    // Continuous Integration mode
    // if true, Karma captures browsers, runs the tests and exits
    singleRun: true,

    // Concurrency level
    // how many browser should be started simultaneous
    concurrency: Infinity
  })
}
<commit_msg>Update karma.conf.js<commit_after>// Karma configuration
// Generated on Tue May 16 2017 15:20:44 GMT-0400 (EDT)

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: ['jasmine', 'AAT'],

    // list of files / patterns to load in the browser
    files: [
      '**/*.html',
      'test/a11yScan.test.js',
      'baselines/**/*.json'
    ],

    // list of files to exclude
    exclude: [
      'node_modules/**/*.html',
      'HTML5/**/*.html',
      'WCAG_GENERAL/extras/**/*.html',
      'WCAG_HTML/extras/**/*.html',
      'WCAG_ARIA/extras/**/*.html',
    ],

    // preprocess matching files before serving them to the browser
    // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
    preprocessors: {
      '**/*.html': ['html2js'],
      "baselines/**/*.json": ['AAT']
    },

    // test results reporter to use
    // possible values: 'dots', 'progress'
    // available reporters: https://npmjs.org/browse/keyword/karma-reporter
    reporters: ['spec', 'AAT'],

    // web server port
    port: 9876,

    // enable / disable colors in the output (reporters and logs)
    colors: false,

    // level of logging
    // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
    logLevel: config.LOG_ERROR,

    // enable / disable watching file and executing tests whenever any file changes
    autoWatch: true,

    // start these browsers
    // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
    browsers: ['Chrome'],

    // Continuous Integration mode
    // if true, Karma captures browsers, runs the tests and exits
    singleRun: true,

    // Concurrency level
    // how many browser should be started simultaneous
    concurrency: Infinity
  })
}
<|endoftext|>


<commit_before>// Karma configuration
// Generated on Mon Aug 22 2016 22:44:18 GMT-0300 (BRT)

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: ['jasmine'],
		// list of files / patterns to load in the browser
		files: [
      'bower_components/jquery/dist/jquery.min.js',
      'bower_components/angular/angular.js',
      'node_modules/angular-mocks/angular-mocks.js',
      'bower_components/angular-ui-router/release/angular-ui-router.js',
      'bower_components/angular-aria/angular-aria.js',
      'bower_components/angular-animate/angular-animate.js',
      'bower_components/angular-material/angular-material.js',
      'beercalc.module.js',
      'beercalc.config.js',
      'beercalc.routes.js',
      'controllers/**/*.js',
			'factories/**/*.js',
      'test/**/*.js'
    ],
		// list of files to exclude
		exclude: [
      'controllers/loading-screen.controller.js'
    ],
		// preprocess matching files before serving them to the browser
		// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
		preprocessors: {
			"beercalc.routes.js": ["coverage"],
			"!(bower_components|node_modules|public|reports|test)/**/!(*.spec).js": ["coverage"],
			"**/*.html": ["ng-html2js"]
		},
		// test results reporter to use
		// possible values: 'dots', 'progress'
		// available reporters: https://npmjs.org/browse/keyword/karma-reporter
		reporters: ['coverage', 'spec'],
		coverageReporter: {
			type: "lcov",
			dir: "reports",
			subdir: "coverage",
			check: {
				global: {
					statements: 90,
					branches: 80,
					functions: 90,
					lines: 80
				}
			}
		},
		specReporter: {
			suppressErrorSummary: true,
			suppressFailed: false,
			suppressPassed: false,
			suppressSkipped: false
		},
		plugins: [
        "karma-phantomjs-launcher",
        "karma-chrome-launcher",
        "karma-jasmine",
        "karma-coverage",
        "karma-spec-reporter",
        "karma-ng-html2js-preprocessor"
    ],
		// web server port
		port: 9876,
		// 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
		// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
		browsers: ['PhantomJS'],
		// Continuous Integration mode
		// if true, Karma captures browsers, runs the tests and exits
		singleRun: true,
		// Concurrency level
		// how many browser should be started simultaneous
		concurrency: Infinity
	})
}
<commit_msg>Fix for karma test<commit_after>// Karma configuration
// Generated on Mon Aug 22 2016 22:44:18 GMT-0300 (BRT)

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: ['jasmine'],
		// list of files / patterns to load in the browser
		files: [
			'bower_components/jquery/dist/jquery.min.js',
			'bower_components/angular/angular.js',
			'node_modules/angular-mocks/angular-mocks.js',
			'bower_components/angular-ui-router/release/angular-ui-router.js',
			'bower_components/angular-aria/angular-aria.js',
			'bower_components/angular-animate/angular-animate.js',
			'bower_components/angular-material/angular-material.js',
			'config/beercalc.module.js',
			'config/beercalc.config.js',
			'config/beercalc.routes.js',
			'controllers/**/*.js',
			'factories/**/*.js',
			'test/**/*.js'
		],
		// list of files to exclude
		exclude: ['controllers/loading-screen.controller.js'],
		// preprocess matching files before serving them to the browser
		// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
		preprocessors: {
			"beercalc.routes.js": ["coverage"],
			"!(bower_components|node_modules|public|reports|test)/**/!(*.spec).js": ["coverage"],
			"**/*.html": ["ng-html2js"]
		},
		// test results reporter to use
		// possible values: 'dots', 'progress'
		// available reporters: https://npmjs.org/browse/keyword/karma-reporter
		reporters: [
			'coverage', 'spec'
		],
		coverageReporter: {
			type: "lcov",
			dir: "reports",
			subdir: "coverage",
			check: {
				global: {
					statements: 90,
					branches: 80,
					functions: 90,
					lines: 80
				}
			}
		},
		specReporter: {
			suppressErrorSummary: true,
			suppressFailed: false,
			suppressPassed: false,
			suppressSkipped: false
		},
		plugins: [
			"karma-phantomjs-launcher",
			"karma-chrome-launcher",
			"karma-jasmine",
			"karma-coverage",
			"karma-spec-reporter",
			"karma-ng-html2js-preprocessor"
		],
		// web server port
		port: 9876,
		// 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
		// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
		browsers: ['PhantomJS'],
		// Continuous Integration mode
		// if true, Karma captures browsers, runs the tests and exits
		singleRun: true,
		// Concurrency level
		// how many browser should be started simultaneous
		concurrency: Infinity
	})
}
<|endoftext|>


<commit_before>var webpack = require('webpack');

module.exports = function karma(config) {
  config.set({
    browsers: ['PhantomJS'],
    frameworks: ['mocha', 'chai', 'sinon'],
    files: ['tests.webpack.js'],
    plugins: [
      'karma-phantomjs-launcher',
      'karma-mocha',
      'karma-chai',
      'karma-sinon',
      'karma-sourcemap-loader',
      'karma-webpack',
      'karma-coverage',
      'karma-mocha-reporter'
    ],
    preprocessors: {
      'tests.webpack.js': ['webpack', 'sourcemap']
    },
    reporters: ['mocha', 'coverage'],
    webpack: {
      devtool: 'inline-source-map',
      module: {
        preLoaders: [
          {
            test: /\.js$/,
            exclude: /(__tests__|node_modules)\//,
            loader: 'isparta-instrumenter'
          }
        ],
        loaders: [
          {
            test: /\.js$/,
            loader: 'babel-loader',
            exclude: /(node_modules|lib)\//
          }
        ]
      },
      externals: {
        cheerio: 'window',
        'react/addons': true,
        'react/lib/ReactContext': true,
        'react/lib/ExecutionEnvironment': true
      },
      plugins: [
        new webpack.NormalModuleReplacementPlugin(/^debug$/g, '../__tests__/mocks/debug.js')
      ]
    },
    webpackServer: {
      noInfo: true
    },
    coverageReporter: {
      reporters: [
        {
          type: 'lcovonly',
          dir: 'coverage/',
          subdir: '.',
          file: 'lcov.info'
        },
        {
          type: 'text-summary'
        }
      ]
    }
  });
};
<commit_msg>Change isparta-instrumenter to isparta-loader<commit_after>var webpack = require('webpack');

module.exports = function karma(config) {
  config.set({
    browsers: ['PhantomJS'],
    frameworks: ['mocha', 'chai', 'sinon'],
    files: ['tests.webpack.js'],
    plugins: [
      'karma-phantomjs-launcher',
      'karma-mocha',
      'karma-chai',
      'karma-sinon',
      'karma-sourcemap-loader',
      'karma-webpack',
      'karma-coverage',
      'karma-mocha-reporter'
    ],
    preprocessors: {
      'tests.webpack.js': ['webpack', 'sourcemap']
    },
    reporters: ['mocha', 'coverage'],
    webpack: {
      devtool: 'inline-source-map',
      module: {
        preLoaders: [
          {
            test: /\.js$/,
            exclude: /(__tests__|node_modules)\//,
            loader: 'isparta-loader'
          }
        ],
        loaders: [
          {
            test: /\.js$/,
            loader: 'babel-loader',
            exclude: /(node_modules|lib)\//
          }
        ]
      },
      externals: {
        cheerio: 'window',
        'react/addons': true,
        'react/lib/ReactContext': true,
        'react/lib/ExecutionEnvironment': true
      },
      plugins: [
        new webpack.NormalModuleReplacementPlugin(/^debug$/g, '../__tests__/mocks/debug.js')
      ]
    },
    webpackServer: {
      noInfo: true
    },
    coverageReporter: {
      reporters: [
        {
          type: 'lcovonly',
          dir: 'coverage/',
          subdir: '.',
          file: 'lcov.info'
        },
        {
          type: 'text-summary'
        }
      ]
    }
  });
};
<|endoftext|>


<commit_before>const sourcemaps = !process.env.SOURCEMAPS === 'false';
const webpack = require('webpack');

function getPreprocessors() {
  const preprocessors = ['webpack'];
  if (sourcemaps) {
    preprocessors.push('sourcemap');
  }
  return {
    'test/test_index.js': preprocessors
  };
}

function getBrowserStackConfig() {
  const username = process.env.BROWSER_STACK_USERNAME;
  const accessKey = process.env.BROWSER_STACK_ACCESS_KEY;
  if (!username && !accessKey) {
    return {};
  }

  const customLaunchers = {
    bs_firefox_mac: {
      base: 'BrowserStack',
      browser: 'firefox',
      browser_version: '30',
      os: 'OS X',
      os_version: 'Yosemite'
    },
    bs_chrome_mac: {
      base: 'BrowserStack',
      browser: 'chrome',
      browser_version: '30',
      os: 'OS X',
      os_version: 'Yosemite'
    },
    bs_safari_mac: {
      base: 'BrowserStack',
      browser: 'safari',
      browser_version: '8',
      os: 'OS X',
      os_version: 'Yosemite'
    },
    bs_windows_ie: {
      base: 'BrowserStack',
      browser: 'ie',
      browser_version: '11',
      os: 'Windows',
      os_version: '8.1'
    },
    bs_iphone_5s: {
      base: 'BrowserStack',
      device: 'iPhone 6',
      os: 'ios',
      os_version: '8.3',
      browser_version: null,
      browser: 'Mobile Safari'
    },
    bs_android_nexus_7: {
      base: 'BrowserStack',
      realMobile: true,
      os: 'android',
      os_version: '4.1',
      browser: 'Android Browser',
      browser_version: null,
      device: 'Google Nexus 7'
    }
  };

  return {
    browserStack: {
      username,
      accessKey
    },
    customLaunchers,
    browsers: Object.keys(customLaunchers)
  };
}

module.exports = function (config) {
  const initialConfig = {
    browserConsoleLogOptions: {
      level: 'log'
    },
    browsers: [
      'PhantomJSWithArgs'
    ],
    browserNoActivityTimeout: 3e5,
    browserDisconnectTimeout: 3e5,
    browserDisconnectTolerance: 3,
    captureTimeout: 120000,
    client: {
      mocha: {
        timeout: 10000
      }
    },
    coverageReporter: {
      dir: '.coverage/',
      reporters: [
        {
          type: 'lcov',
          subdir: '.'
        }
      ]
    },
    customContextFile: sourcemaps ? null : 'test/context.html',
    customLaunchers: {
      PhantomJSWithArgs: {
        base: 'PhantomJS',
        options: {
          viewportSize: {
            width: 1024,
            height: 768
          }
        }
      }
    },
    files: [
      './node_modules/phantomjs-polyfill-object-assign/object-assign-polyfill.js',
      'test/test_index.js'
    ],
    frameworks: [
      'mocha'
    ],
    preprocessors: getPreprocessors(),
    reporters: [
      'mocha',
      'coverage',
      'coveralls'
    ],
    singleRun: true,
    webpack: {
      devtool: 'cheap-module-inline-source-map',
      externals: {
        'react/lib/ExecutionEnvironment': true,
        'react/lib/ReactContext': 'window',
        'react/addons': true
      },
      module: {
        exprContextCritical: false,
        rules: [
          // Run regular source code through babel
          {
            test: /\.js$/,
            exclude: /node_modules/,
            use: {
              loader: 'babel-loader',
              options: {
                plugins: [
                  'empower-assert',
                  [
                    'espower', {
                      embedAst: true
                    }
                  ],
                  [
                    'istanbul', {
                      exclude: [
                        '**/index.js',
                        '**/*.spec.js',
                        'test/test_index.js'
                      ]
                    }
                  ]
                ],
                presets: [
                  [
                    'es2015',
                    {
                      modules: false
                    }
                  ]
                ]
              }
            }
          },
          {
            test: /\.css$/,
            use: [
              'style-loader',
              'css-loader?modules&localIdentName=[name].[local]',
              'postcss-loader'
            ]
          },
          {
            test: /\.svg$/,
            use: [
              'babel-loader',
              'react-svg-loader'
            ]
          }
        ]
      },
      plugins: [
        new webpack.DefinePlugin({
          __TEST__: true
        })
      ]
    },
    webpackServer: {
      noInfo: true
    }
  };

  config.set(Object.assign({}, initialConfig, getBrowserStackConfig()));
};
<commit_msg>[test] add edge 14 / windows 10 to browser targets<commit_after>const sourcemaps = !process.env.SOURCEMAPS === 'false';
const webpack = require('webpack');

function getPreprocessors() {
  const preprocessors = ['webpack'];
  if (sourcemaps) {
    preprocessors.push('sourcemap');
  }
  return {
    'test/test_index.js': preprocessors
  };
}

function getBrowserStackConfig() {
  const username = process.env.BROWSER_STACK_USERNAME;
  const accessKey = process.env.BROWSER_STACK_ACCESS_KEY;
  if (!username && !accessKey) {
    return {};
  }

  const customLaunchers = {
    bs_firefox_mac: {
      base: 'BrowserStack',
      browser: 'firefox',
      browser_version: '45',
      os: 'OS X',
      os_version: 'Yosemite'
    },
    bs_chrome_mac: {
      base: 'BrowserStack',
      browser: 'chrome',
      browser_version: '49',
      os: 'OS X',
      os_version: 'Yosemite'
    },
    bs_safari_mac: {
      base: 'BrowserStack',
      browser: 'safari',
      browser_version: '8',
      os: 'OS X',
      os_version: 'Yosemite'
    },
    bs_ie_windows: {
      base: 'BrowserStack',
      browser: 'ie',
      browser_version: '11',
      os: 'Windows',
      os_version: '8.1'
    },
    bs_edge_windows: {
      base: 'BrowserStack',
      browser: 'edge',
      browser_version: '14',
      os: 'Windows',
      os_version: '10'
    },
    bs_iphone_5s: {
      base: 'BrowserStack',
      device: 'iPhone 6',
      os: 'ios',
      os_version: '8.3',
      browser_version: null,
      browser: 'Mobile Safari'
    },
    bs_android_nexus_7: {
      base: 'BrowserStack',
      realMobile: true,
      os: 'android',
      os_version: '4.1',
      browser: 'Android Browser',
      browser_version: null,
      device: 'Google Nexus 7'
    }
  };

  return {
    browserStack: {
      username,
      accessKey
    },
    customLaunchers,
    browsers: Object.keys(customLaunchers)
  };
}

module.exports = function (config) {
  const initialConfig = {
    browserConsoleLogOptions: {
      level: 'log'
    },
    browsers: [
      'PhantomJSWithArgs'
    ],
    browserNoActivityTimeout: 3e5,
    browserDisconnectTimeout: 3e5,
    browserDisconnectTolerance: 3,
    captureTimeout: 120000,
    client: {
      mocha: {
        timeout: 10000
      }
    },
    coverageReporter: {
      dir: '.coverage/',
      reporters: [
        {
          type: 'lcov',
          subdir: '.'
        }
      ]
    },
    customContextFile: sourcemaps ? null : 'test/context.html',
    customLaunchers: {
      PhantomJSWithArgs: {
        base: 'PhantomJS',
        options: {
          viewportSize: {
            width: 1024,
            height: 768
          }
        }
      }
    },
    files: [
      './node_modules/phantomjs-polyfill-object-assign/object-assign-polyfill.js',
      'test/test_index.js'
    ],
    frameworks: [
      'mocha'
    ],
    preprocessors: getPreprocessors(),
    reporters: [
      'mocha',
      'coverage',
      'coveralls'
    ],
    singleRun: true,
    webpack: {
      devtool: 'cheap-module-inline-source-map',
      externals: {
        'react/lib/ExecutionEnvironment': true,
        'react/lib/ReactContext': 'window',
        'react/addons': true
      },
      module: {
        exprContextCritical: false,
        rules: [
          // Run regular source code through babel
          {
            test: /\.js$/,
            exclude: /node_modules/,
            use: {
              loader: 'babel-loader',
              options: {
                plugins: [
                  'empower-assert',
                  [
                    'espower', {
                      embedAst: true
                    }
                  ],
                  [
                    'istanbul', {
                      exclude: [
                        '**/index.js',
                        '**/*.spec.js',
                        'test/test_index.js'
                      ]
                    }
                  ]
                ],
                presets: [
                  [
                    'es2015',
                    {
                      modules: false
                    }
                  ]
                ]
              }
            }
          },
          {
            test: /\.css$/,
            use: [
              'style-loader',
              'css-loader?modules&localIdentName=[name].[local]',
              'postcss-loader'
            ]
          },
          {
            test: /\.svg$/,
            use: [
              'babel-loader',
              'react-svg-loader'
            ]
          }
        ]
      },
      plugins: [
        new webpack.DefinePlugin({
          __TEST__: true
        })
      ]
    },
    webpackServer: {
      noInfo: true
    }
  };

  config.set(Object.assign({}, initialConfig, getBrowserStackConfig()));
};
<|endoftext|>


<commit_before>// http 服务器
var httpServer = function (req, res, next) {
    if (req.url.indexOf('/api/test/upload/ok') > -1) {

        res.end(JSON.stringify({
            code: 200
        }));

    } else {
        next();
    }
};

var files = [
    {
        pattern: 'lib/**/*.js',
        included: false
    },
    {
        pattern: 'src/**/*',
        included: false
    },
    {
        pattern: 'test/**/*.js',
        included: false
    },
    'lib/requirejs/config.js',
    // 加载初始化视图测试
    'karma.conf.require.js'
];

if (process.argv.slice(-1)[0].match(/--test\=(.*)$/)) {
    files[2].pattern = 'test/' + RegExp.$1;
    console.log([
        '============',
        '开始测试：' + files[2].pattern,
        '============'
    ].join('\n'));
}

// Karma configuration
// Generated on Sun Jan 24 2016 23:22:35 GMT+0800 (CST)
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: [
            'jasmine',
            'requirejs'
        ],
        // list of files / patterns to load in the browser
        files: files,
        // 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/**/*.js': 'coverage'
        },

        coverageReporter: {
            // specify a common output directory
            dir: '.',
            reporters: [
                // { type: 'html', subdir: 'report-html' },
                {
                    type: 'lcov',
                    subdir: 'coverage'
                },
                {
                    type: 'text-summary'
                }
            ]
        },
        // test results reporter to use
        // possible values: 'dots', 'progress'
        // available reporters: https://npmjs.org/browse/keyword/karma-reporter
        reporters: [
            'progress',
            // 'coverage'
        ],
        // web server port
        port: 9876,
        // 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: false,
        // start these browsers
        // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
        browsers: [
            'PhantomJS'
        ],
        // Continuous Integration mode
        // if true, Karma captures browsers, runs the tests and exits
        singleRun: true,
        // Concurrency level
        // how many browser should be started simultaneous
        concurrency: Infinity,

        middleware: ['httpServer'],
         // plugins
        plugins: ['karma-*', {
            'middleware:httpServer': [
                'factory', function () {
                    return httpServer;
                }
            ]
        }]
    });
};
<commit_msg>update: 优化karma配置<commit_after>// http 服务器
var httpServer = function (req, res, next) {
    if (req.url.indexOf('/api/test/upload/ok') > -1) {

        res.end(JSON.stringify({
            code: 200
        }));

    } else {
        next();
    }
};

var files = [
    {
        pattern: 'lib/zepto.js',
        included: false
    },
    {
        pattern: 'lib/requirejs/plugins/*.js',
        included: false
    },
    {
        pattern: 'src/**/*',
        included: false
    },
    {
        pattern: 'test/**/*.js',
        included: false
    },
    'lib/requirejs/config.js',
    // 加载初始化视图测试
    'karma.conf.require.js'
];

if (process.argv.slice(-1)[0].match(/--test\=(.*)$/)) {
    files[2].pattern = 'test/' + RegExp.$1;
    console.log([
        '============',
        '开始测试：' + files[2].pattern,
        '============'
    ].join('\n'));
}

// Karma configuration
// Generated on Sun Jan 24 2016 23:22:35 GMT+0800 (CST)
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: [
            'jasmine',
            'requirejs'
        ],
        // list of files / patterns to load in the browser
        files: files,
        // 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/**/*.js': 'coverage'
        },

        coverageReporter: {
            // specify a common output directory
            dir: '.',
            reporters: [
                // { type: 'html', subdir: 'report-html' },
                {
                    type: 'lcov',
                    subdir: 'coverage'
                },
                {
                    type: 'text-summary'
                }
            ]
        },
        // test results reporter to use
        // possible values: 'dots', 'progress'
        // available reporters: https://npmjs.org/browse/keyword/karma-reporter
        reporters: [
            'progress',
            // 'coverage'
        ],
        // web server port
        port: 9876,
        // 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: false,
        // start these browsers
        // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
        browsers: [
            'PhantomJS'
        ],
        // Continuous Integration mode
        // if true, Karma captures browsers, runs the tests and exits
        singleRun: true,
        // Concurrency level
        // how many browser should be started simultaneous
        concurrency: Infinity,

        middleware: ['httpServer'],
         // plugins
        plugins: ['karma-*', {
            'middleware:httpServer': [
                'factory', function () {
                    return httpServer;
                }
            ]
        }]
    });
};
<|endoftext|>


<commit_before>// Karma configuration file, see link for more information
// https://karma-runner.github.io/0.13/config/configuration-file.html

module.exports = function (config) {
  config.set({
    basePath: '',
    frameworks: ['jasmine', '@angular/cli'],
    plugins: [
        require('karma-jasmine'),
        require('karma-chrome-launcher'),
        require('karma-jasmine-html-reporter'),
        require('karma-coverage-istanbul-reporter'),
        require('@angular/cli/plugins/karma')
    ],
    client:{
        clearContext: false // leave Jasmine Spec Runner output visible in browser
    },
    files: [
      { pattern: './src/test.ts', watched: false }
    ],
    preprocessors: {
      './src/test.ts': ['@angular/cli']
    },
    coverageIstanbulReporter: {
        reports: ['html', 'lcovonly'],
        fixWebpackSourcePaths: true
    },
    angularCli: {
      environment: 'dev'
    },
    reporters: config.angularCli && config.angularCli.codeCoverage
        ? ['progress', 'coverage-istanbul']
        : ['progress', 'kjhtml'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    browsers: ['Chrome'],
    singleRun: false
  });
};
<commit_msg>Fix tests runtime error. Add extension ".ts" MIME type.<commit_after>// Karma configuration file, see link for more information
// https://karma-runner.github.io/0.13/config/configuration-file.html

module.exports = function (config) {
  config.set({
    basePath: '',
    frameworks: ['jasmine', '@angular/cli'],
    plugins: [
        require('karma-jasmine'),
        require('karma-chrome-launcher'),
        require('karma-jasmine-html-reporter'),
        require('karma-coverage-istanbul-reporter'),
        require('@angular/cli/plugins/karma')
    ],
    client:{
        clearContext: false // leave Jasmine Spec Runner output visible in browser
    },
    files: [
      { pattern: './src/test.ts', watched: false }
    ],
    preprocessors: {
      './src/test.ts': ['@angular/cli']
    },
    coverageIstanbulReporter: {
        reports: ['html', 'lcovonly'],
        fixWebpackSourcePaths: true
    },
    angularCli: {
      environment: 'dev'
    },
    reporters: config.angularCli && config.angularCli.codeCoverage
        ? ['progress', 'coverage-istanbul']
        : ['progress', 'kjhtml'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    browsers: ['Chrome'],
    singleRun: false,
    mime: {
        'text/x-typescript': ['ts','tsx']
    }
  });
};
<|endoftext|>


<commit_before>// Karma configuration

// base path, that will be used to resolve files and exclude
basePath = '';

// list of files / patterns to load in the browser
files = [
  JASMINE,
  JASMINE_ADAPTER,
  'app/bower_components/lodash/dist/lodash.js',
  'app/bower_components/angular/angular.js',
  'app/bower_components/angular-mocks/angular-mocks.js',
  'app/bower_components/angular-resource/angular-resource.js',
  'app/bower_components/angular-cookies/angular-cookies.js',
  'app/bower_components/angular-bootstrap/ui-bootstrap.js',
  'app/scripts/*.js',
  'app/scripts/**/*.js',
  'test/mock/**/*.js',
  //'test/spec/**/*.js'
];

// list of files to exclude
exclude = [
  'app/scripts/mockHttpBackend.js'
];

// test results reporter to use
// possible values: dots || progress || growl
reporters = ['progress'];

// web server port
port = 8080;

// cli runner port
runnerPort = 9100;

// enable / disable colors in the output (reporters and logs)
colors = true;

// level of logging
// possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG
logLevel = LOG_INFO;

// enable / disable watching file and executing tests whenever any file changes
autoWatch = false;

// Start these browsers, currently available:
// - Chrome
// - ChromeCanary
// - Firefox
// - Opera
// - Safari (only Mac)
// - PhantomJS
// - IE (only Windows)
browsers = ['Firefox'];

// If browser does not capture in given timeout [ms], kill it
captureTimeout = 5000;

// Continuous Integration mode
// if true, it capture browsers, run tests and exit
singleRun = false;
<commit_msg>Comment out mock tests.<commit_after>// Karma configuration

// base path, that will be used to resolve files and exclude
basePath = '';

// list of files / patterns to load in the browser
files = [
  JASMINE,
  JASMINE_ADAPTER,
  'app/bower_components/lodash/dist/lodash.js',
  'app/bower_components/angular/angular.js',
  'app/bower_components/angular-mocks/angular-mocks.js',
  'app/bower_components/angular-resource/angular-resource.js',
  'app/bower_components/angular-cookies/angular-cookies.js',
  'app/bower_components/angular-bootstrap/ui-bootstrap.js',
  'app/scripts/*.js',
  'app/scripts/**/*.js'
  // 'test/mock/**/*.js',
  //'test/spec/**/*.js'
];

// list of files to exclude
exclude = [
  'app/scripts/mockHttpBackend.js'
];

// test results reporter to use
// possible values: dots || progress || growl
reporters = ['progress'];

// web server port
port = 8080;

// cli runner port
runnerPort = 9100;

// enable / disable colors in the output (reporters and logs)
colors = true;

// level of logging
// possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG
logLevel = LOG_INFO;

// enable / disable watching file and executing tests whenever any file changes
autoWatch = false;

// Start these browsers, currently available:
// - Chrome
// - ChromeCanary
// - Firefox
// - Opera
// - Safari (only Mac)
// - PhantomJS
// - IE (only Windows)
browsers = ['Firefox'];

// If browser does not capture in given timeout [ms], kill it
captureTimeout = 5000;

// Continuous Integration mode
// if true, it capture browsers, run tests and exit
singleRun = false;
<|endoftext|>


<commit_before>// karma.conf.js - the config file for karma, which runs our tests.

var path = require('path');
var webpack = require('webpack');

/*
 * We use webpack to build our tests. It's a pain to have to wait for webpack
 * to build everything; however it's the easiest way to load our dependencies
 * from node_modules.
 *
 * If you run karma in multi-run mode (with `npm run test:multi`), it will watch
 * the tests for changes, and webpack will rebuild using a cache. This is much quicker
 * than a clean rebuild.
 */

// the name of the test file. By default, a special file which runs all tests.
var testFile = process.env.KARMA_TEST_FILE || 'test/all-tests.js';

process.env.PHANTOMJS_BIN = 'node_modules/.bin/phantomjs';
process.env.Q_DEBUG = 1;

module.exports = function (config) {
    config.set({
        // frameworks to use
        // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
        frameworks: ['mocha'],

        // list of files / patterns to load in the browser
        files: [
            'node_modules/babel-polyfill/browser.js',
            testFile,
            {pattern: 'vector/img/*', watched: false, included: false, served: true, nocache: false},
        ],

        // redirect img links to the karma server
        proxies: {
            "/img/": "/base/vector/img/",
        },

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

        // test results reporter to use
        // possible values: 'dots', 'progress'
        // available reporters: https://npmjs.org/browse/keyword/karma-reporter
        reporters: ['progress', 'junit'],

        // web server port
        port: 9876,

        // 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
        // available browser launchers:
        // https://npmjs.org/browse/keyword/karma-launcher
        browsers: [
            'Chrome',
            //'PhantomJS',
        ],

        // Continuous Integration mode
        // if true, Karma captures browsers, runs the tests and exits
        // singleRun: false,

        // Concurrency level
        // how many browser should be started simultaneous
        concurrency: Infinity,

        junitReporter: {
            outputDir: 'karma-reports',
        },

        webpack: {
            module: {
                loaders: [
                    { test: /\.json$/, loader: "json" },
                    {
                        test: /\.js$/, loader: "babel",
                        include: [path.resolve('./src'),
                                  path.resolve('./test'),
                                 ]
                    },
                ],
                noParse: [
                    // don't parse the languages within highlight.js. They
                    // cause stack overflows
                    // (https://github.com/webpack/webpack/issues/1721), and
                    // there is no need for webpack to parse them - they can
                    // just be included as-is.
                    /highlight\.js\/lib\/languages/,

                    // also disable parsing for sinon, because it
                    // tries to do voodoo with 'require' which upsets
                    // webpack (https://github.com/webpack/webpack/issues/304)
                    /sinon\/pkg\/sinon\.js$/,
                ],
            },
            resolve: {
                alias: {
                    // alias any requires to the react module to the one in our path, otherwise
                    // we tend to get the react source included twice when using npm link.
                    react: path.resolve('./node_modules/react'),

                    // same goes for js-sdk
                    "matrix-js-sdk": path.resolve('./node_modules/matrix-js-sdk'),

                    sinon: 'sinon/pkg/sinon.js',
                },
                root: [
                    path.resolve('./src'),
                    path.resolve('./test'),
                ],
            },
            plugins: [
                // olm may not be installed, so avoid webpack warnings by
                // ignoring it.
                new webpack.IgnorePlugin(/^olm$/),
            ],
            devtool: 'inline-source-map',
        },
    });
};
<commit_msg>A couple of tweaks to the karma config<commit_after>// karma.conf.js - the config file for karma, which runs our tests.

var path = require('path');
var webpack = require('webpack');

/*
 * We use webpack to build our tests. It's a pain to have to wait for webpack
 * to build everything; however it's the easiest way to load our dependencies
 * from node_modules.
 *
 * If you run karma in multi-run mode (with `npm run test:multi`), it will watch
 * the tests for changes, and webpack will rebuild using a cache. This is much quicker
 * than a clean rebuild.
 */

// the name of the test file. By default, a special file which runs all tests.
var testFile = process.env.KARMA_TEST_FILE || 'test/all-tests.js';

process.env.PHANTOMJS_BIN = 'node_modules/.bin/phantomjs';
process.env.Q_DEBUG = 1;

module.exports = function (config) {
    config.set({
        // frameworks to use
        // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
        frameworks: ['mocha'],

        // list of files / patterns to load in the browser
        files: [
            'node_modules/babel-polyfill/browser.js',
            testFile,

            // make the images available via our httpd. They will be avaliable
            // below http://localhost:[PORT]/base/. See also `proxies` which
            // defines alternative URLs for them.
            //
            // This isn't required by any of the tests, but it stops karma
            // logging warnings when it serves a 404 for them.
            {
                pattern: 'src/skins/vector/img/*',
                watched: false, included: false, served: true, nocache: false,
            },
        ],

        proxies: {
            // redirect img links to the karma server. See above.
            "/img/": "/base/src/skins/vector/img/",
        },

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

        // test results reporter to use
        // possible values: 'dots', 'progress'
        // available reporters: https://npmjs.org/browse/keyword/karma-reporter
        reporters: ['progress', 'junit'],

        // web server port
        port: 9876,

        // 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
        // available browser launchers:
        // https://npmjs.org/browse/keyword/karma-launcher
        browsers: [
            'Chrome',
            //'PhantomJS',
        ],

        // Continuous Integration mode
        // if true, Karma captures browsers, runs the tests and exits
        // singleRun: false,

        // Concurrency level
        // how many browser should be started simultaneous
        concurrency: Infinity,

        junitReporter: {
            outputDir: 'karma-reports',
        },

        webpack: {
            module: {
                preLoaders: [
                    // use the source-map-loader for javascript. This means
                    // that we have a better chance of seeing line numbers from
                    // the pre-babeled source.
                    { test: /\.js$/, loader: "source-map-loader" },
                ],
                loaders: [
                    { test: /\.json$/, loader: "json" },
                    {
                        test: /\.js$/, loader: "babel",
                        include: [path.resolve('./src'),
                                  path.resolve('./test'),
                                 ]
                    },
                ],
                noParse: [
                    // don't parse the languages within highlight.js. They
                    // cause stack overflows
                    // (https://github.com/webpack/webpack/issues/1721), and
                    // there is no need for webpack to parse them - they can
                    // just be included as-is.
                    /highlight\.js\/lib\/languages/,

                    // also disable parsing for sinon, because it
                    // tries to do voodoo with 'require' which upsets
                    // webpack (https://github.com/webpack/webpack/issues/304)
                    /sinon\/pkg\/sinon\.js$/,
                ],
            },
            resolve: {
                alias: {
                    // alias any requires to the react module to the one in our path, otherwise
                    // we tend to get the react source included twice when using npm link.
                    react: path.resolve('./node_modules/react'),

                    // same goes for js-sdk
                    "matrix-js-sdk": path.resolve('./node_modules/matrix-js-sdk'),

                    sinon: 'sinon/pkg/sinon.js',
                },
                root: [
                    path.resolve('./src'),
                    path.resolve('./test'),
                ],
            },
            plugins: [
                // olm may not be installed, so avoid webpack warnings by
                // ignoring it.
                new webpack.IgnorePlugin(/^olm$/),
            ],
            devtool: 'inline-source-map',
        },
    });
};
<|endoftext|>


<commit_before>// karma.conf.js - the config file for karma, which runs our tests.

var path = require('path');
var fs = require('fs');

/*
 * We use webpack to build our tests. It's a pain to have to wait for webpack
 * to build everything; however it's the easiest way to load our dependencies
 * from node_modules.
 *
 * If you run karma in multi-run mode (with `npm run test-multi`), it will watch
 * the tests for changes, and webpack will rebuild using a cache. This is much quicker
 * than a clean rebuild.
 */

// the name of the test file. By default, a special file which runs all tests.
//
// TODO: this could be a pattern, and karma would run each file, with a
// separate webpack bundle for each file. But then we get a separate instance
// of the sdk, and each of the dependencies, for each test file, and everything
// gets very confused. Can we persuade webpack to put all of the dependencies
// in a 'common' bundle?
//
var testFile = process.env.KARMA_TEST_FILE || 'test/all-tests.js';

process.env.PHANTOMJS_BIN = 'node_modules/.bin/phantomjs';

function fileExists(name) {
    try {
        fs.statSync(gsCss);
        return true;
    } catch (e) {
        return false;
    }
}

// try find the gemini-scrollbar css in an npm-version-agnostic way
var gsCss = 'node_modules/gemini-scrollbar/gemini-scrollbar.css';
if (!fileExists(gsCss)) {
    gsCss = 'node_modules/react-gemini-scrollbar/'+gsCss;
}

module.exports = function (config) {
    config.set({
        // frameworks to use
        // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
        frameworks: ['mocha'],

        // list of files / patterns to load in the browser
        files: [
            testFile,
            gsCss,

            // some images to reduce noise from the tests
            {pattern: 'test/img/*', watched: false, included: false,
             served: true, nocache: false},
            // translation files
            {pattern: 'src/i18n/strings/*', watcheed: false, included: false, served: true},
            {pattern: 'test/i18n/*', watched: false, included: false, served: true},
        ],

        proxies: {
            // redirect img links to the karma server
            "/img/": "/base/test/img/",
            // special languages.json file for the tests
            "/i18n/languages.json": "/base/test/i18n/languages.json",
            // and redirect i18n requests
            "/i18n/": "/base/src/i18n/strings/",
        },

        // list of files to exclude
        //
        // This doesn't work. It turns out that it's webpack which does the
        // watching of the /test directory (karma only watches `testFile`
        // itself). Webpack watches the directory so that it can spot
        // new tests, which is fair enough; unfortunately it triggers a rebuild
        // every time a lockfile is created in that directory, and there
        // doesn't seem to be any way to tell webpack to ignore particular
        // files in a watched directory.
        //
        // exclude: [
        //     '**/.#*'
        // ],

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

        // test results reporter to use
        // possible values: 'dots', 'progress'
        // available reporters: https://npmjs.org/browse/keyword/karma-reporter
        reporters: ['logcapture', 'spec', 'junit', 'summary'],

        specReporter: {
            suppressErrorSummary: false, // do print error summary
            suppressFailed: false, // do print information about failed tests
            suppressPassed: false, // do print information about passed tests
            showSpecTiming: true, // print the time elapsed for each spec
        },

        client: {
            captureLogs: true,
        },

        // web server port
        port: 9876,

        // 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
        //
        // This is strictly for logs that would be generated by the browser itself and we
        // don't want to log about missing images, which are emitted on LOG_WARN.
        logLevel: config.LOG_ERROR,

        // enable / disable watching file and executing tests whenever any file
        // changes
        autoWatch: true,

        // start these browsers
        // available browser launchers:
        // https://npmjs.org/browse/keyword/karma-launcher
        browsers: [
            'Chrome',
            //'PhantomJS',
            //'ChromeHeadless',
        ],

        customLaunchers: {
            'ChromeHeadless': {
                base: 'Chrome',
                flags: [
                    // See https://chromium.googlesource.com/chromium/src/+/lkgr/headless/README.md
                    '--headless',
                    '--disable-gpu',
                    // Without a remote debugging port, Google Chrome exits immediately.
                    '--remote-debugging-port=9222',
                ],
            }
        },

        // Continuous Integration mode
        // if true, Karma captures browsers, runs the tests and exits
        // singleRun: false,

        // Concurrency level
        // how many browser should be started simultaneous
        concurrency: Infinity,

        junitReporter: {
            outputDir: 'karma-reports',
        },

        webpack: {
            module: {
                rules: [
                    {
                        test: /\.js$/, loader: "babel-loader",
                        include: [path.resolve('./src'),
                                  path.resolve('./test'),
                                 ]
                    },
                ],
                noParse: [
                    // for cross platform compatibility use [\\\/] as the path separator
                    // this ensures that the regex trips on both Windows and *nix

                    // don't parse the languages within highlight.js. They
                    // cause stack overflows
                    // (https://github.com/webpack/webpack/issues/1721), and
                    // there is no need for webpack to parse them - they can
                    // just be included as-is.
                    /highlight\.js[\\\/]lib[\\\/]languages/,

                    // olm takes ages for webpack to process, and it's already heavily
                    // optimised, so there is little to gain by us uglifying it.
                    /olm[\\\/](javascript[\\\/])?olm\.js$/,

                    // also disable parsing for sinon, because it
                    // tries to do voodoo with 'require' which upsets
                    // webpack (https://github.com/webpack/webpack/issues/304)
                    /sinon[\\\/]pkg[\\\/]sinon\.js$/,
                ],
            },
            resolve: {
                alias: {
                    // alias any requires to the react module to the one in our
                    // path, otherwise we tend to get the react source included
                    // twice when using npm link.
                    react: path.resolve('./node_modules/react'),

                    'matrix-react-sdk': path.resolve('test/skinned-sdk.js'),
                    'sinon': 'sinon/pkg/sinon.js',
                },
                modules: [
                    path.resolve('./test'),
                    "node_modules"
                ],
            },
            devtool: 'inline-source-map',
            externals: {
                // Don't try to bundle electron: leave it as a commonjs dependency
                // (the 'commonjs' here means it will output a 'require')
                "electron": "commonjs electron",
            },
            // make sure we're flagged as development to avoid wasting time optimising
            mode: 'development',
        },

        webpackMiddleware: {
            stats: {
                // don't fill the console up with a mahoosive list of modules
                chunks: false,
            },
        },

        browserNoActivityTimeout: 15000,
    });
};
<commit_msg>Fix Karma/Webpack so it can build the tests<commit_after>// karma.conf.js - the config file for karma, which runs our tests.

var path = require('path');
var fs = require('fs');

/*
 * We use webpack to build our tests. It's a pain to have to wait for webpack
 * to build everything; however it's the easiest way to load our dependencies
 * from node_modules.
 *
 * If you run karma in multi-run mode (with `npm run test-multi`), it will watch
 * the tests for changes, and webpack will rebuild using a cache. This is much quicker
 * than a clean rebuild.
 */

// the name of the test file. By default, a special file which runs all tests.
//
// TODO: this could be a pattern, and karma would run each file, with a
// separate webpack bundle for each file. But then we get a separate instance
// of the sdk, and each of the dependencies, for each test file, and everything
// gets very confused. Can we persuade webpack to put all of the dependencies
// in a 'common' bundle?
//
var testFile = process.env.KARMA_TEST_FILE || 'test/all-tests.js';

process.env.PHANTOMJS_BIN = 'node_modules/.bin/phantomjs';

function fileExists(name) {
    try {
        fs.statSync(gsCss);
        return true;
    } catch (e) {
        return false;
    }
}

// try find the gemini-scrollbar css in an npm-version-agnostic way
var gsCss = 'node_modules/gemini-scrollbar/gemini-scrollbar.css';
if (!fileExists(gsCss)) {
    gsCss = 'node_modules/react-gemini-scrollbar/'+gsCss;
}

module.exports = function (config) {
    config.set({
        // frameworks to use
        // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
        frameworks: ['mocha'],

        // list of files / patterns to load in the browser
        files: [
            testFile,
            gsCss,

            // some images to reduce noise from the tests
            {pattern: 'test/img/*', watched: false, included: false,
             served: true, nocache: false},
            // translation files
            {pattern: 'src/i18n/strings/*', watcheed: false, included: false, served: true},
            {pattern: 'test/i18n/*', watched: false, included: false, served: true},
        ],

        proxies: {
            // redirect img links to the karma server
            "/img/": "/base/test/img/",
            // special languages.json file for the tests
            "/i18n/languages.json": "/base/test/i18n/languages.json",
            // and redirect i18n requests
            "/i18n/": "/base/src/i18n/strings/",
        },

        // list of files to exclude
        //
        // This doesn't work. It turns out that it's webpack which does the
        // watching of the /test directory (karma only watches `testFile`
        // itself). Webpack watches the directory so that it can spot
        // new tests, which is fair enough; unfortunately it triggers a rebuild
        // every time a lockfile is created in that directory, and there
        // doesn't seem to be any way to tell webpack to ignore particular
        // files in a watched directory.
        //
        // exclude: [
        //     '**/.#*'
        // ],

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

        // test results reporter to use
        // possible values: 'dots', 'progress'
        // available reporters: https://npmjs.org/browse/keyword/karma-reporter
        reporters: ['logcapture', 'spec', 'junit', 'summary'],

        specReporter: {
            suppressErrorSummary: false, // do print error summary
            suppressFailed: false, // do print information about failed tests
            suppressPassed: false, // do print information about passed tests
            showSpecTiming: true, // print the time elapsed for each spec
        },

        client: {
            captureLogs: true,
        },

        // web server port
        port: 9876,

        // 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
        //
        // This is strictly for logs that would be generated by the browser itself and we
        // don't want to log about missing images, which are emitted on LOG_WARN.
        logLevel: config.LOG_ERROR,

        // enable / disable watching file and executing tests whenever any file
        // changes
        autoWatch: true,

        // start these browsers
        // available browser launchers:
        // https://npmjs.org/browse/keyword/karma-launcher
        browsers: [
            'Chrome',
            //'PhantomJS',
            //'ChromeHeadless',
        ],

        customLaunchers: {
            'ChromeHeadless': {
                base: 'Chrome',
                flags: [
                    // See https://chromium.googlesource.com/chromium/src/+/lkgr/headless/README.md
                    '--headless',
                    '--disable-gpu',
                    // Without a remote debugging port, Google Chrome exits immediately.
                    '--remote-debugging-port=9222',
                ],
            }
        },

        // Continuous Integration mode
        // if true, Karma captures browsers, runs the tests and exits
        // singleRun: false,

        // Concurrency level
        // how many browser should be started simultaneous
        concurrency: Infinity,

        junitReporter: {
            outputDir: 'karma-reports',
        },

        webpack: {
            module: {
                rules: [
                    {
                        test: /\.js$/, loader: "babel-loader",
                        include: [path.resolve('./src'),
                                  path.resolve('./test'),
                                 ]
                    },
                ],
                noParse: [
                    // for cross platform compatibility use [\\\/] as the path separator
                    // this ensures that the regex trips on both Windows and *nix

                    // don't parse the languages within highlight.js. They
                    // cause stack overflows
                    // (https://github.com/webpack/webpack/issues/1721), and
                    // there is no need for webpack to parse them - they can
                    // just be included as-is.
                    /highlight\.js[\\\/]lib[\\\/]languages/,

                    // olm takes ages for webpack to process, and it's already heavily
                    // optimised, so there is little to gain by us uglifying it.
                    /olm[\\\/](javascript[\\\/])?olm\.js$/,

                    // also disable parsing for sinon, because it
                    // tries to do voodoo with 'require' which upsets
                    // webpack (https://github.com/webpack/webpack/issues/304)
                    /sinon[\\\/]pkg[\\\/]sinon\.js$/,
                ],
            },
            resolve: {
                alias: {
                    // alias any requires to the react module to the one in our
                    // path, otherwise we tend to get the react source included
                    // twice when using npm link.
                    react: path.resolve('./node_modules/react'),

                    'matrix-react-sdk': path.resolve('test/skinned-sdk.js'),
                    'sinon': 'sinon/pkg/sinon.js',

                    // To make webpack happy
                    // Related: https://github.com/request/request/issues/1529
                    // (there's no mock available for fs, so we fake a mock by using
                    // an in-memory version of fs)
                    "fs": "memfs",
                },
                modules: [
                    path.resolve('./test'),
                    "node_modules"
                ],
            },
            node: {
                // Because webpack is made of fail
                // https://github.com/request/request/issues/1529
                // Note: 'mock' is the new 'empty'
                net: 'mock',
                tls: 'mock'
            },
            devtool: 'inline-source-map',
            externals: {
                // Don't try to bundle electron: leave it as a commonjs dependency
                // (the 'commonjs' here means it will output a 'require')
                "electron": "commonjs electron",
            },
            // make sure we're flagged as development to avoid wasting time optimising
            mode: 'development',
        },

        webpackMiddleware: {
            stats: {
                // don't fill the console up with a mahoosive list of modules
                chunks: false,
            },
        },

        browserNoActivityTimeout: 15000,
    });
};
<|endoftext|>