1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-08-30 16:50:00 +02:00

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`
This commit is contained in:
XhmikosR
2021-01-12 15:25:03 +02:00
parent f8da510367
commit 0f1069a32e
2 changed files with 32 additions and 29 deletions

View File

@@ -1,15 +1,15 @@
/* eslint-env node */ /* eslint-env node */
'use strict'
const path = require('path') const path = require('path')
const ip = require('ip') const ip = require('ip')
const { const { browsers, browsersKeys } = require('./browsers')
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 USE_OLD_JQUERY = Boolean(process.env.USE_OLD_JQUERY)
const bundle = process.env.BUNDLE === 'true' const BUNDLE = Boolean(process.env.BUNDLE)
const browserStack = process.env.BROWSER === 'true' 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 = [ const frameworks = [
'qunit', 'qunit',
@@ -68,7 +68,7 @@ const conf = {
} }
} }
if (bundle) { if (BUNDLE) {
frameworks.push('detectBrowsers') frameworks.push('detectBrowsers')
plugins.push( plugins.push(
'karma-chrome-launcher', 'karma-chrome-launcher',
@@ -78,10 +78,10 @@ if (bundle) {
conf.customLaunchers = customLaunchers conf.customLaunchers = customLaunchers
conf.detectBrowsers = detectBrowsers conf.detectBrowsers = detectBrowsers
files = files.concat([ files = files.concat([
jqueryFile, JQUERY_FILE,
'dist/js/bootstrap.js' 'dist/js/bootstrap.js'
]) ])
} else if (browserStack) { } else if (BROWSERSTACK) {
conf.hostname = ip.address() conf.hostname = ip.address()
conf.browserStack = { conf.browserStack = {
username: process.env.BROWSER_STACK_USERNAME, username: process.env.BROWSER_STACK_USERNAME,
@@ -98,35 +98,39 @@ if (bundle) {
'node_modules/jquery/dist/jquery.slim.min.js', 'node_modules/jquery/dist/jquery.slim.min.js',
'js/dist/util.js', 'js/dist/util.js',
'js/dist/tooltip.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 { } else {
frameworks.push('detectBrowsers') frameworks.push('detectBrowsers')
plugins.push( plugins.push(
'karma-chrome-launcher', 'karma-chrome-launcher',
'karma-firefox-launcher', 'karma-firefox-launcher',
'karma-detect-browsers', 'karma-detect-browsers'
'karma-coverage-istanbul-reporter'
) )
files = files.concat([ files = files.concat([
jqueryFile, JQUERY_FILE,
'js/coverage/dist/util.js', 'js/coverage/dist/util.js',
'js/coverage/dist/tooltip.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.customLaunchers = customLaunchers
conf.detectBrowsers = detectBrowsers conf.detectBrowsers = detectBrowsers
conf.coverageIstanbulReporter = { if (!USE_OLD_JQUERY) {
dir: path.resolve(__dirname, '../coverage/'), plugins.push('karma-coverage-istanbul-reporter')
reports: ['lcov', 'text-summary'], reporters.push('coverage-istanbul')
thresholds: { conf.coverageIstanbulReporter = {
emitWarning: false, dir: path.resolve(__dirname, '../coverage/'),
global: { reports: ['lcov', 'text-summary'],
statements: 90, thresholds: {
branches: 86, emitWarning: false,
functions: 89, global: {
lines: 90 statements: 90,
branches: 86,
functions: 89,
lines: 90
}
} }
} }
} }
@@ -140,7 +144,6 @@ conf.reporters = reporters
conf.files = files conf.files = files
module.exports = karmaConfig => { 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
conf.logLevel = karmaConfig.LOG_ERROR || karmaConfig.LOG_WARN
karmaConfig.set(conf) karmaConfig.set(conf)
} }

View File

@@ -45,7 +45,7 @@
"js-test-karma-bundle": "cross-env BUNDLE=true npm run js-test-karma", "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-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-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", "lint": "npm-run-all --parallel js-lint css-lint lockfile-lint",
"docs": "npm-run-all docs-build docs-lint", "docs": "npm-run-all docs-build docs-lint",
"docs-build": "hugo --cleanDestinationDir", "docs-build": "hugo --cleanDestinationDir",