Hook up with SauceLabs
This sets up Select2 to be able to run tests on the SauceLabs environment. This will allow us to run the tests on different browsers in the future, though at the moment we need to start combining test files. This required adding a snippet of code for reporting QUnit test results to SauceLabs within the global test helper file. The tests currently cannot be run on IE 8 because all of the tests are using jQuery 2.x, which is not compatible.
This commit is contained in:
parent
d51570e1fe
commit
a0c26e1114
10
.travis.yml
10
.travis.yml
@ -1,8 +1,16 @@
|
||||
language: node_js
|
||||
|
||||
node_js:
|
||||
- 0.10
|
||||
|
||||
env:
|
||||
global:
|
||||
- secure: XMNK8GVxkwKa6oLl7nJwgg/wmY1YDk5rrMd+UXz26EDCsMDbiy1P7GhN2fEiBSLaQ7YfEuvaDcmzQxTrT0YTHp1PDzb2o9J4tIDdEkqPcv1y8xMaYDfmsN0rBPdBwZEg9H5zUgi7OdUbrGswSYxsKCE3x8EOqK89104HyOo1LN4=
|
||||
- secure: BU5BPRx6H4O3WJ509YPixjUxg+hDF3z2BVJX6NiGmKWweqvCEYFfiiHLwDEgp/ynRcF9vGVi1V4Ly1jq7f8NIajbDZ5q443XchZFYFg78K/EwD5mK6LYt16zb7+Jn0KbzwHeGRGzc9AvcEYlW6i634cSCm4n3BnqtF5PpogSzdw=
|
||||
|
||||
script:
|
||||
- grunt compile test
|
||||
- grunt ci
|
||||
|
||||
notifications:
|
||||
email: false
|
||||
irc:
|
||||
|
62
Gruntfile.js
62
Gruntfile.js
@ -29,6 +29,21 @@ module.exports = function (grunt) {
|
||||
cwd: 'src/js'
|
||||
}, 'select2/i18n/*.js');
|
||||
|
||||
var testFiles = grunt.file.expand('tests/**/*.html');
|
||||
var testUrls = testFiles.map(function (filePath) {
|
||||
return 'http://localhost:9999/' + filePath;
|
||||
});
|
||||
|
||||
var testBuildNumber = "unknown";
|
||||
|
||||
if (process.env.TRAVIS_JOB_ID) {
|
||||
testBuildNumber = "travis-" + process.env.TRAVIS_JOB_ID;
|
||||
} else {
|
||||
var currentTime = new Date();
|
||||
|
||||
testBuildNumber = "manual-" + currentTime.getTime();
|
||||
}
|
||||
|
||||
for (var i = 0; i < i18nFiles.length; i++) {
|
||||
var file = i18nFiles[i];
|
||||
var name = file.split('.')[0];
|
||||
@ -45,6 +60,16 @@ module.exports = function (grunt) {
|
||||
docs: ['docs/_site']
|
||||
},
|
||||
|
||||
connect: {
|
||||
tests: {
|
||||
options: {
|
||||
base: '.',
|
||||
hostname: '127.0.0.1',
|
||||
port: 9999
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
uglify: {
|
||||
'dist': {
|
||||
src: 'dist/js/select2.js',
|
||||
@ -57,9 +82,36 @@ module.exports = function (grunt) {
|
||||
},
|
||||
|
||||
qunit: {
|
||||
all: [
|
||||
'tests/**/*.html'
|
||||
]
|
||||
all: {
|
||||
options: {
|
||||
urls: testUrls
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
'saucelabs-qunit': {
|
||||
all: {
|
||||
options: {
|
||||
build: testBuildNumber,
|
||||
tags: ['tests', 'qunit'],
|
||||
urls: testUrls,
|
||||
testname: 'QUnit test for Select2',
|
||||
browsers: [
|
||||
{
|
||||
browserName: 'internet explorer',
|
||||
version: '9'
|
||||
},
|
||||
|
||||
{
|
||||
browserName: 'firefox'
|
||||
},
|
||||
|
||||
{
|
||||
browserName: 'chrome'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
'gh-pages': {
|
||||
@ -234,6 +286,7 @@ module.exports = function (grunt) {
|
||||
|
||||
grunt.loadNpmTasks('grunt-contrib-clean');
|
||||
grunt.loadNpmTasks('grunt-contrib-concat');
|
||||
grunt.loadNpmTasks('grunt-contrib-connect');
|
||||
grunt.loadNpmTasks('grunt-contrib-jshint');
|
||||
grunt.loadNpmTasks('grunt-contrib-qunit');
|
||||
grunt.loadNpmTasks('grunt-contrib-requirejs');
|
||||
@ -243,6 +296,7 @@ module.exports = function (grunt) {
|
||||
|
||||
grunt.loadNpmTasks('grunt-gh-pages');
|
||||
grunt.loadNpmTasks('grunt-jekyll');
|
||||
grunt.loadNpmTasks('grunt-saucelabs');
|
||||
grunt.loadNpmTasks('grunt-sass');
|
||||
|
||||
grunt.registerTask('default', ['compile', 'test', 'minify']);
|
||||
@ -251,6 +305,8 @@ module.exports = function (grunt) {
|
||||
grunt.registerTask('minify', ['uglify', 'sass:dist']);
|
||||
grunt.registerTask('test', ['qunit', 'jshint']);
|
||||
|
||||
grunt.registerTask('ci', ['compile', 'saucelabs-qunit', 'test']);
|
||||
|
||||
grunt.registerTask('docs', ['symlink:docs', 'jekyll:serve']);
|
||||
|
||||
grunt.registerTask('docs-release', ['default', 'clean:docs', 'gh-pages']);
|
||||
|
@ -42,6 +42,7 @@
|
||||
"grunt-cli": "^0.1.13",
|
||||
"grunt-contrib-clean": "^0.6.0",
|
||||
"grunt-contrib-concat": "^0.4.0",
|
||||
"grunt-contrib-connect": "^0.9.0",
|
||||
"grunt-contrib-jshint": "^0.10.0",
|
||||
"grunt-contrib-nodeunit": "~0.3.3",
|
||||
"grunt-contrib-qunit": "~0.4.0",
|
||||
@ -52,6 +53,7 @@
|
||||
"grunt-gh-pages": "^0.9.1",
|
||||
"grunt-jekyll": "^0.4.2",
|
||||
"grunt-sass": "~0.12.0",
|
||||
"grunt-saucelabs": "^8.5.0",
|
||||
"node-sass": "~0.8.6"
|
||||
}
|
||||
}
|
||||
|
2
src/js/select2/compat/initSelection.js
vendored
2
src/js/select2/compat/initSelection.js
vendored
@ -2,7 +2,7 @@ define([
|
||||
'jquery'
|
||||
], function ($) {
|
||||
function InitSelection (decorated, $element, options) {
|
||||
if (console && console.warn) {
|
||||
if (window.console && console.warn) {
|
||||
console.warn(
|
||||
'Select2: The `initSelection` option has been deprecated in favor' +
|
||||
' of a custom data adapter that overrides the `current` method. ' +
|
||||
|
2
src/js/select2/compat/query.js
vendored
2
src/js/select2/compat/query.js
vendored
@ -2,7 +2,7 @@ define([
|
||||
|
||||
], function () {
|
||||
function Query (decorated, $element, options) {
|
||||
if (console && console.warn) {
|
||||
if (window.console && console.warn) {
|
||||
console.warn(
|
||||
'Select2: The `query` option has been deprecated in favor of a ' +
|
||||
'custom data adapter that overrides the `query` method. Support ' +
|
||||
|
6
src/js/select2/core.js
vendored
6
src/js/select2/core.js
vendored
@ -391,7 +391,7 @@ define([
|
||||
};
|
||||
|
||||
Select2.prototype.enable = function (args) {
|
||||
if (console && console.warn) {
|
||||
if (window.console && console.warn) {
|
||||
console.warn(
|
||||
'Select2: The `select2("enable")` method has been deprecated and will' +
|
||||
' be removed in later Select2 versions. Use $element.prop("disabled")' +
|
||||
@ -409,7 +409,7 @@ define([
|
||||
};
|
||||
|
||||
Select2.prototype.data = function () {
|
||||
if (arguments.length > 0 && console && console.warn) {
|
||||
if (arguments.length > 0 && window.console && console.warn) {
|
||||
console.warn(
|
||||
'Select2: Data can no longer be set using `select2("data")`. You ' +
|
||||
'should consider setting the value instead using `$element.val()`.'
|
||||
@ -426,7 +426,7 @@ define([
|
||||
};
|
||||
|
||||
Select2.prototype.val = function (args) {
|
||||
if (console && console.warn) {
|
||||
if (window.console && console.warn) {
|
||||
console.warn(
|
||||
'Select2: The `select2("val")` method has been deprecated and will be' +
|
||||
' removed in later Select2 versions. Use $element.val() instead.'
|
||||
|
2
src/js/select2/data/ajax.js
vendored
2
src/js/select2/data/ajax.js
vendored
@ -64,7 +64,7 @@ define([
|
||||
var $request = options.transport(options, function (data) {
|
||||
var results = self.processResults(data, params);
|
||||
|
||||
if (console && console.error) {
|
||||
if (window.console && console.error) {
|
||||
// Check to make sure that the response included a `results` key.
|
||||
if (!results || !results.results || !$.isArray(results.results)) {
|
||||
console.error(
|
||||
|
2
src/js/select2/defaults.js
vendored
2
src/js/select2/defaults.js
vendored
@ -237,7 +237,7 @@ define([
|
||||
// The translation could not be loaded at all. Sometimes this is
|
||||
// because of a configuration problem, other times this can be
|
||||
// because of how Select2 helps load all possible translation files.
|
||||
if (console && console.warn) {
|
||||
if (window.console && console.warn) {
|
||||
console.warn(
|
||||
'Select2: The lanugage file for "' + name + '" could not be ' +
|
||||
'automatically loaded. A fallback will be used instead.'
|
||||
|
4
src/js/select2/options.js
vendored
4
src/js/select2/options.js
vendored
@ -46,7 +46,7 @@ define([
|
||||
$e.prop('multiple', this.options.multiple);
|
||||
|
||||
if ($e.data('select2-tags')) {
|
||||
if (console && console.warn) {
|
||||
if (window.console && console.warn) {
|
||||
console.warn(
|
||||
'Select2: The `data-select2-tags` attribute has been changed to ' +
|
||||
'use the `data-data` and `data-tags="true"` attributes and will be ' +
|
||||
@ -59,7 +59,7 @@ define([
|
||||
}
|
||||
|
||||
if ($e.data('ajax-url')) {
|
||||
if (console && console.warn) {
|
||||
if (window.console && console.warn) {
|
||||
console.warn(
|
||||
'Select2: The `data-ajax-url` attribute has been changed to ' +
|
||||
'`data-ajax--url` and support for the old attribute will be removed' +
|
||||
|
2
src/js/select2/selection/allowClear.js
vendored
2
src/js/select2/selection/allowClear.js
vendored
@ -9,7 +9,7 @@ define([
|
||||
decorated.call(this, container, $container);
|
||||
|
||||
if (self.placeholder == null) {
|
||||
if (console && console.error) {
|
||||
if (window.console && console.error) {
|
||||
console.error(
|
||||
'Select2: The `allowClear` option should be used in combination ' +
|
||||
'with the `placeholder` option.'
|
||||
|
@ -16,3 +16,31 @@ Utils.Extend(MockContainer, Utils.Observable);
|
||||
MockContainer.prototype.isOpen = function () {
|
||||
return this.isOpen;
|
||||
};
|
||||
|
||||
var log = [];
|
||||
var testName;
|
||||
|
||||
QUnit.done(function (test_results) {
|
||||
var tests = [];
|
||||
for(var i = 0, len = log.length; i < len; i++) {
|
||||
var details = log[i];
|
||||
tests.push({
|
||||
name: details.name,
|
||||
result: details.result,
|
||||
expected: details.expected,
|
||||
actual: details.actual,
|
||||
source: details.source
|
||||
});
|
||||
}
|
||||
test_results.tests = tests;
|
||||
|
||||
window.global_test_results = test_results;
|
||||
});
|
||||
QUnit.testStart(function(testDetails){
|
||||
QUnit.log(function(details){
|
||||
if (!details.result) {
|
||||
details.name = testDetails.name;
|
||||
log.push(details);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user