Skip to content

Commit

Permalink
tests(jQuery): test on both oldest & latest supported jQuery version
Browse files Browse the repository at this point in the history
  • Loading branch information
mgol committed Mar 13, 2016
1 parent e01419e commit 244ce08
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 10 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ env:
- JOB=unit BROWSER_PROVIDER=saucelabs
- JOB=docs-e2e BROWSER_PROVIDER=saucelabs
- JOB=e2e TEST_TARGET=jqlite BROWSER_PROVIDER=saucelabs
- JOB=e2e TEST_TARGET=jquery-old BROWSER_PROVIDER=saucelabs

This comment has been minimized.

Copy link
@petebacondarwin

petebacondarwin Mar 14, 2016

I feel sad that we have jquery-old. What happens if we started testing on more than two versions?
How about we have jquery21 and jquery22, then it will be cleaner to add jquery30 later.

This comment has been minimized.

Copy link
@mgol

mgol Mar 14, 2016

Author Owner

I'd like to keep jquery as the latest tested target because it's included in many places that only run on one jQuery version & updating them all would increase the diff significantly. Those are things like the docs site or Protractor tests.

I can definitely change jquery-old to jquery21, though. Would that be fine?

Note that while we'll soon only have 3 versions to test (2.1.4, 2.2.2 & 3.0.0), after 3.0.0 we'll try to release more often and I doubt we'd want to test 5 versions here. :)

This comment has been minimized.

Copy link
@petebacondarwin

petebacondarwin Mar 14, 2016

That works for me!

- JOB=e2e TEST_TARGET=jquery BROWSER_PROVIDER=saucelabs
global:
- CXX=g++-4.8 # node 4 likes the G++ v4.8 compiler
Expand Down
7 changes: 5 additions & 2 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ module.exports = function(grunt) {
tests: {
jqlite: 'karma-jqlite.conf.js',
jquery: 'karma-jquery.conf.js',
'jquery-old': 'karma-jquery-old.conf.js',
docs: 'karma-docs.conf.js',
modules: 'karma-modules.conf.js'
},
Expand All @@ -87,6 +88,7 @@ module.exports = function(grunt) {
autotest: {
jqlite: 'karma-jqlite.conf.js',
jquery: 'karma-jquery.conf.js',
'jquery-old': 'karma-jquery-old.conf.js',
modules: 'karma-modules.conf.js',
docs: 'karma-docs.conf.js'
},
Expand Down Expand Up @@ -344,10 +346,11 @@ module.exports = function(grunt) {
//alias tasks
grunt.registerTask('test', 'Run unit, docs and e2e tests with Karma', ['jshint', 'jscs', 'package', 'test:unit', 'test:promises-aplus', 'tests:docs', 'test:protractor']);
grunt.registerTask('test:jqlite', 'Run the unit tests with Karma' , ['tests:jqlite']);
grunt.registerTask('test:jquery', 'Run the jQuery unit tests with Karma', ['tests:jquery']);
grunt.registerTask('test:jquery', 'Run the jQuery (latest) unit tests with Karma', ['tests:jquery']);
grunt.registerTask('test:jquery-old', 'Run the jQuery 2.1 unit tests with Karma', ['tests:jquery-old']);
grunt.registerTask('test:modules', 'Run the Karma module tests with Karma', ['build', 'tests:modules']);
grunt.registerTask('test:docs', 'Run the doc-page tests with Karma', ['package', 'tests:docs']);
grunt.registerTask('test:unit', 'Run unit, jQuery and Karma module tests with Karma', ['test:jqlite', 'test:jquery', 'test:modules']);
grunt.registerTask('test:unit', 'Run unit, jQuery and Karma module tests with Karma', ['test:jqlite', 'test:jquery', 'test:jquery-old', 'test:modules']);
grunt.registerTask('test:protractor', 'Run the end to end tests with Protractor and keep a test server running in the background', ['webdriver', 'connect:testserver', 'protractor:normal']);
grunt.registerTask('test:travis-protractor', 'Run the end to end tests with Protractor for Travis CI builds', ['connect:testserver', 'protractor:travis']);
grunt.registerTask('test:ci-protractor', 'Run the end to end tests with Protractor for Jenkins CI builds', ['webdriver', 'connect:testserver', 'protractor:jenkins']);
Expand Down
9 changes: 9 additions & 0 deletions angularFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,15 @@ var angularFiles = {
'@angularTest'
],

'karmaJqueryOld': [
'bower_components/jquery-old/dist/jquery.js',
'test/jquery_alias.js',
'@angularSrc',
'@angularSrcModules',
'@angularScenario',
'@angularTest'
],

'karmaJqueryExclude': [
'src/angular-bootstrap.js',
'src/ngScenario/angular-bootstrap.js',
Expand Down
3 changes: 2 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"name": "AngularJS",
"license": "MIT",
"devDependencies": {
"jquery": "2.1.1",
"jquery": "2.2.1",
"jquery-old": "jquery#2.1.4",
"closure-compiler": "https://dl.google.com/closure-compiler/compiler-20140814.zip",
"ng-closure-runner": "https://raw.github.com/angular/ng-closure-runner/v0.2.3/assets/ng-closure-runner.zip"
}
Expand Down
2 changes: 1 addition & 1 deletion docs/bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "AngularJS-docs-app",
"dependencies": {
"jquery": "2.1.1",
"jquery": "2.2.1",
"lunr.js": "0.5.12",
"open-sans-fontface": "1.0.4",
"google-code-prettify": "1.0.1",
Expand Down
2 changes: 1 addition & 1 deletion docs/content/tutorial/step_07.ngdoc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ We are using [Bower][bower] to install client-side dependencies. This step upda
"dependencies": {
"angular": "1.4.x",
"angular-mocks": "1.4.x",
"jquery": "~2.1.1",

This comment has been minimized.

Copy link
@petebacondarwin

petebacondarwin Mar 14, 2016

We'll need to ensure that @gkalpak includes this change in his work on phonecat

This comment has been minimized.

Copy link
@gkalpak

gkalpak Apr 3, 2016

@mgol, I opted for jquery: 2.x in the tutorial. Is there any reason that's not a good idea ?

This comment has been minimized.

Copy link
@petebacondarwin

petebacondarwin via email Apr 3, 2016

This comment has been minimized.

Copy link
@gkalpak

gkalpak Apr 3, 2016

2.x (Not sure what you mean 😁)

This comment has been minimized.

Copy link
@petebacondarwin

petebacondarwin Apr 3, 2016

2.1, 2.2 etc :-)

This comment has been minimized.

Copy link
@gkalpak

gkalpak Apr 3, 2016

2.x will install the latest version of 2.x. E.g. when 2.3.0 is out, ti will install that.
In the tutorial app, we only are only using .animate() from jQuery and I figured Angular itself should stay compatible with the latest 2.x branch of jQuery, so I thought: Why not get the latest and greatest 2.x jQuery available ? 😃

This comment has been minimized.

Copy link
@mgol

mgol Apr 4, 2016

Author Owner

From the semver point of view 2.x === 2 === 2.x.x if you only look at the latest matching version (i.e. what npm install will install with such an entry in package.json) so the .x part is superflous. I'd advise to not pin the jQuery dependency only to the major, though. While we now follow semver and we avoid breaking changes in the minor bumps (1.11/2.1 were the last releases not following that pattern) this is a DOM library and our experience shows every little change breaks something in the wild. Even bumping the patch might break something. I'd advise to either pin the version completely or maybe just leave it the current way, i.e. pin it to the minor.

BTW, the current version is 2.2.2 and we'll be releasing 2.2.3 soon. For now it shouldn't matter if you put 2 or ~2.2 there as we don't plan to release 2.3 but it's a matter of encouraging safe practices looking into the future.

This comment has been minimized.

Copy link
@mgol

mgol Apr 4, 2016

Author Owner

BTW, Angular 1.x should stay compatible with jQuery 3 as well. ;)

This comment has been minimized.

Copy link
@gkalpak

gkalpak Apr 5, 2016

OK, I changed it to 2.2.X. Thx !

This comment has been minimized.

Copy link
@mgol

mgol Apr 5, 2016

Author Owner

I usually don't use .x but the ~ instead as I have more control then. E.g. I could now specify ~2.2.3 and I know every one that followed the guide will have this version or newer.

"jquery": "~2.2.1",
"bootstrap": "~3.1.1",
"angular-route": "1.4.x"
}
Expand Down
2 changes: 1 addition & 1 deletion docs/content/tutorial/step_11.ngdoc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ We are using [Bower][bower] to install client side dependencies. This step upda
"dependencies": {
"angular": "1.4.x",
"angular-mocks": "1.4.x",
"jquery": "~2.1.1",
"jquery": "~2.2.1",
"bootstrap": "~3.1.1",
"angular-route": "1.4.x",
"angular-resource": "1.4.x"
Expand Down
4 changes: 2 additions & 2 deletions docs/content/tutorial/step_12.ngdoc
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ We are using [Bower][bower] to install client side dependencies. This step upda
"dependencies": {
"angular": "1.4.x",
"angular-mocks": "1.4.x",
"jquery": "~2.1.1",
"jquery": "~2.2.1",
"bootstrap": "~3.1.1",
"angular-route": "1.4.x",
"angular-resource": "1.4.x",
Expand All @@ -49,7 +49,7 @@ We are using [Bower][bower] to install client side dependencies. This step upda

* `"angular-animate": "1.4.x"` tells bower to install a version of the
angular-animate component that is compatible with version 1.4.x.
* `"jquery": "~2.1.1"` tells bower to install the 2.1.1 version of jQuery. Note that this is not an
* `"jquery": "~2.2.1"` tells bower to install the 2.2.1 version of jQuery. Note that this is not an
Angular library, it is the standard jQuery library. We can use bower to install a wide range of 3rd
party libraries.

Expand Down
18 changes: 18 additions & 0 deletions karma-jquery-old.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
'use strict';

var angularFiles = require('./angularFiles');
var sharedConfig = require('./karma-shared.conf');

module.exports = function(config) {
sharedConfig(config, {testName: 'AngularJS: jQuery', logFile: 'karma-jquery.log'});

config.set({
files: angularFiles.mergeFilesFor('karmaJqueryOld'),
exclude: angularFiles.mergeFilesFor('karmaJqueryExclude'),

junitReporter: {
outputFile: 'test_out/jquery.xml',
suite: 'jQuery'
}
});
};
4 changes: 2 additions & 2 deletions scripts/travis/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ elif [ $JOB = "unit" ]; then
elif [ $JOB = "docs-e2e" ]; then
grunt test:travis-protractor --specs "docs/app/e2e/**/*.scenario.js"
elif [ $JOB = "e2e" ]; then
if [ $TEST_TARGET = "jquery" ]; then
if [ $TEST_TARGET = "jquery" -o $TEST_TARGET = "jquery-old" ]; then

This comment has been minimized.

Copy link
@petebacondarwin

petebacondarwin Mar 14, 2016

Could this be made more generic (and future proof) with:

if [[ $TEST_TARGET == jquery* ]]; then

This uses the double square bracket test which allows pattern matching

export USE_JQUERY=1
fi

export TARGET_SPECS="build/docs/ptore2e/**/default_test.js"
if [ $TEST_TARGET = "jquery" ]; then
if [ $TEST_TARGET = "jquery" -o $TEST_TARGET = "jquery-old" ]; then
TARGET_SPECS="build/docs/ptore2e/**/jquery_test.js"
fi

Expand Down

0 comments on commit 244ce08

Please sign in to comment.