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-03-02 14:15:20 +01:00
|
|
|
const path = require('path')
|
|
|
|
const jsCoveragePath = path.resolve(__dirname, '../coverage')
|
2017-11-10 11:25:47 +01:00
|
|
|
|
|
|
|
module.exports = (config) => {
|
2018-03-21 11:00:13 +01:00
|
|
|
const jqueryFile = process.env.USE_OLD_JQUERY ? 'https://code.jquery.com/jquery-1.9.1.min.js' : 'assets/js/vendor/jquery-slim.min.js'
|
2017-11-10 11:25:47 +01:00
|
|
|
|
|
|
|
config.set({
|
|
|
|
basePath: '../..',
|
2018-03-09 23:17:57 +01:00
|
|
|
frameworks: ['qunit', 'sinon', 'detectBrowsers'],
|
2017-11-10 11:25:47 +01:00
|
|
|
plugins: [
|
|
|
|
'karma-chrome-launcher',
|
|
|
|
'karma-firefox-launcher',
|
|
|
|
'karma-qunit',
|
2018-03-09 23:17:57 +01:00
|
|
|
'karma-sinon',
|
2018-03-02 14:15:20 +01:00
|
|
|
'karma-detect-browsers',
|
|
|
|
'karma-coverage-istanbul-reporter'
|
2017-11-10 11:25:47 +01:00
|
|
|
],
|
|
|
|
// list of files / patterns to load in the browser
|
|
|
|
files: [
|
|
|
|
jqueryFile,
|
|
|
|
'assets/js/vendor/popper.min.js',
|
2018-03-02 14:15:20 +01:00
|
|
|
'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
|
2017-11-10 11:25:47 +01:00
|
|
|
'js/tests/unit/*.js'
|
|
|
|
],
|
2018-03-02 14:15:20 +01:00
|
|
|
reporters: ['dots', 'coverage-istanbul'],
|
2017-11-10 11:25:47 +01:00
|
|
|
port: 9876,
|
|
|
|
colors: true,
|
|
|
|
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
|
|
|
|
logLevel: config.LOG_ERROR || config.LOG_WARN,
|
|
|
|
autoWatch: false,
|
|
|
|
customLaunchers: {
|
|
|
|
FirefoxHeadless: {
|
|
|
|
base: 'Firefox',
|
|
|
|
flags: ['-headless']
|
|
|
|
}
|
|
|
|
},
|
|
|
|
singleRun: true,
|
|
|
|
concurrency: Infinity,
|
|
|
|
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')
|
|
|
|
}
|
2018-03-02 14:15:20 +01:00
|
|
|
},
|
|
|
|
coverageIstanbulReporter: {
|
|
|
|
dir: jsCoveragePath,
|
|
|
|
reports: ['lcov', 'text-summary'],
|
|
|
|
thresholds: {
|
2018-03-20 16:08:19 +01:00
|
|
|
emitWarning: false,
|
2018-03-02 14:15:20 +01:00
|
|
|
global: {
|
2018-04-10 09:28:29 +02:00
|
|
|
statements: 90,
|
|
|
|
branches: 84,
|
|
|
|
functions: 87,
|
|
|
|
lines: 90
|
2018-03-02 14:15:20 +01:00
|
|
|
}
|
|
|
|
}
|
2018-05-07 15:56:24 +02:00
|
|
|
},
|
|
|
|
client: {
|
|
|
|
qunit: {
|
|
|
|
showUI: true
|
|
|
|
}
|
2017-11-10 11:25:47 +01:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|