1
0
mirror of synced 2024-11-22 04:56:08 +03:00

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:
Kevin Brown 2015-02-13 21:55:04 -05:00
parent d51570e1fe
commit a0c26e1114
11 changed files with 108 additions and 14 deletions

View File

@ -1,8 +1,16 @@
language: node_js language: node_js
node_js: node_js:
- 0.10 - 0.10
env:
global:
- secure: XMNK8GVxkwKa6oLl7nJwgg/wmY1YDk5rrMd+UXz26EDCsMDbiy1P7GhN2fEiBSLaQ7YfEuvaDcmzQxTrT0YTHp1PDzb2o9J4tIDdEkqPcv1y8xMaYDfmsN0rBPdBwZEg9H5zUgi7OdUbrGswSYxsKCE3x8EOqK89104HyOo1LN4=
- secure: BU5BPRx6H4O3WJ509YPixjUxg+hDF3z2BVJX6NiGmKWweqvCEYFfiiHLwDEgp/ynRcF9vGVi1V4Ly1jq7f8NIajbDZ5q443XchZFYFg78K/EwD5mK6LYt16zb7+Jn0KbzwHeGRGzc9AvcEYlW6i634cSCm4n3BnqtF5PpogSzdw=
script: script:
- grunt compile test - grunt ci
notifications: notifications:
email: false email: false
irc: irc:

View File

@ -29,6 +29,21 @@ module.exports = function (grunt) {
cwd: 'src/js' cwd: 'src/js'
}, 'select2/i18n/*.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++) { for (var i = 0; i < i18nFiles.length; i++) {
var file = i18nFiles[i]; var file = i18nFiles[i];
var name = file.split('.')[0]; var name = file.split('.')[0];
@ -45,6 +60,16 @@ module.exports = function (grunt) {
docs: ['docs/_site'] docs: ['docs/_site']
}, },
connect: {
tests: {
options: {
base: '.',
hostname: '127.0.0.1',
port: 9999
}
}
},
uglify: { uglify: {
'dist': { 'dist': {
src: 'dist/js/select2.js', src: 'dist/js/select2.js',
@ -57,9 +82,36 @@ module.exports = function (grunt) {
}, },
qunit: { qunit: {
all: [ all: {
'tests/**/*.html' 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': { 'gh-pages': {
@ -234,6 +286,7 @@ module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-contrib-clean'); grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-concat'); grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-jshint'); grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-qunit'); grunt.loadNpmTasks('grunt-contrib-qunit');
grunt.loadNpmTasks('grunt-contrib-requirejs'); grunt.loadNpmTasks('grunt-contrib-requirejs');
@ -243,6 +296,7 @@ module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-gh-pages'); grunt.loadNpmTasks('grunt-gh-pages');
grunt.loadNpmTasks('grunt-jekyll'); grunt.loadNpmTasks('grunt-jekyll');
grunt.loadNpmTasks('grunt-saucelabs');
grunt.loadNpmTasks('grunt-sass'); grunt.loadNpmTasks('grunt-sass');
grunt.registerTask('default', ['compile', 'test', 'minify']); grunt.registerTask('default', ['compile', 'test', 'minify']);
@ -251,6 +305,8 @@ module.exports = function (grunt) {
grunt.registerTask('minify', ['uglify', 'sass:dist']); grunt.registerTask('minify', ['uglify', 'sass:dist']);
grunt.registerTask('test', ['qunit', 'jshint']); grunt.registerTask('test', ['qunit', 'jshint']);
grunt.registerTask('ci', ['compile', 'saucelabs-qunit', 'test']);
grunt.registerTask('docs', ['symlink:docs', 'jekyll:serve']); grunt.registerTask('docs', ['symlink:docs', 'jekyll:serve']);
grunt.registerTask('docs-release', ['default', 'clean:docs', 'gh-pages']); grunt.registerTask('docs-release', ['default', 'clean:docs', 'gh-pages']);

View File

@ -42,6 +42,7 @@
"grunt-cli": "^0.1.13", "grunt-cli": "^0.1.13",
"grunt-contrib-clean": "^0.6.0", "grunt-contrib-clean": "^0.6.0",
"grunt-contrib-concat": "^0.4.0", "grunt-contrib-concat": "^0.4.0",
"grunt-contrib-connect": "^0.9.0",
"grunt-contrib-jshint": "^0.10.0", "grunt-contrib-jshint": "^0.10.0",
"grunt-contrib-nodeunit": "~0.3.3", "grunt-contrib-nodeunit": "~0.3.3",
"grunt-contrib-qunit": "~0.4.0", "grunt-contrib-qunit": "~0.4.0",
@ -52,6 +53,7 @@
"grunt-gh-pages": "^0.9.1", "grunt-gh-pages": "^0.9.1",
"grunt-jekyll": "^0.4.2", "grunt-jekyll": "^0.4.2",
"grunt-sass": "~0.12.0", "grunt-sass": "~0.12.0",
"grunt-saucelabs": "^8.5.0",
"node-sass": "~0.8.6" "node-sass": "~0.8.6"
} }
} }

View File

@ -2,7 +2,7 @@ define([
'jquery' 'jquery'
], function ($) { ], function ($) {
function InitSelection (decorated, $element, options) { function InitSelection (decorated, $element, options) {
if (console && console.warn) { if (window.console && console.warn) {
console.warn( console.warn(
'Select2: The `initSelection` option has been deprecated in favor' + 'Select2: The `initSelection` option has been deprecated in favor' +
' of a custom data adapter that overrides the `current` method. ' + ' of a custom data adapter that overrides the `current` method. ' +

View File

@ -2,7 +2,7 @@ define([
], function () { ], function () {
function Query (decorated, $element, options) { function Query (decorated, $element, options) {
if (console && console.warn) { if (window.console && console.warn) {
console.warn( console.warn(
'Select2: The `query` option has been deprecated in favor of a ' + 'Select2: The `query` option has been deprecated in favor of a ' +
'custom data adapter that overrides the `query` method. Support ' + 'custom data adapter that overrides the `query` method. Support ' +

View File

@ -391,7 +391,7 @@ define([
}; };
Select2.prototype.enable = function (args) { Select2.prototype.enable = function (args) {
if (console && console.warn) { if (window.console && console.warn) {
console.warn( console.warn(
'Select2: The `select2("enable")` method has been deprecated and will' + 'Select2: The `select2("enable")` method has been deprecated and will' +
' be removed in later Select2 versions. Use $element.prop("disabled")' + ' be removed in later Select2 versions. Use $element.prop("disabled")' +
@ -409,7 +409,7 @@ define([
}; };
Select2.prototype.data = function () { Select2.prototype.data = function () {
if (arguments.length > 0 && console && console.warn) { if (arguments.length > 0 && window.console && console.warn) {
console.warn( console.warn(
'Select2: Data can no longer be set using `select2("data")`. You ' + 'Select2: Data can no longer be set using `select2("data")`. You ' +
'should consider setting the value instead using `$element.val()`.' 'should consider setting the value instead using `$element.val()`.'
@ -426,7 +426,7 @@ define([
}; };
Select2.prototype.val = function (args) { Select2.prototype.val = function (args) {
if (console && console.warn) { if (window.console && console.warn) {
console.warn( console.warn(
'Select2: The `select2("val")` method has been deprecated and will be' + 'Select2: The `select2("val")` method has been deprecated and will be' +
' removed in later Select2 versions. Use $element.val() instead.' ' removed in later Select2 versions. Use $element.val() instead.'

View File

@ -64,7 +64,7 @@ define([
var $request = options.transport(options, function (data) { var $request = options.transport(options, function (data) {
var results = self.processResults(data, params); 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. // Check to make sure that the response included a `results` key.
if (!results || !results.results || !$.isArray(results.results)) { if (!results || !results.results || !$.isArray(results.results)) {
console.error( console.error(

View File

@ -237,7 +237,7 @@ define([
// The translation could not be loaded at all. Sometimes this is // The translation could not be loaded at all. Sometimes this is
// because of a configuration problem, other times this can be // because of a configuration problem, other times this can be
// because of how Select2 helps load all possible translation files. // because of how Select2 helps load all possible translation files.
if (console && console.warn) { if (window.console && console.warn) {
console.warn( console.warn(
'Select2: The lanugage file for "' + name + '" could not be ' + 'Select2: The lanugage file for "' + name + '" could not be ' +
'automatically loaded. A fallback will be used instead.' 'automatically loaded. A fallback will be used instead.'

View File

@ -46,7 +46,7 @@ define([
$e.prop('multiple', this.options.multiple); $e.prop('multiple', this.options.multiple);
if ($e.data('select2-tags')) { if ($e.data('select2-tags')) {
if (console && console.warn) { if (window.console && console.warn) {
console.warn( console.warn(
'Select2: The `data-select2-tags` attribute has been changed to ' + 'Select2: The `data-select2-tags` attribute has been changed to ' +
'use the `data-data` and `data-tags="true"` attributes and will be ' + 'use the `data-data` and `data-tags="true"` attributes and will be ' +
@ -59,7 +59,7 @@ define([
} }
if ($e.data('ajax-url')) { if ($e.data('ajax-url')) {
if (console && console.warn) { if (window.console && console.warn) {
console.warn( console.warn(
'Select2: The `data-ajax-url` attribute has been changed to ' + 'Select2: The `data-ajax-url` attribute has been changed to ' +
'`data-ajax--url` and support for the old attribute will be removed' + '`data-ajax--url` and support for the old attribute will be removed' +

View File

@ -9,7 +9,7 @@ define([
decorated.call(this, container, $container); decorated.call(this, container, $container);
if (self.placeholder == null) { if (self.placeholder == null) {
if (console && console.error) { if (window.console && console.error) {
console.error( console.error(
'Select2: The `allowClear` option should be used in combination ' + 'Select2: The `allowClear` option should be used in combination ' +
'with the `placeholder` option.' 'with the `placeholder` option.'

View File

@ -16,3 +16,31 @@ Utils.Extend(MockContainer, Utils.Observable);
MockContainer.prototype.isOpen = function () { MockContainer.prototype.isOpen = function () {
return this.isOpen; 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);
}
});
});