Skip to content

Commit

Permalink
feat: add teamcity & browserstack support
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonocasey committed Jun 25, 2018
1 parent 55c4f3f commit eae31ab
Show file tree
Hide file tree
Showing 4 changed files with 382 additions and 37 deletions.
2 changes: 2 additions & 0 deletions generators/app/package-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ const DEFAULTS = {
'conventional-changelog-videojs',
'in-publish',
'karma',
'karma-browserstack-launcher',
'karma-teamcity-reporter',
'karma-chrome-launcher',
'karma-detect-browsers',
'karma-firefox-launcher',
Expand Down
141 changes: 107 additions & 34 deletions generators/app/templates/scripts/_karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,62 +1,107 @@
/* eslint-disable no-console */
const serveStatic = require('serve-static');
const path = require('path');
const serve = serveStatic(
path.join(__dirname, '..'),
{index: ['index.html', 'index.htm']}
);

/* allow static files to be served, note karma will takeover the /test directory */
const StaticMiddlewareFactory = function(config) {
console.log(`**** Dev server started at http://${config.listenAddress}:${config.port}/ *****`);
console.log(`**** Karma static file server enabled in project root *****`);

const serve = serveStatic(
config.basePath,
{index: ['index.html', 'index.htm']}
);

return function(req, res, next) {
res.setHeader('Cache-Control', 'no-cache,must-revalidate');
return serve(req, res, next);
};
};

module.exports = function(config) {
const detectBrowsers = {
enabled: false,
usePhantomJS: false
};
/* browsers to run on teamcity */
const teamcityLaunchers = {
bsChrome: {
base: 'BrowserStack',
browser: 'chrome',
os: 'Windows',
os_version: '10'
},

// On Travis CI, we can only run in Firefox and Chrome; so, enforce that.
if (process.env.TRAVIS) {
config.browsers = ['Firefox', 'travisChrome'];
bsFirefox: {
base: 'BrowserStack',
browser: 'firefox',
os: 'Windows',
os_version: '10'
},

bsSafariSierra: {
base: 'BrowserStack',
browser: 'safari',
os: 'OS X',
os_version: 'Sierra'
},

bsEdgeWin10: {
base: 'BrowserStack',
browser: 'edge',
os: 'Windows',
os_version: '10'
},

bsIE11Win10: {
base: 'BrowserStack',
browser: 'ie',
browser_version: '11',
os: 'Windows',
os_version: '10'
},

bsIE11Win7: {
base: 'BrowserStack',
browser: 'ie',
browser_version: '11',
os: 'Windows',
os_version: '7'
}
};

// If no browsers are specified, we enable `karma-detect-browsers`
// this will detect all browsers that are available for testing
if (config.browsers !== false && !config.browsers.length) {
detectBrowsers.enabled = true;
/* browsers to run on travis */
const travisLaunchers = {
travisFirefox: {
base: 'Firefox',
},
travisChrome: {
base: 'Chrome',
flags: ['--no-sandbox']
}
};

module.exports = function(config) {
/* Default configuration */
config.set({
basePath: '..',
frameworks: ['qunit', 'detectBrowsers'],
customLaunchers: Object.assign({}, travisLaunchers, teamcityLaunchers),
client: {clearContext: false, qunit: {showUI: true, testTimeout: 5000}},

detectBrowsers: {
enabled: false,
usePhantomJS: false
},
browserStack: {
project: process.env.TEAMCITY_PROJECT_NAME || pkg.name,
name: '',
build: process.env.TRAVIS_BUILD_NUMBER || process.env.BUILD_NUMBER,
pollingTimeout: 30000,
captureTimeout: 600,
timeout: 600
},
reporters: ['dots'],
files: [
'node_modules/video.js/dist/video-js.css',<% if (css) { %>
'dist/<%= pluginName %>.css',<% } %>
'node_modules/sinon/pkg/sinon.js',
'node_modules/video.js/dist/video.js',
'test/dist/bundle.js'
],
customLaunchers: {
travisChrome: {
base: 'Chrome',
flags: ['--no-sandbox']
}
},
client: {
clearContext: false,
qunit: {
showUI: true,
testTimeout: 5000
}
},
detectBrowsers,
reporters: ['dots'],
port: 9999,
urlRoot: '/test/',
plugins: [
Expand All @@ -67,6 +112,34 @@ module.exports = function(config) {
colors: true,
autoWatch: false,
singleRun: true,
concurrency: Infinity
concurrency: Infinity,

captureTimeout: 30000,
browserNoActivityTimeout: 300000,
});

/* dynamic configuration, for ci and detectBrowsers */

// run browsers listed in travisLaunchers
if (process.env.TRAVIS) {
config.browsers = Object.keys(travisLaunchers);
config.browserStack.name = process.env.TRAVIS_BUILD_NUMBER;
if (process.env.TRAVIS_PULL_REQUEST !== 'false') {
config.browserStack.name += ' ' + process.env.TRAVIS_PULL_REQUEST + ' ' + process.env.TRAVIS_PULL_REQUEST_BRANCH;
}

config.browserStack.name += ' ' + process.env.TRAVIS_BRANCH;

// run browsers listed in teamcityLaunchers
} else if (process.env.TEAMCITY_VERSION) {
config.reporters.push('teamcity');
config.browsers = Object.keys(teamcityLaunchers);
browserstackName = process.env.TEAMCITY_PROJECT_NAME + '_' + process.env.BUILD_NUMBER;
}

// If no browsers are specified, we enable `karma-detect-browsers`
// this will detect all browsers that are available for testing
if (config.browsers !== false && !config.browsers.length) {
config.detectBrowsers.enabled = true;
}
};
Loading

0 comments on commit eae31ab

Please sign in to comment.