-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add teamcity & browserstack support #185
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,116 @@ | ||
/* eslint-disable no-console */ | ||
/* eslint-disable no-console, camelcase */ | ||
const serveStatic = require('serve-static'); | ||
const path = require('path'); | ||
const serve = serveStatic( | ||
path.join(__dirname, '..'), | ||
{index: ['index.html', 'index.htm']} | ||
); | ||
const pkg = require('../package.json'); | ||
|
||
/* 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(`**** static file server started for ${config.basePath} *****`); | ||
|
||
const serve = serveStatic( | ||
config.basePath, | ||
{index: ['index.html', 'index.htm']} | ||
); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should server the basePath, rather than trying to determine our own. |
||
|
||
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 teamcitystack */ | ||
const teamcityLaunchers = {} | ||
|
||
// On Travis CI, we can only run in Firefox and Chrome; so, enforce that. | ||
if (process.env.TRAVIS) { | ||
config.browsers = ['Firefox', 'travisChrome']; | ||
/* browsers to run on browserstack */ | ||
const browserstackLaunchers = { | ||
bsChrome: { | ||
base: 'BrowserStack', | ||
browser: 'chrome', | ||
os: 'Windows', | ||
os_version: '10' | ||
}, | ||
|
||
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, | ||
browserstackLaunchers | ||
), | ||
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: [ | ||
|
@@ -67,6 +121,46 @@ module.exports = function(config) { | |
colors: true, | ||
autoWatch: false, | ||
singleRun: true, | ||
concurrency: Infinity | ||
concurrency: Infinity, | ||
|
||
captureTimeout: 30000, | ||
browserNoActivityTimeout: 300000 | ||
}); | ||
|
||
/* dynamic configuration, for ci and detectBrowsers */ | ||
|
||
// determine what browsers should be run on this environment | ||
if (process.env.BROWSER_STACK_USERNAME) { | ||
config.browsers = Object.keys(browserstackLaunchers); | ||
} else if (process.env.TRAVIS) { | ||
config.browsers = Object.keys(travisLaunchers); | ||
} else if (process.env.TEAMCITY_VERSION) { | ||
config.browsers = Object.keys(teamcityLaunchers); | ||
} | ||
|
||
// if running on travis | ||
if (process.env.TRAVIS) { | ||
config.browserStack.name = process.env.TRAVIS_BUILD_NUMBER; | ||
if (process.env.TRAVIS_PULL_REQUEST !== 'false') { | ||
config.browserStack.name += process.env.TRAVIS_PULL_REQUEST; | ||
config.browserStack.name += ' '; | ||
config.browserStack.name += process.env.TRAVIS_PULL_REQUEST_BRANCH; | ||
} | ||
|
||
config.browserStack.name += ' ' + process.env.TRAVIS_BRANCH; | ||
|
||
// if running on teamcity | ||
} else if (process.env.TEAMCITY_VERSION) { | ||
config.reporters.push('teamcity'); | ||
config.browserStack.name = process.env.TEAMCITY_PROJECT_NAME; | ||
config.browserStack.name += '_'; | ||
config.browserStack.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; | ||
} | ||
|
||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this info being printed elsewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The karma server prints it when it starts up. Oftentimes the address we were printing here is the address we were passed. This means that when port
9999
is in use and get incremented by karma to10000
. we still print9999
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool.