1
0
Fork 0
mirror of https://github.com/twbs/bootstrap.git synced 2022-11-09 12:25:43 -05:00

Allow us to run our unit test on differents jquery version

This commit is contained in:
Johann-S 2017-11-10 11:25:47 +01:00 committed by XhmikosR
parent cdab56d940
commit e8ba37139f
6 changed files with 1058 additions and 203 deletions

View file

@ -6,7 +6,19 @@
<title>Bootstrap Plugin Test Suite</title>
<!-- jQuery -->
<script src="../../assets/js/vendor/jquery-slim.min.js"></script>
<script>
(function () {
var path = '../../assets/js/vendor/jquery-slim.min.js'
// get jquery param from the query string.
var jQueryVersion = location.search.match(/[?&]jquery=(.*?)(?=&|$)/)
// If a version was specified, use that version from our vendor folder
if (jQueryVersion) {
path = 'vendor/jquery-' + jQueryVersion[1] + '.min.js'
}
document.write('<script src="' + path + '"><\/script>')
}())
</script>
<script src="../../assets/js/vendor/popper.min.js"></script>
<!-- QUnit -->
@ -77,11 +89,6 @@
})
})
// Cleanup
QUnit.testDone(function () {
$('#modal-test, .modal-backdrop').remove()
})
// Display fixture on-screen on iOS to avoid false positives
// See https://github.com/twbs/bootstrap/pull/15955
if (/iPhone|iPad|iPod/.test(navigator.userAgent)) {

55
js/tests/karma.conf.js Normal file
View file

@ -0,0 +1,55 @@
/* eslint-env node */
'use strict'
module.exports = (config) => {
const jqueryFile = process.env.USE_OLD_JQUERY ? 'js/tests/vendor/jquery-1.9.1.min.js' : 'assets/js/vendor/jquery-slim.min.js'
config.set({
basePath: '../..',
frameworks: ['qunit', 'detectBrowsers'],
plugins: [
'karma-chrome-launcher',
'karma-firefox-launcher',
'karma-qunit',
'karma-detect-browsers'
],
// list of files / patterns to load in the browser
files: [
jqueryFile,
'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
'js/tests/unit/*.js'
],
reporters: ['dots'],
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')
}
}
})
}

View file

@ -29,6 +29,8 @@ $(function () {
$.fn.bootstrapModal = $.fn.modal.noConflict()
},
afterEach: function () {
$('.modal-backdrop, #modal-test').remove()
$(document.body).removeClass('modal-open')
$.fn.modal = $.fn.bootstrapModal
delete $.fn.bootstrapModal
}

5
js/tests/vendor/jquery-1.9.1.min.js vendored Normal file

File diff suppressed because one or more lines are too long

1171
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -42,7 +42,7 @@
"js-minify-standalone": "uglifyjs --compress typeofs=false --mangle --comments \"/^!/\" --source-map \"content=dist/js/bootstrap.js.map,includeSources,url=bootstrap.min.js.map\" --output dist/js/bootstrap.min.js dist/js/bootstrap.js",
"js-minify-bundle": "uglifyjs --compress typeofs=false --mangle --comments \"/^!/\" --source-map \"content=dist/js/bootstrap.bundle.js.map,includeSources,url=bootstrap.bundle.min.js.map\" --output dist/js/bootstrap.bundle.min.js dist/js/bootstrap.bundle.js",
"js-minify-docs": "uglifyjs --mangle --comments \"/^!/\" --output assets/js/docs.min.js assets/js/vendor/anchor.min.js assets/js/vendor/clipboard.min.js assets/js/vendor/holder.min.js \"assets/js/src/*.js\"",
"js-test": "phantomjs ./node_modules/qunit-phantomjs-runner/runner.js js/tests/index.html 60",
"js-test": "cross-env USE_OLD_JQUERY=true karma start js/tests/karma.conf.js && karma start js/tests/karma.conf.js",
"js-test-cloud": "ruby -r webrick -e \"s = WEBrick::HTTPServer.new(:Port => 3000, :DocumentRoot => Dir.pwd, :Logger => WEBrick::Log.new('/dev/null'), :AccessLog => []); trap('INT') { s.shutdown }; s.start\" & node build/saucelabs-unit-test.js",
"docs": "npm-run-all --parallel css-docs js-docs --sequential docs-compile docs-lint",
"docs-compile": "bundle exec jekyll build",
@ -94,13 +94,16 @@
"eslint-plugin-compat": "^2.1.0",
"htmllint-cli": "^0.0.6",
"jsunitsaucelabs": "^1.3.0",
"karma": "^1.7.1",
"karma-chrome-launcher": "^2.2.0",
"karma-detect-browsers": "^2.2.6",
"karma-firefox-launcher": "^1.0.1",
"karma-qunit": "^1.2.1",
"node-sass": "^4.7.1",
"nodemon": "^1.12.1",
"npm-run-all": "^4.1.2",
"phantomjs-prebuilt": "^2.1.16",
"popper.js": "^1.12.9",
"postcss-cli": "^4.1.1",
"qunit-phantomjs-runner": "^2.3.0",
"qunitjs": "^2.4.1",
"rollup": "^0.51.8",
"rollup-plugin-babel": "4.0.0-beta.0",