-
-
Notifications
You must be signed in to change notification settings - Fork 78.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
134 additions
and
172 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,76 +1,142 @@ | ||
/* eslint-env node */ | ||
/* eslint no-process-env: 0 */ | ||
const ip = require('ip') | ||
const { | ||
browsers, | ||
browsersKeys | ||
} = require('./browsers') | ||
const path = require('path') | ||
const jsCoveragePath = path.resolve(__dirname, '../coverage') | ||
|
||
module.exports = (config) => { | ||
const jqueryFile = process.env.USE_OLD_JQUERY ? 'https://code.jquery.com/jquery-1.9.1.min.js' : 'site/docs/4.1/assets/js/vendor/jquery-slim.min.js' | ||
const jqueryFile = process.env.USE_OLD_JQUERY ? 'https://code.jquery.com/jquery-1.9.1.min.js' : 'site/docs/4.1/assets/js/vendor/jquery-slim.min.js' | ||
const bundle = process.env.BUNDLE === 'true' | ||
const browserStack = process.env.BROWSER === 'true' | ||
|
||
config.set({ | ||
basePath: '../..', | ||
frameworks: ['qunit', 'sinon', 'detectBrowsers'], | ||
plugins: [ | ||
'karma-chrome-launcher', | ||
'karma-firefox-launcher', | ||
'karma-qunit', | ||
'karma-sinon', | ||
'karma-detect-browsers', | ||
'karma-coverage-istanbul-reporter' | ||
], | ||
// list of files / patterns to load in the browser | ||
files: [ | ||
jqueryFile, | ||
'site/docs/4.1/assets/js/vendor/popper.min.js', | ||
'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 | ||
'js/tests/unit/*.js' | ||
], | ||
reporters: ['dots', 'coverage-istanbul'], | ||
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'] | ||
} | ||
const frameworks = [ | ||
'qunit', | ||
'sinon' | ||
] | ||
|
||
if (availableBrowser.includes('Firefox')) { | ||
return ['FirefoxHeadless'] | ||
} | ||
const plugins = [ | ||
'karma-qunit', | ||
'karma-sinon' | ||
] | ||
|
||
throw new Error('Please install Firefox or Chrome') | ||
} | ||
}, | ||
coverageIstanbulReporter: { | ||
dir: jsCoveragePath, | ||
reports: ['lcov', 'text-summary'], | ||
thresholds: { | ||
emitWarning: false, | ||
global: { | ||
statements: 90, | ||
branches: 84, | ||
functions: 87, | ||
lines: 90 | ||
} | ||
} | ||
}, | ||
client: { | ||
qunit: { | ||
showUI: true | ||
const reporters = ['dots'] | ||
|
||
const 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') | ||
} | ||
} | ||
|
||
const customLaunchers = { | ||
FirefoxHeadless: { | ||
base: 'Firefox', | ||
flags: ['-headless'] | ||
} | ||
} | ||
|
||
let files | ||
const conf = { | ||
basePath: '../..', | ||
port: 9876, | ||
colors: true, | ||
autoWatch: false, | ||
singleRun: true, | ||
concurrency: Infinity, | ||
client: { | ||
qunit: { | ||
showUI: true | ||
} | ||
} | ||
} | ||
|
||
if (bundle) { | ||
frameworks.push('detectBrowsers') | ||
plugins.push( | ||
'karma-chrome-launcher', | ||
'karma-firefox-launcher', | ||
'karma-detect-browsers' | ||
) | ||
conf.customLaunchers = customLaunchers | ||
conf.detectBrowsers = detectBrowsers | ||
files = files.concat([ | ||
jqueryFile, | ||
'site/docs/4.1/assets/js/vendor/popper.min.js', | ||
'dist/js/bootstrap.js' | ||
]) | ||
} else if (browserStack) { | ||
conf.hostname = ip.address() | ||
conf.browserStack = { | ||
username: process.env.BROWSER_STACK_USERNAME, | ||
accessKey: process.env.BROWSER_STACK_ACCESS_KEY, | ||
build: `bootstrap-${new Date().toISOString()}`, | ||
project: 'Bootstrap', | ||
retryLimit: 2 | ||
} | ||
plugins.push('karma-browserstack-launcher') | ||
conf.customLaunchers = browsers | ||
conf.browsers = browsersKeys | ||
reporters.push('BrowserStack') | ||
files = files.concat([ | ||
'site/docs/4.1/assets/js/vendor/jquery-slim.min.js', | ||
'site/docs/4.1/assets/js/vendor/popper.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 | ||
]) | ||
} else { | ||
frameworks.push('detectBrowsers') | ||
plugins.push( | ||
'karma-chrome-launcher', | ||
'karma-firefox-launcher', | ||
'karma-detect-browsers', | ||
'karma-coverage-istanbul-reporter' | ||
) | ||
files = files.concat([ | ||
jqueryFile, | ||
'site/docs/4.1/assets/js/vendor/popper.min.js', | ||
'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 | ||
]) | ||
reporters.push('coverage-istanbul') | ||
conf.customLaunchers = customLaunchers | ||
conf.detectBrowsers = detectBrowsers | ||
conf.coverageIstanbulReporter = { | ||
dir: jsCoveragePath, | ||
reports: ['lcov', 'text-summary'], | ||
thresholds: { | ||
emitWarning: false, | ||
global: { | ||
statements: 90, | ||
branches: 84, | ||
functions: 87, | ||
lines: 90 | ||
} | ||
} | ||
}) | ||
} | ||
} | ||
|
||
files.push('js/tests/unit/*.js') | ||
|
||
conf.frameworks = frameworks | ||
conf.plugins = plugins | ||
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 | ||
karmaConfig.set(conf) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters