2017-11-10 11:25:47 +01:00
|
|
|
/* eslint-env node */
|
2018-12-13 12:14:49 +01:00
|
|
|
|
2021-01-12 14:25:03 +01:00
|
|
|
'use strict'
|
|
|
|
|
2019-01-17 11:06:43 +01:00
|
|
|
const path = require('path')
|
2018-09-13 09:42:15 +02:00
|
|
|
const ip = require('ip')
|
2021-01-12 14:25:03 +01:00
|
|
|
const { browsers, browsersKeys } = require('./browsers')
|
2017-11-10 11:25:47 +01:00
|
|
|
|
2021-01-12 14:25:03 +01:00
|
|
|
const USE_OLD_JQUERY = Boolean(process.env.USE_OLD_JQUERY)
|
|
|
|
const BUNDLE = Boolean(process.env.BUNDLE)
|
|
|
|
const BROWSERSTACK = Boolean(process.env.BROWSERSTACK)
|
2021-01-28 22:26:08 +01:00
|
|
|
const JQUERY_FILE = USE_OLD_JQUERY ?
|
|
|
|
'https://cdn.jsdelivr.net/npm/jquery@1.9.1/jquery.min.js' :
|
|
|
|
'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) {
|
2021-02-16 12:12:23 +01:00
|
|
|
// On CI just use Chrome
|
|
|
|
if (process.env.CI === true) {
|
|
|
|
return ['ChromeHeadless']
|
|
|
|
}
|
|
|
|
|
|
|
|
if (availableBrowser.includes('Chrome')) {
|
2018-09-13 09:42:15 +02:00
|
|
|
return ['ChromeHeadless']
|
|
|
|
}
|
|
|
|
|
2020-11-17 21:01:24 +01:00
|
|
|
if (availableBrowser.includes('Chromium')) {
|
|
|
|
return ['ChromiumHeadless']
|
|
|
|
}
|
|
|
|
|
2018-09-13 09:42:15 +02:00
|
|
|
if (availableBrowser.includes('Firefox')) {
|
|
|
|
return ['FirefoxHeadless']
|
|
|
|
}
|
|
|
|
|
2020-11-17 21:01:24 +01:00
|
|
|
throw new Error('Please install Chrome, Chromium or Firefox')
|
2018-09-13 09:42:15 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-12 14:25:03 +01:00
|
|
|
if (BUNDLE) {
|
2018-09-13 09:42:15 +02:00
|
|
|
frameworks.push('detectBrowsers')
|
|
|
|
plugins.push(
|
|
|
|
'karma-chrome-launcher',
|
|
|
|
'karma-firefox-launcher',
|
|
|
|
'karma-detect-browsers'
|
|
|
|
)
|
|
|
|
conf.detectBrowsers = detectBrowsers
|
2021-01-27 17:37:18 +01:00
|
|
|
files = [...files,
|
2021-01-12 14:25:03 +01:00
|
|
|
JQUERY_FILE,
|
2021-01-27 17:37:18 +01:00
|
|
|
'dist/js/bootstrap.js']
|
2021-01-12 14:25:03 +01:00
|
|
|
} else if (BROWSERSTACK) {
|
2018-09-13 09:42:15 +02:00
|
|
|
conf.hostname = ip.address()
|
|
|
|
conf.browserStack = {
|
|
|
|
username: process.env.BROWSER_STACK_USERNAME,
|
|
|
|
accessKey: process.env.BROWSER_STACK_ACCESS_KEY,
|
2021-01-08 09:05:56 +01:00
|
|
|
build: `bootstrap-v4-${new Date().toISOString()}`,
|
2018-09-13 09:42:15 +02:00
|
|
|
project: 'Bootstrap',
|
|
|
|
retryLimit: 2
|
|
|
|
}
|
|
|
|
plugins.push('karma-browserstack-launcher')
|
|
|
|
conf.customLaunchers = browsers
|
|
|
|
conf.browsers = browsersKeys
|
|
|
|
reporters.push('BrowserStack')
|
2021-01-27 17:37:18 +01:00
|
|
|
files = [...files,
|
2019-01-15 17:01:40 +01:00
|
|
|
'node_modules/jquery/dist/jquery.slim.min.js',
|
2018-09-13 09:42:15 +02:00
|
|
|
'js/dist/util.js',
|
|
|
|
'js/dist/tooltip.js',
|
2021-01-12 14:25:03 +01:00
|
|
|
// include all of our js/dist files except util.js, index.js and tooltip.js
|
2021-01-27 17:37:18 +01:00
|
|
|
'js/dist/!(util|index|tooltip).js']
|
2018-09-13 09:42:15 +02:00
|
|
|
} else {
|
|
|
|
frameworks.push('detectBrowsers')
|
|
|
|
plugins.push(
|
|
|
|
'karma-chrome-launcher',
|
|
|
|
'karma-firefox-launcher',
|
2021-01-12 14:25:03 +01:00
|
|
|
'karma-detect-browsers'
|
2018-09-13 09:42:15 +02:00
|
|
|
)
|
2021-01-27 17:37:18 +01:00
|
|
|
files = [...files,
|
2021-01-12 14:25:03 +01:00
|
|
|
JQUERY_FILE,
|
2018-09-13 09:42:15 +02:00
|
|
|
'js/coverage/dist/util.js',
|
|
|
|
'js/coverage/dist/tooltip.js',
|
2021-01-12 14:25:03 +01:00
|
|
|
// include all of our js/dist files except util.js, index.js and tooltip.js
|
2021-01-27 17:37:18 +01:00
|
|
|
'js/coverage/dist/!(util|index|tooltip).js']
|
2018-09-13 09:42:15 +02:00
|
|
|
conf.detectBrowsers = detectBrowsers
|
2021-01-12 14:25:03 +01:00
|
|
|
if (!USE_OLD_JQUERY) {
|
|
|
|
plugins.push('karma-coverage-istanbul-reporter')
|
|
|
|
reporters.push('coverage-istanbul')
|
|
|
|
conf.coverageIstanbulReporter = {
|
|
|
|
dir: path.resolve(__dirname, '../coverage/'),
|
|
|
|
reports: ['lcov', 'text-summary'],
|
|
|
|
thresholds: {
|
|
|
|
emitWarning: false,
|
|
|
|
global: {
|
|
|
|
statements: 90,
|
|
|
|
branches: 86,
|
|
|
|
functions: 89,
|
|
|
|
lines: 90
|
|
|
|
}
|
2018-05-07 15:56:24 +02:00
|
|
|
}
|
2017-11-10 11:25:47 +01:00
|
|
|
}
|
2018-09-13 09:42:15 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
files.push('js/tests/unit/*.js')
|
|
|
|
|
|
|
|
conf.frameworks = frameworks
|
|
|
|
conf.plugins = plugins
|
|
|
|
conf.reporters = reporters
|
|
|
|
conf.files = files
|
|
|
|
|
2020-06-12 20:50:30 +02:00
|
|
|
module.exports = karmaConfig => {
|
2021-01-12 14:25:03 +01:00
|
|
|
conf.logLevel = karmaConfig.LOG_ERROR
|
2018-09-13 09:42:15 +02:00
|
|
|
karmaConfig.set(conf)
|
2017-11-10 11:25:47 +01:00
|
|
|
}
|