Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions js/tests/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 -->
Expand Down Expand Up @@ -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)) {
Expand Down
55 changes: 55 additions & 0 deletions js/tests/karma.conf.js
Original file line number Diff line number Diff line change
@@ -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')
}
}
})
}
2 changes: 2 additions & 0 deletions js/tests/unit/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ $(function () {
$.fn.bootstrapModal = $.fn.modal.noConflict()
},
afterEach: function () {
$('.modal-backdrop, #modal-test').remove()
$(document.body).removeClass('modal-open')
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added that because in our index.html which run our unit test we did the same see : https://github.com/twbs/bootstrap/blob/v4-dev/js/tests/index.html#L82

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But do we need to do it in modal.js if we do it in index.html?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Karma do not use our index.html it generate a new index.html

$.fn.modal = $.fn.bootstrapModal
delete $.fn.bootstrapModal
}
Expand Down
5 changes: 5 additions & 0 deletions js/tests/vendor/jquery-1.9.1.min.js

Large diffs are not rendered by default.

Loading