0
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-01-30 22:52:24 +01:00

JS: update karma config (#32769)

* rename constants
* enforce the constants to be Boolean
* fix karma `logLevel`
This commit is contained in:
XhmikosR 2021-01-13 19:16:51 +02:00 committed by GitHub
parent 05249c8c04
commit cad88abdb0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 17 deletions

View File

@ -1,5 +1,7 @@
/* eslint-env node */
'use strict'
const path = require('path')
const ip = require('ip')
const { babel } = require('@rollup/plugin-babel')
@ -12,10 +14,11 @@ const {
browsersKeys
} = require('./browsers')
const { env } = process
const browserStack = env.BROWSER === 'true'
const debug = env.DEBUG === 'true'
const jQueryTest = env.JQUERY === 'true'
const ENV = process.env
const BROWSERSTACK = Boolean(ENV.BROWSERSTACK)
const DEBUG = Boolean(ENV.DEBUG)
const JQUERY_TEST = Boolean(ENV.JQUERY)
const frameworks = [
'jasmine'
]
@ -30,16 +33,16 @@ const reporters = ['dots']
const detectBrowsers = {
usePhantomJS: false,
postDetection(availableBrowser) {
if (env.CI === true || availableBrowser.includes('Chrome')) {
return debug ? ['Chrome'] : ['ChromeHeadless']
if (ENV.CI === true || availableBrowser.includes('Chrome')) {
return DEBUG ? ['Chrome'] : ['ChromeHeadless']
}
if (availableBrowser.includes('Chromium')) {
return debug ? ['Chromium'] : ['ChromiumHeadless']
return DEBUG ? ['Chromium'] : ['ChromiumHeadless']
}
if (availableBrowser.includes('Firefox')) {
return debug ? ['Firefox'] : ['FirefoxHeadless']
return DEBUG ? ['Firefox'] : ['FirefoxHeadless']
}
throw new Error('Please install Chrome, Chromium or Firefox')
@ -67,7 +70,7 @@ const conf = {
'node_modules/hammer-simulator/index.js',
{
pattern: 'js/tests/unit/**/!(jquery).spec.js',
watched: !browserStack
watched: !BROWSERSTACK
}
],
preprocessors: {
@ -101,11 +104,11 @@ const conf = {
}
}
if (browserStack) {
if (BROWSERSTACK) {
conf.hostname = ip.address()
conf.browserStack = {
username: env.BROWSER_STACK_USERNAME,
accessKey: env.BROWSER_STACK_ACCESS_KEY,
username: ENV.BROWSER_STACK_USERNAME,
accessKey: ENV.BROWSER_STACK_ACCESS_KEY,
build: `bootstrap-${new Date().toISOString()}`,
project: 'Bootstrap',
retryLimit: 2
@ -114,7 +117,7 @@ if (browserStack) {
conf.customLaunchers = browsers
conf.browsers = browsersKeys
reporters.push('BrowserStack', 'kjhtml')
} else if (jQueryTest) {
} else if (JQUERY_TEST) {
frameworks.push('detectBrowsers')
plugins.push(
'karma-chrome-launcher',
@ -155,7 +158,7 @@ if (browserStack) {
}
}
if (debug) {
if (DEBUG) {
conf.hostname = ip.address()
plugins.push('karma-jasmine-html-reporter')
reporters.push('kjhtml')
@ -169,7 +172,6 @@ conf.plugins = plugins
conf.reporters = reporters
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)
}

View File

@ -51,7 +51,7 @@
"js-test-karma": "karma start js/tests/karma.conf.js",
"js-test-integration-bundle": "rollup --config js/tests/integration/rollup.bundle.js",
"js-test-integration-modularity": "rollup --config js/tests/integration/rollup.bundle-modularity.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",
"js-test-jquery": "cross-env JQUERY=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",