mirror of
https://github.com/twbs/bootstrap.git
synced 2025-08-16 02:24:19 +02:00
Allow us to run our unit test on differents jquery version
This commit is contained in:
@@ -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
55
js/tests/karma.conf.js
Normal 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')
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
@@ -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
5
js/tests/vendor/jquery-1.9.1.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user