2017-11-10 11:25:47 +01:00
|
|
|
/* eslint-env node */
|
2017-12-16 12:44:17 +01:00
|
|
|
/* eslint no-process-env: 0 */
|
2018-12-13 12:14:49 +01:00
|
|
|
|
2019-01-17 11:06:43 +01:00
|
|
|
const path = require('path')
|
2018-09-13 09:42:15 +02:00
|
|
|
const ip = require('ip')
|
|
|
|
const {
|
|
|
|
browsers,
|
|
|
|
browsersKeys
|
|
|
|
} = require('./browsers')
|
2017-11-10 11:25:47 +01:00
|
|
|
|
2019-02-26 12:20:34 +01:00
|
|
|
const { env } = process
|
2019-02-24 14:34:36 +01:00
|
|
|
const bundle = env.BUNDLE === 'true'
|
|
|
|
const browserStack = env.BROWSER === 'true'
|
|
|
|
const debug = env.DEBUG === 'true'
|
|
|
|
|
2019-02-24 11:45:01 +01:00
|
|
|
const jqueryFile = 'node_modules/jquery/dist/jquery.slim.min.js'
|
2017-11-10 11:25:47 +01:00
|
|
|
|
2018-03-03 22:04:11 +01:00
|
|
|
const frameworks = [
|
|
|
|
'qunit',
|
|
|
|
'sinon'
|
|
|
|
]
|
|
|
|
|
2018-10-14 13:59:51 +02:00
|
|
|
const plugins = [
|
|
|
|
'karma-qunit',
|
|
|
|
'karma-sinon'
|
|
|
|
]
|
|
|
|
|
2018-09-13 09:42:15 +02:00
|
|
|
const reporters = ['dots']
|
|
|
|
|
|
|
|
const detectBrowsers = {
|
|
|
|
usePhantomJS: false,
|
|
|
|
postDetection(availableBrowser) {
|
2019-02-24 14:34:36 +01:00
|
|
|
if (typeof env.TRAVIS_JOB_ID !== 'undefined' || availableBrowser.includes('Chrome')) {
|
2019-02-22 23:37:55 +01:00
|
|
|
return debug ? ['Chrome'] : ['ChromeHeadless']
|
2018-09-13 09:42:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (availableBrowser.includes('Firefox')) {
|
2019-02-22 23:37:55 +01:00
|
|
|
return debug ? ['Firefox'] : ['FirefoxHeadless']
|
2018-09-13 09:42:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
throw new Error('Please install Firefox or Chrome')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const customLaunchers = {
|
|
|
|
FirefoxHeadless: {
|
|
|
|
base: 'Firefox',
|
|
|
|
flags: ['-headless']
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-03 22:04:11 +01:00
|
|
|
let files = [
|
|
|
|
'node_modules/popper.js/dist/umd/popper.min.js',
|
|
|
|
'node_modules/hammer-simulator/index.js'
|
|
|
|
]
|
|
|
|
|
2018-09-13 09:42:15 +02:00
|
|
|
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,
|
2019-03-16 15:10:23 +01:00
|
|
|
'js/tests/unit/tests-polyfills.js',
|
2019-02-22 23:37:55 +01:00
|
|
|
'dist/js/bootstrap.js',
|
2019-03-16 15:10:23 +01:00
|
|
|
'js/tests/unit/!(tests-polyfills).js'
|
2018-09-13 09:42:15 +02:00
|
|
|
])
|
|
|
|
} else if (browserStack) {
|
|
|
|
conf.hostname = ip.address()
|
|
|
|
conf.browserStack = {
|
2019-02-24 14:34:36 +01:00
|
|
|
username: env.BROWSER_STACK_USERNAME,
|
|
|
|
accessKey: env.BROWSER_STACK_ACCESS_KEY,
|
2018-09-13 09:42:15 +02:00
|
|
|
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([
|
2019-02-24 11:45:01 +01:00
|
|
|
jqueryFile,
|
2019-03-16 15:10:23 +01:00
|
|
|
'js/tests/unit/tests-polyfills.js',
|
2019-02-22 23:37:55 +01:00
|
|
|
'js/coverage/dist/util/util.js',
|
|
|
|
'js/coverage/dist/util/sanitizer.js',
|
2018-07-25 11:29:16 +02:00
|
|
|
'js/coverage/dist/dom/polyfill.js',
|
2018-06-09 18:23:13 +02:00
|
|
|
'js/coverage/dist/dom/eventHandler.js',
|
|
|
|
'js/coverage/dist/dom/selectorEngine.js',
|
|
|
|
'js/coverage/dist/dom/data.js',
|
|
|
|
'js/coverage/dist/dom/manipulator.js',
|
2018-06-09 18:24:06 +02:00
|
|
|
'js/coverage/dist/dom/!(polyfill).js',
|
2018-06-09 18:23:13 +02:00
|
|
|
'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
|
2019-03-16 15:10:23 +01:00
|
|
|
'js/tests/unit/!(tests-polyfills).js',
|
2019-02-22 23:37:55 +01:00
|
|
|
'js/tests/unit/dom/*.js',
|
|
|
|
'js/tests/unit/util/*.js'
|
2018-09-13 09:42:15 +02:00
|
|
|
])
|
|
|
|
} else {
|
|
|
|
frameworks.push('detectBrowsers')
|
|
|
|
plugins.push(
|
|
|
|
'karma-chrome-launcher',
|
|
|
|
'karma-firefox-launcher',
|
|
|
|
'karma-detect-browsers',
|
|
|
|
'karma-coverage-istanbul-reporter'
|
|
|
|
)
|
|
|
|
files = files.concat([
|
|
|
|
jqueryFile,
|
2019-03-16 15:10:23 +01:00
|
|
|
'js/tests/unit/tests-polyfills.js',
|
2019-02-22 23:37:55 +01:00
|
|
|
'js/coverage/dist/util/util.js',
|
|
|
|
'js/coverage/dist/util/sanitizer.js',
|
2018-07-25 11:29:16 +02:00
|
|
|
'js/coverage/dist/dom/polyfill.js',
|
2017-11-24 10:23:31 +01:00
|
|
|
'js/coverage/dist/dom/eventHandler.js',
|
|
|
|
'js/coverage/dist/dom/selectorEngine.js',
|
|
|
|
'js/coverage/dist/dom/data.js',
|
|
|
|
'js/coverage/dist/dom/manipulator.js',
|
2018-06-09 18:24:06 +02:00
|
|
|
'js/coverage/dist/dom/!(polyfill).js',
|
2018-09-13 09:42:15 +02:00
|
|
|
'js/coverage/dist/tooltip.js',
|
2018-06-09 18:23:13 +02:00
|
|
|
'js/coverage/dist/!(util|index|tooltip).js', // include all of our js/dist files except util.js, index.js and tooltip.js
|
2019-03-16 15:10:23 +01:00
|
|
|
'js/tests/unit/!(tests-polyfills).js',
|
2019-02-22 23:37:55 +01:00
|
|
|
'js/tests/unit/dom/*.js',
|
|
|
|
'js/tests/unit/util/*.js'
|
2018-09-13 09:42:15 +02:00
|
|
|
])
|
|
|
|
reporters.push('coverage-istanbul')
|
|
|
|
conf.customLaunchers = customLaunchers
|
|
|
|
conf.detectBrowsers = detectBrowsers
|
|
|
|
conf.coverageIstanbulReporter = {
|
2019-01-17 11:06:43 +01:00
|
|
|
dir: path.resolve(__dirname, '../coverage/'),
|
2018-09-13 09:42:15 +02:00
|
|
|
reports: ['lcov', 'text-summary'],
|
|
|
|
thresholds: {
|
|
|
|
emitWarning: false,
|
|
|
|
global: {
|
|
|
|
statements: 90,
|
2018-10-29 14:27:55 +01:00
|
|
|
branches: 86,
|
|
|
|
functions: 89,
|
2018-09-13 09:42:15 +02:00
|
|
|
lines: 90
|
2018-06-09 21:11:05 +02:00
|
|
|
},
|
|
|
|
each: {
|
|
|
|
overrides: {
|
|
|
|
'js/src/dom/polyfill.js': {
|
|
|
|
statements: 39,
|
|
|
|
lines: 37,
|
|
|
|
branches: 19,
|
|
|
|
functions: 50
|
|
|
|
}
|
|
|
|
}
|
2018-05-07 15:56:24 +02:00
|
|
|
}
|
2017-11-10 11:25:47 +01:00
|
|
|
}
|
2018-09-13 09:42:15 +02:00
|
|
|
}
|
|
|
|
|
2019-02-22 23:37:55 +01:00
|
|
|
if (debug) {
|
|
|
|
conf.singleRun = false
|
|
|
|
conf.autoWatch = true
|
|
|
|
}
|
|
|
|
}
|
2018-09-13 09:42:15 +02:00
|
|
|
|
|
|
|
conf.frameworks = frameworks
|
|
|
|
conf.plugins = plugins
|
|
|
|
conf.reporters = reporters
|
|
|
|
conf.files = files
|
|
|
|
|
2019-02-26 12:20:34 +01:00
|
|
|
module.exports = karmaConfig => {
|
2018-09-13 09:42:15 +02:00
|
|
|
// 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 11:25:47 +01:00
|
|
|
}
|