2017-11-10 05:25:47 -05:00
|
|
|
/* eslint-env node */
|
2017-12-16 06:44:17 -05:00
|
|
|
/* eslint no-process-env: 0 */
|
2018-09-13 03:42:15 -04:00
|
|
|
const ip = require('ip')
|
|
|
|
const {
|
|
|
|
browsers,
|
|
|
|
browsersKeys
|
|
|
|
} = require('./browsers')
|
2018-03-02 08:15:20 -05:00
|
|
|
const path = require('path')
|
|
|
|
const jsCoveragePath = path.resolve(__dirname, '../coverage')
|
2017-11-10 05:25:47 -05:00
|
|
|
|
2018-09-13 03:42:15 -04:00
|
|
|
const jqueryFile = process.env.USE_OLD_JQUERY ? 'https://code.jquery.com/jquery-1.9.1.min.js' : 'site/docs/4.1/assets/js/vendor/jquery-slim.min.js'
|
|
|
|
const bundle = process.env.BUNDLE === 'true'
|
|
|
|
const browserStack = process.env.BROWSER === 'true'
|
2017-11-10 05:25:47 -05:00
|
|
|
|
2018-09-13 03:42:15 -04:00
|
|
|
const frameworks = [
|
|
|
|
'qunit',
|
|
|
|
'sinon'
|
|
|
|
]
|
2017-11-10 05:25:47 -05:00
|
|
|
|
2018-09-13 03:42:15 -04:00
|
|
|
const plugins = [
|
|
|
|
'karma-qunit',
|
|
|
|
'karma-sinon'
|
|
|
|
]
|
2017-11-10 05:25:47 -05:00
|
|
|
|
2018-09-13 03:42:15 -04:00
|
|
|
const reporters = ['dots']
|
|
|
|
|
|
|
|
const detectBrowsers = {
|
|
|
|
usePhantomJS: false,
|
|
|
|
postDetection(availableBrowser) {
|
|
|
|
if (typeof process.env.TRAVIS_JOB_ID !== 'undefined' || availableBrowser.includes('Chrome')) {
|
|
|
|
return ['ChromeHeadless']
|
|
|
|
}
|
|
|
|
|
|
|
|
if (availableBrowser.includes('Firefox')) {
|
|
|
|
return ['FirefoxHeadless']
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new Error('Please install Firefox or Chrome')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const customLaunchers = {
|
|
|
|
FirefoxHeadless: {
|
|
|
|
base: 'Firefox',
|
|
|
|
flags: ['-headless']
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
let files = ['site/docs/4.1/assets/js/vendor/popper.min.js']
|
|
|
|
const conf = {
|
|
|
|
basePath: '../..',
|
|
|
|
port: 9876,
|
|
|
|
colors: true,
|
|
|
|
autoWatch: false,
|
|
|
|
singleRun: true,
|
|
|
|
concurrency: Infinity,
|
|
|
|
client: {
|
|
|
|
qunit: {
|
|
|
|
showUI: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bundle) {
|
|
|
|
frameworks.push('detectBrowsers')
|
|
|
|
plugins.push(
|
|
|
|
'karma-chrome-launcher',
|
|
|
|
'karma-firefox-launcher',
|
|
|
|
'karma-detect-browsers'
|
|
|
|
)
|
|
|
|
conf.customLaunchers = customLaunchers
|
|
|
|
conf.detectBrowsers = detectBrowsers
|
|
|
|
files = files.concat([
|
|
|
|
jqueryFile,
|
|
|
|
'dist/js/bootstrap.js'
|
|
|
|
])
|
|
|
|
} else if (browserStack) {
|
|
|
|
conf.hostname = ip.address()
|
|
|
|
conf.browserStack = {
|
|
|
|
username: process.env.BROWSER_STACK_USERNAME,
|
|
|
|
accessKey: process.env.BROWSER_STACK_ACCESS_KEY,
|
|
|
|
build: `bootstrap-${new Date().toISOString()}`,
|
|
|
|
project: 'Bootstrap',
|
|
|
|
retryLimit: 2
|
|
|
|
}
|
|
|
|
plugins.push('karma-browserstack-launcher')
|
|
|
|
conf.customLaunchers = browsers
|
|
|
|
conf.browsers = browsersKeys
|
|
|
|
reporters.push('BrowserStack')
|
|
|
|
files = files.concat([
|
|
|
|
'site/docs/4.1/assets/js/vendor/jquery-slim.min.js',
|
|
|
|
'js/dist/util.js',
|
|
|
|
'js/dist/tooltip.js',
|
|
|
|
'js/dist/!(util|index|tooltip).js' // include all of our js/dist files except util.js, index.js and tooltip.js
|
|
|
|
])
|
|
|
|
} else {
|
|
|
|
frameworks.push('detectBrowsers')
|
|
|
|
plugins.push(
|
|
|
|
'karma-chrome-launcher',
|
|
|
|
'karma-firefox-launcher',
|
|
|
|
'karma-detect-browsers',
|
|
|
|
'karma-coverage-istanbul-reporter'
|
|
|
|
)
|
|
|
|
files = files.concat([
|
|
|
|
jqueryFile,
|
|
|
|
'js/coverage/dist/util.js',
|
|
|
|
'js/coverage/dist/tooltip.js',
|
|
|
|
'js/coverage/dist/!(util|index|tooltip).js' // include all of our js/dist files except util.js, index.js and tooltip.js
|
|
|
|
])
|
|
|
|
reporters.push('coverage-istanbul')
|
|
|
|
conf.customLaunchers = customLaunchers
|
|
|
|
conf.detectBrowsers = detectBrowsers
|
|
|
|
conf.coverageIstanbulReporter = {
|
|
|
|
dir: jsCoveragePath,
|
|
|
|
reports: ['lcov', 'text-summary'],
|
|
|
|
thresholds: {
|
|
|
|
emitWarning: false,
|
|
|
|
global: {
|
|
|
|
statements: 90,
|
|
|
|
branches: 84,
|
|
|
|
functions: 87,
|
|
|
|
lines: 90
|
2018-05-07 09:56:24 -04:00
|
|
|
}
|
2017-11-10 05:25:47 -05:00
|
|
|
}
|
2018-09-13 03:42:15 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
files.push('js/tests/unit/*.js')
|
|
|
|
|
|
|
|
conf.frameworks = frameworks
|
|
|
|
conf.plugins = plugins
|
|
|
|
conf.reporters = reporters
|
|
|
|
conf.files = files
|
|
|
|
|
|
|
|
module.exports = (karmaConfig) => {
|
|
|
|
// possible values: karmaConfig.LOG_DISABLE || karmaConfig.LOG_ERROR || karmaConfig.LOG_WARN || karmaConfig.LOG_INFO || karmaConfig.LOG_DEBUG
|
|
|
|
conf.logLevel = karmaConfig.LOG_ERROR || karmaConfig.LOG_WARN
|
|
|
|
karmaConfig.set(conf)
|
2017-11-10 05:25:47 -05:00
|
|
|
}
|