aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXhmikosR <[email protected]>2021-01-12 15:25:03 +0200
committerXhmikosR <[email protected]>2021-01-13 10:49:09 +0200
commit0f1069a32e57fdfba81ea366346ed4546489669b (patch)
treee5e516e3bc34f6f8e77405029d21725447e3e82a
parentf8da510367c47a1efff39050a3239250648a7899 (diff)
downloadbootstrap-0f1069a32e57fdfba81ea366346ed4546489669b.tar.xz
bootstrap-0f1069a32e57fdfba81ea366346ed4546489669b.zip
Update karma config
* rename constants * enforce the constants to be Boolean * use the coverage plugin only one time, on the latest jQuery run * fix karma `logLevel`
-rw-r--r--js/tests/karma.conf.js59
-rw-r--r--package.json2
2 files changed, 32 insertions, 29 deletions
diff --git a/js/tests/karma.conf.js b/js/tests/karma.conf.js
index 2e947ab97..c87911736 100644
--- a/js/tests/karma.conf.js
+++ b/js/tests/karma.conf.js
@@ -1,15 +1,15 @@
/* eslint-env node */
+'use strict'
+
const path = require('path')
const ip = require('ip')
-const {
- browsers,
- browsersKeys
-} = require('./browsers')
+const { browsers, browsersKeys } = require('./browsers')
-const jqueryFile = process.env.USE_OLD_JQUERY ? 'https://code.jquery.com/jquery-1.9.1.min.js' : 'node_modules/jquery/dist/jquery.slim.min.js'
-const bundle = process.env.BUNDLE === 'true'
-const browserStack = process.env.BROWSER === 'true'
+const USE_OLD_JQUERY = Boolean(process.env.USE_OLD_JQUERY)
+const BUNDLE = Boolean(process.env.BUNDLE)
+const BROWSERSTACK = Boolean(process.env.BROWSERSTACK)
+const JQUERY_FILE = USE_OLD_JQUERY ? 'https://code.jquery.com/jquery-1.9.1.min.js' : 'node_modules/jquery/dist/jquery.slim.min.js'
const frameworks = [
'qunit',
@@ -68,7 +68,7 @@ const conf = {
}
}
-if (bundle) {
+if (BUNDLE) {
frameworks.push('detectBrowsers')
plugins.push(
'karma-chrome-launcher',
@@ -78,10 +78,10 @@ if (bundle) {
conf.customLaunchers = customLaunchers
conf.detectBrowsers = detectBrowsers
files = files.concat([
- jqueryFile,
+ JQUERY_FILE,
'dist/js/bootstrap.js'
])
-} else if (browserStack) {
+} else if (BROWSERSTACK) {
conf.hostname = ip.address()
conf.browserStack = {
username: process.env.BROWSER_STACK_USERNAME,
@@ -98,35 +98,39 @@ if (bundle) {
'node_modules/jquery/dist/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
+ // include all of our js/dist files except util.js, index.js and tooltip.js
+ 'js/dist/!(util|index|tooltip).js'
])
} else {
frameworks.push('detectBrowsers')
plugins.push(
'karma-chrome-launcher',
'karma-firefox-launcher',
- 'karma-detect-browsers',
- 'karma-coverage-istanbul-reporter'
+ 'karma-detect-browsers'
)
files = files.concat([
- jqueryFile,
+ JQUERY_FILE,
'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
+ // include all of our js/dist files except util.js, index.js and tooltip.js
+ 'js/coverage/dist/!(util|index|tooltip).js'
])
- reporters.push('coverage-istanbul')
conf.customLaunchers = customLaunchers
conf.detectBrowsers = detectBrowsers
- conf.coverageIstanbulReporter = {
- dir: path.resolve(__dirname, '../coverage/'),
- reports: ['lcov', 'text-summary'],
- thresholds: {
- emitWarning: false,
- global: {
- statements: 90,
- branches: 86,
- functions: 89,
- lines: 90
+ 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
+ }
}
}
}
@@ -140,7 +144,6 @@ 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
+ conf.logLevel = karmaConfig.LOG_ERROR
karmaConfig.set(conf)
}
diff --git a/package.json b/package.json
index 46508742d..56e39b0dd 100644
--- a/package.json
+++ b/package.json
@@ -45,7 +45,7 @@
"js-test-karma-bundle": "cross-env BUNDLE=true npm run js-test-karma",
"js-test-karma-bundle-old": "cross-env BUNDLE=true USE_OLD_JQUERY=true npm run js-test-karma",
"js-test-integration": "rollup --config js/tests/integration/rollup.bundle.js",
- "js-test-cloud": "cross-env BROWSER=true npm run js-test-karma",
+ "js-test-cloud": "cross-env BROWSERSTACK=true npm run js-test-karma",
"lint": "npm-run-all --parallel js-lint css-lint lockfile-lint",
"docs": "npm-run-all docs-build docs-lint",
"docs-build": "hugo --cleanDestinationDir",