Skip to content

Instantly share code, notes, and snippets.

@falsefalse
Created March 21, 2017 12:44
Show Gist options
  • Save falsefalse/30a544b312bacd0f13d254bb29a6b624 to your computer and use it in GitHub Desktop.
Save falsefalse/30a544b312bacd0f13d254bb29a6b624 to your computer and use it in GitHub Desktop.

Revisions

  1. falsefalse created this gist Mar 21, 2017.
    65 changes: 65 additions & 0 deletions karma.browserstack.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,65 @@
    // browserstack (read: IE11) config
    const karma = require('./karma.common.js')
    const appComponents = require('./app_components.js')

    const browserStackLauncher = {
    ie11: {
    'base': 'BrowserStack',
    'browser': 'ie',
    'browser_version': '11.0',
    'os': 'Windows',
    // Pick OS from the env variable or use Windows 7
    'os_version': process.env.OS || '7',
    'name': appComponents.id
    }
    }

    const options = {
    preprocessors: {
    [appComponents.all[appComponents.id]]: ['webpack', 'gzip'],
    },

    // Browsers configuration
    browsers: [Object.keys(browserStackLauncher)],

    customLaunchers: browserStackLauncher,

    browserStack: {
    // Increase polling time to avoid hitting BS rate limit, default is 1000
    pollingTimeout: 5 * 1000, /* 5 seconds */

    // https://github.com/karma-runner/karma-browserstack-launcher/issues/17#issuecomment-181559755
    startTunnel: true,

    // if tests ain't completed during this timespan IE is stalled
    timeout: 4 * 60, /* 4 minutes */

    name: process.env.BUILD_TAG || false,

    project: 'Platform'
    },

    // We are limited in the number of parallel VMs in BrowserStack (5)
    // and Karma don't know how to limit parallel browser instances
    // so waiting time must be insanely high. Default is 10 * 1000
    browserNoActivityTimeout: 3 * 60 * 1000, /* 3 minutes */

    captureTimeout: 90 * 1000, /* 1.5 minutes */

    // Make Karma more tolerant to disconnects. It's required to make
    // BrowserStack tests more stable. Default is 2000.
    browserDisconnectTimeout: 30 * 1000, /* 30 sec */

    browserDisconnectTolerance: 5,

    // Reporters configuration
    reporters: ['mocha', 'BrowserStack'],

    mochaReporter: {
    output: 'minimal'
    }
    }

    module.exports = function (config) {
    karma(config, options)
    }