Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run our unit tests on different jQuery versions #24749

Merged
merged 3 commits into from
Nov 23, 2017

Conversation

Johann-S
Copy link
Member

@Johann-S Johann-S commented Nov 10, 2017

I added a new devDeps because phantomjs do not allow to pass parameters in URL
BTW if this PR is accepted I'll change js-test-cloud to use our server task 👍

Add Karma to run our unit tests on ChromeHeadless instead of PhantomJS + it's allow us to run our unit tests on two jQuery versions

Fixes: #24705

@Johann-S Johann-S force-pushed the v4-dev-johann-tests-jquery-version branch from bd57641 to e6c6914 Compare November 10, 2017 10:31
package.json Outdated
@@ -61,7 +63,8 @@
"test": "npm-run-all dist js-test docs-compile docs-lint bundlesize",
"watch": "npm-run-all --parallel watch-css watch-js",
"watch-css": "nodemon --ignore js/ --ignore dist/ -e scss -x \"npm run css\"",
"watch-js": "nodemon --ignore scss/ --ignore js/dist/ --ignore dist/ -e js -x \"npm run js-compile\""
"watch-js": "nodemon --ignore scss/ --ignore js/dist/ --ignore dist/ -e js -x \"npm run js-compile\"",
"server": "http-server -s -p 3000"
Copy link
Member

Choose a reason for hiding this comment

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

Not sure this makes sense in this branch since we already need Ruby.

I did this in my Hugo branch because the Ruby dep is removed.

Copy link
Member

Choose a reason for hiding this comment

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

OK, now I read you comment about phantom.

Why do we need phantom anyway? Can't we use jsdom or Chrome/Firefox headless?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep that's a possible switch because phantomjs won't receive any fixes

@@ -0,0 +1,11 @@
(function () {
var path = '../../assets/js/vendor/jquery-slim.min.js'
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we don't need this new file at all? It's a small snippet so perhaps we could have it in the HTML file?

Copy link
Member Author

Choose a reason for hiding this comment

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

yep sure 👍

@XhmikosR
Copy link
Member

IMO you should revert the http-server switch here; it doesn't make things better since we already need Ruby for Jekyll.

Also, the js-tests will probably need to be run sequentially; we can't use the same port simultaneously.

@Johann-S
Copy link
Member Author

My main issue here is how to launch a npm task in background and lauch our qunit tests 😟

@Johann-S Johann-S changed the title Allow us to run our unit test on differents jquery version [WIP] Allow us to run our unit test on differents jquery version Nov 10, 2017
@Johann-S Johann-S force-pushed the v4-dev-johann-tests-jquery-version branch 2 times, most recently from b17c962 to e8d0378 Compare November 10, 2017 12:44
@Johann-S
Copy link
Member Author

I added Karma to run our test on ChromeHeadless it's possible to add FirefoxHeadless too so if it's wanted do not hesitate 👍

With this implementation we can run our unit tests on jQuery 1.9.1 and the latest release of jQuery 3

@@ -29,6 +29,8 @@ $(function () {
$.fn.bootstrapModal = $.fn.modal.noConflict()
},
afterEach: function () {
$('.modal-backdrop, #modal-test').remove()
$(document.body).removeClass('modal-open')
Copy link
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
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
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

@Johann-S Johann-S changed the title [WIP] Allow us to run our unit test on differents jquery version Allow us to run our unit test on differents jquery version Nov 12, 2017
@Johann-S Johann-S force-pushed the v4-dev-johann-tests-jquery-version branch 2 times, most recently from fd23f0d to 95fdf6a Compare November 16, 2017 12:39
karma.conf.js Outdated
// list of files / patterns to load in the browser
files: [
jQueryVersion,
jqueryFile,
'assets/js/vendor/popper.min.js',
'js/dist/util.js',
Copy link
Member

Choose a reason for hiding this comment

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

Would it work if we did js/dist*.js and just excluded index.js? Or even just include everything?

Copy link
Member Author

Choose a reason for hiding this comment

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

Nope because we have to be sure util.js is the first included script

@Johann-S
Copy link
Member Author

I made a test using jsdom and it's not possible because jsdom do not have document.createRange function which is used in Popper.js

@Johann-S Johann-S force-pushed the v4-dev-johann-tests-jquery-version branch 3 times, most recently from 6bac084 to a1b850b Compare November 16, 2017 14:04
@Johann-S
Copy link
Member Author

Johann-S commented Nov 16, 2017

@XhmikosR I changed the reporter, and now we use wildcard to include our dist files and added Firefox launcher

karma.conf.js Outdated
@@ -0,0 +1,39 @@
module.exports = function (config) {
const jqueryFile = process.env.USE_OLD_JQUERY === 'true' ? 'js/tests/vendor/jquery-1.9.1.min.js' : 'assets/js/vendor/jquery-slim.min.js'
Copy link
Member

Choose a reason for hiding this comment

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

Maybe process.env.USE_OLD_JQUERY would be enough?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't understand what you mean here 😟

Copy link
Member

Choose a reason for hiding this comment

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

I was wondering, wouldn't this be enough?

const jqueryFile = process.env.USE_OLD_JQUERY ? 'js/tests/vendor/jquery-1.9.1.min.js' : 'assets/js/vendor/jquery-slim.min.js'

Oh, and perhaps we should only change the filename and keep the path since it's common?

@Johann-S Johann-S force-pushed the v4-dev-johann-tests-jquery-version branch from 4cf67ea to 1c88c55 Compare November 16, 2017 21:42
@XhmikosR XhmikosR changed the title Allow us to run our unit test on differents jquery version Run our unit tests on different jQuery versions Nov 17, 2017
@XhmikosR XhmikosR removed the on-hold label Nov 17, 2017
@Johann-S Johann-S force-pushed the v4-dev-johann-tests-jquery-version branch from ecfc5a8 to 5cbf19f Compare November 17, 2017 08:29
@Johann-S Johann-S force-pushed the v4-dev-johann-tests-jquery-version branch from 5cbf19f to 45b5107 Compare November 17, 2017 08:45
@Johann-S
Copy link
Member Author

Do you have any concerns about that PR @mdo ? Or can we merge ?

@FezVrasta
Copy link
Contributor

About Popper.js on jsdom, the suggested way is to mock Popper.js away directly since it can't work on a jsdom environment even if you polyfill everything that's required.

@Johann-S
Copy link
Member Author

Seems better in parallel @XhmikosR 👍

@Johann-S Johann-S force-pushed the v4-dev-johann-tests-jquery-version branch from fe9f627 to 069ab73 Compare November 20, 2017 08:28
@Johann-S Johann-S force-pushed the v4-dev-johann-tests-jquery-version branch from 069ab73 to 27e0129 Compare November 21, 2017 21:02
@XhmikosR XhmikosR merged commit 68ca294 into v4-dev Nov 23, 2017
@XhmikosR XhmikosR deleted the v4-dev-johann-tests-jquery-version branch November 23, 2017 08:42
@mdo mdo mentioned this pull request Nov 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants