diff --git a/Gruntfile.js b/Gruntfile.js index 613aee879..1672fd605 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -43,16 +43,31 @@ module.exports = function (grunt) { sauceLoginFile: grunt.file.exists('SAUCE_API_KEY.yml') ? grunt.file.readYAML('SAUCE_API_KEY.yml') : undefined, sauceUser: process.env.SAUCE_USERNAME || 'fuelux', sauceKey: process.env.SAUCE_ACCESS_KEY ? process.env.SAUCE_ACCESS_KEY : '<%= sauceLoginFile.key %>', - allTestUrls: ['2.1.0', '1.11.0', '1.9.1', 'browserGlobals'].map(function (ver) { - if (ver === 'browserGlobals') { - return 'http://localhost:<%= connect.testServer.options.port %>/test/fuelux-browser-globals.html'; + // TEST URLS + distTestUrl: ['http://localhost:<%= connect.testServer.options.port %>/test/?testdist=true'], + allTestUrls: ['2.1.0', '1.11.0', '1.9.1', 'browserGlobals', 'codeCoverage' ].map(function (type) { + if (type === 'browserGlobals') { + return 'http://localhost:<%= connect.testServer.options.port %>/test/browser-globals.html'; + } + else if (type === 'codeCoverage') { + return 'http://localhost:<%= connect.testServer.options.port %>/test/?coverage=true'; + } + else { + // test dist with multiple jQuery versions + return '<% distTestUrl %>'; //'http://localhost:<%= connect.testServer.options.port %>/test/?jquery=' + ver + '&testdist=true'; } - - return 'http://localhost:<%= connect.testServer.options.port %>/test/fuelux.html?jquery=' + ver + '&testdist=true'; }), - testUrl: ['http://localhost:<%= connect.testServer.options.port %>/test/fuelux.html?jquery=' + '1.9.1&testdist=true'], //Tasks configuration + blanket_qunit: { + source: { + options: { + urls: ['http://localhost:<%= connect.testServer.options.port %>/test/?coverage=true&gruntReport'], + threshold: 68, + globalThreshold: 81 + } + } + }, clean: { dist: ['dist'], zipsrc: ['dist/fuelux'],// temp folder @@ -127,13 +142,13 @@ module.exports = function (grunt) { options: { hostname: '*', port: process.env.PORT || 8000, - useAvailablePort: true// increment port number, if unavailable... + useAvailablePort: true // increment port number, if unavailable... } }, testServer: { options: { hostname: '*', - port: 9000,// allows main server to be run simultaneously + port: 9000, // allows main server to be run simultaneously useAvailablePort: true// increment port number, if unavailable... } } @@ -196,7 +211,7 @@ module.exports = function (grunt) { undef: true, unused: false// changed }, - source: ['Gruntfile.js', 'js/*.js', 'dist/fuelux.js'], + sourceAndDist: ['Gruntfile.js', 'js/*.js', 'dist/fuelux.js'], tests: { options: { latedef: false, @@ -210,7 +225,7 @@ module.exports = function (grunt) { }, qunit: { //run with `grunt releasetest` or `grunt travisci`. Requires connect server to be running. - full: { + release: { options: { urls: '<%= allTestUrls %>', screenshot: true, @@ -222,11 +237,20 @@ module.exports = function (grunt) { } } }, - //can be run with `grunt qunit:simple` - simple: ['test/*.html'], + globals: { + options: { + urls: ['http://localhost:<%= connect.testServer.options.port %>/test/browser-globals.html'] + } + }, + // `grunt qunit:source` will test the source files directly. + source: { + options: { + urls: ['http://localhost:<%= connect.testServer.options.port %>/test/?coverage=true'] + } + }, dist: { options: { - urls: ['http://localhost:<%= connect.server.options.port %>/test/fuelux.html?testdist=true'] + urls: ['http://localhost:<%= connect.testServer.options.port %>/test/?coverage=true&testdist=true'] } } }, @@ -345,7 +369,7 @@ module.exports = function (grunt) { browsers: grunt.file.readYAML('sauce_browsers_tricky.yml'), build: process.env.TRAVIS_BUILD_NUMBER || '<%= pkg.version %>', testname: process.env.TRAVIS_JOB_ID || Math.floor((new Date()).getTime() / 1000 - 1230768000).toString(), - urls: '<%= testUrl %>' + urls: '<%= distTestUrl %>' } }, defaultBrowsers: { @@ -358,7 +382,7 @@ module.exports = function (grunt) { browsers: grunt.file.readYAML('sauce_browsers.yml'), build: process.env.TRAVIS_BUILD_NUMBER || '<%= pkg.version %>', testname: process.env.TRAVIS_JOB_ID || '<%= pkg.version %>-<%= grunt.template.today("dddd, mmmm dS, yyyy, h:MM:ss TT") %>', - urls: '<%= testUrl %>', + urls: '<%= distTestUrl %>', maxPollRetries: 4, throttled: 3, maxRetries: 3 @@ -422,19 +446,19 @@ module.exports = function (grunt) { watch: { //watch everything and test everything (test dist) full: { - files: ['Gruntfile.js', 'fonts/**', 'js/**', 'less/**', 'lib/**', 'test/**', 'index.html', 'dev.html'], + files: ['Gruntfile.js', 'fonts/**', 'js/**', 'less/**', 'test/**', 'index.html', 'dev.html'], options: { livereload: isLivereloadEnabled }, - tasks: ['jshint', 'dist', 'qunit:dist', 'validation'] + tasks: ['jshint', 'blanket_qunit:source', 'qunit:globals', 'dist', 'qunit:dist', 'validation'] }, - //watch everything but only perform simple qunit tests (don't test dist) - simple: { - files: ['Gruntfile.js', 'fonts/**', 'js/**', 'less/**', 'lib/**', 'test/**', 'index.html', 'dev.html'], + //watch everything but only perform source qunit tests (don't test dist) + source: { + files: ['Gruntfile.js', 'fonts/**', 'js/**', 'less/**', 'test/**', 'index.html', 'dev.html'], options: { livereload: isLivereloadEnabled }, - tasks: ['jshint', 'qunit:simple', 'validation'] + tasks: ['jshint', 'blanket_qunit:source', 'qunit:globals', 'validation'] }, //only watch and dist less, useful when doing LESS/CSS work less: { @@ -469,7 +493,6 @@ module.exports = function (grunt) { }); - /* ------------- BUILD ------------- */ @@ -487,9 +510,6 @@ module.exports = function (grunt) { grunt.file.delete('less/fuelux-no-namespace.less', options); }); - - - // ZIP distribution task grunt.registerTask('distzip', 'Compress and zip "dist"', ['copy:zipsrc', 'compress', 'clean:zipsrc']); @@ -501,25 +521,33 @@ module.exports = function (grunt) { TESTS ------------- */ // The default build task - grunt.registerTask('default', 'Run simple tests. Pass --no-resetdist to keep dist changes from being wiped out', ['test', 'clean:screenshots', 'resetdist']); + grunt.registerTask('default', 'Run source file tests. Pass --no-resetdist to keep "dist" changes from being wiped out', + ['test', 'clean:screenshots', 'resetdist']); // to be run prior to submitting a PR - grunt.registerTask('test', 'run jshint, qunit:simple, and validate HTML', ['jshint', 'qunit:simple', 'validation']); + grunt.registerTask('test', 'run jshint, qunit source w/ coverage, and validate HTML', + ['jshint', 'connect:testServer', 'qunit:globals', 'blanket_qunit:source', 'validation']); - //If qunit:simple is working but qunit:full is breaking, check to see if the dist broke the code. This would be especially useful if we start mangling our code, but, is 99.99% unlikely right now - grunt.registerTask('validate-dist', 'run qunit:simple, dist, and then qunit:full', ['connect:testServer', 'qunit:simple', 'dist', 'qunit:full']); + //If qunit:source is working but qunit:full is breaking, check to see if the dist broke the code. This would be especially useful if we start mangling our code, but, is 99.99% unlikely right now + grunt.registerTask('validate-dist', 'run qunit:source, dist, and then qunit:full', + ['connect:testServer', 'qunit:source', 'dist', 'qunit:full']); - // multiple jquery versions, then run SauceLabs VMs - grunt.registerTask('releasetest', 'run jshint, dist, qunit:full, validation, and qunit on saucelabs', ['connect:testServer', 'jshint', 'qunit:simple', 'dist', 'qunit:full', 'validation', 'saucelabs-qunit:defaultBrowsers']); + // multiple jQuery versions, then run SauceLabs VMs + grunt.registerTask('releasetest', 'run jshint, build dist, all source tests, validation, and qunit on SauceLabs', + ['connect:testServer', 'jshint', 'blanket_qunit', 'dist', 'qunit:full', 'validation', + 'saucelabs-qunit:defaultBrowsers']); // can be run locally instead of through TravisCI, but requires the Fuel UX Saucelabs API key file which is not public at this time. - grunt.registerTask('saucelabs', 'run jshint, and qunit on saucelabs', ['connect:testServer', 'jshint', 'saucelabs-qunit:defaultBrowsers']); + grunt.registerTask('saucelabs', 'run jshint, and qunit on saucelabs', + ['connect:testServer', 'jshint', 'saucelabs-qunit:defaultBrowsers']); // can be run locally instead of through TravisCI, but requires the FuelUX Saucelabs API key file which is not public at this time. - grunt.registerTask('trickysauce', 'run tests, jshint, and qunit for "tricky browsers" (IE8-11)', ['connect:testServer', 'jshint', 'saucelabs-qunit:trickyBrowsers']); + grunt.registerTask('trickysauce', 'run tests, jshint, and qunit for "tricky browsers" (IE8-11)', + ['connect:testServer', 'jshint', 'saucelabs-qunit:trickyBrowsers']); // Travis CI task. This task no longer uses SauceLabs. Please run 'grunt saucelabs' manually. - grunt.registerTask('travisci', 'Tests to run when in Travis CI environment', ['connect:testServer', 'jshint', 'qunit:simple', 'dist', 'qunit:full']); + grunt.registerTask('travisci', 'Tests to run when in Travis CI environment', + ['connect:testServer', 'jshint', 'qunit:source', 'dist', 'qunit:full']); //if you've already accidentally added your files for commit, this will at least unstage them. If you haven't, this will wipe them out. grunt.registerTask('resetdist', 'resets changes to dist to keep them from being checked in', function () { @@ -546,12 +574,14 @@ module.exports = function (grunt) { if (!grunt.option('no-tests')) { grunt.task.run(['releasetest']); - //delete any screenshots that may have happened if it got this far. This isn't foolproof because it relies on the phantomjs server/page timeout, which can take longer than this grunt task depending on how long saucelabs takes to run... + // Delete any screenshots that may have happened if it got this far. This isn't foolproof + // because it relies on the phantomjs server/page timeout, which can take longer than this + // grunt task depending on how long saucelabs takes to run... grunt.task.run('clean:screenshots'); } grunt.config('banner', '<%= bannerRelease %>'); - //make sure we run dist again to grab the latest version numbers. Yeah, we're running it twice... ¯\_(ツ)_/¯ + // Run dist again to grab the latest version numbers. Yeah, we're running it twice... ¯\_(ツ)_/¯ grunt.task.run(['bump-only:' + grunt.config('bump.increment'), 'replace:readme', 'dist']); }); @@ -559,52 +589,55 @@ module.exports = function (grunt) { /* ------------- SERVE ------------- */ - //most basic serve task, it's the safest, but also the slowest. - grunt.registerTask('serve', 'Serve the files. --no-test to skip tests', function () { - //default --test=true - if (typeof grunt.option('test') === "undefined") { - grunt.option('test', true); - } + // default serve task that runs tests and builds and tests dist by default. + grunt.registerTask('serve', 'Test, build, serve files. (~20s)', function () { + var tasks = ['test', 'servedist']; + grunt.task.run(tasks); + }); - grunt.task.run(['servedist']); + // default serve task that runs tests and builds and tests dist by default (~20s). + grunt.registerTask('serveslow', 'Serve files. Run all tests. Does not build. (~20s)', function () { + var tasks = ['connect:server', 'test', 'watch:source']; + grunt.task.run(tasks); }); - //Fastest serve command for freely slinging code (you won't get interrupted by tests, etc). - grunt.registerTask('servefast', 'Serve the files. pass --test to run tests.', function () { + //Fastest serve command for freely slinging code (no tests will run by default). + grunt.registerTask('servefast', 'Serve the files (no watch), --test to run tests. (~0s)', function () { grunt.task.run(['connect:server']); if (grunt.option('test')) { - grunt.task.run(['qunit:simple', 'watch:simple']); + grunt.task.run(['connect:testServer', 'qunit:source', 'watch:source']); } else { grunt.task.run(['watch:lite']); } }); - //Fastest serve command when you're working on LESS - grunt.registerTask('serveless', 'Compile LESS and serve the files. pass --tests to run test.', function () { + // Fastest serve command when you're working on LESS + grunt.registerTask('serveless', 'Compile LESS and serve the files. pass --tests to run test. (~3s)', function () { grunt.task.run(['distcss']); if (grunt.option('test')) { - //add qunit:simple as a watch task for watch:less since they want tests + // add qunit:source as a watch task for watch:less since they want tests grunt.config.merge({ watch: { less: { - tasks: ['qunit:simple'] + tasks: ['qunit:source'] } } }); - grunt.task.run(['qunit:simple']); + grunt.task.run(['qunit:source']); } grunt.task.run(['connect:server', 'watch:less']); }); - //basically just `grunt serve` but tests default to being off - grunt.registerTask('servedist', 'Compile and serve everything, pass --test to run tests.', function () { + // same as `grunt serve` but tests default to being off + grunt.registerTask('servedist', 'Compile and serve everything, pass --test to run tests. (~7s)', function () { grunt.task.run(['dist']); - //start up the server here so we can run tests if appropriate + //start up the servers here so we can run tests if appropriate grunt.task.run(['connect:server']); + grunt.task.run(['connect:testServer']); if (grunt.option('test')) { grunt.task.run(['qunit:dist', 'watch:full']); diff --git a/test/fuelux-browser-globals.html b/test/browser-globals.html similarity index 93% rename from test/fuelux-browser-globals.html rename to test/browser-globals.html index 064f604e9..8b6b53288 100644 --- a/test/fuelux-browser-globals.html +++ b/test/browser-globals.html @@ -6,7 +6,7 @@ -

Fuel UX Test Suite

+

Fuel UX Global Variable Test Suite

@@ -45,7 +45,7 @@

- + \ No newline at end of file diff --git a/test/fuelux-browser-globals.js b/test/browser-globals.js similarity index 100% rename from test/fuelux-browser-globals.js rename to test/browser-globals.js diff --git a/test/datepicker-moment-test.js b/test/datepicker-moment-test.js index 51a568eeb..a55cb105b 100644 --- a/test/datepicker-moment-test.js +++ b/test/datepicker-moment-test.js @@ -7,9 +7,10 @@ define(function(require){ var html = require('text!test/markup/datepicker-markup.html'); require('bootstrap'); + require('moment'); require('fuelux/datepicker'); - require('test/datepicker-test'); //this ensures the non-moment tests run before the moment tests + // require('test/datepicker-test'); //this ensures the non-moment tests run before the moment tests function uaMatch(ua){ ua = ua.toLowerCase(); @@ -38,14 +39,7 @@ define(function(require){ //IE 8 & 9 have problems with the moment switching. Figure a way around this later, if possible. Otherwise, just //test manually by commenting this if statement out and refreshing over and over again. if(runTestsBoolean){ - module('Fuel UX Datepicker with moment.js', { - setup: function(){ - window.moment = window.tmpMoment; - }, - teardown: function(){ - window.moment = undefined; - } - }); + module('Fuel UX Datepicker with moment.js'); test("should be defined on jquery object", function () { ok($().datepicker, 'datepicker method is defined'); diff --git a/test/datepicker-test.js b/test/datepicker-test.js index d58e2fe3f..a4a8acfa2 100644 --- a/test/datepicker-test.js +++ b/test/datepicker-test.js @@ -11,14 +11,7 @@ define(function(require){ require('bootstrap'); require('fuelux/datepicker'); - module('Fuel UX Datepicker', { - setup: function(){ - if(window.moment){ - window.tmpMoment = window.moment; - window.moment = undefined; - } - } - }); + module('Fuel UX Datepicker'); test("should be defined on jquery object", function () { ok($().datepicker, 'datepicker method is defined'); diff --git a/test/fuelux.html b/test/index.html similarity index 61% rename from test/fuelux.html rename to test/index.html index dda90dfa7..e7e64bda0 100644 --- a/test/fuelux.html +++ b/test/index.html @@ -8,8 +8,6 @@ - - @@ -19,37 +17,43 @@ diff --git a/test/fuelux-test.js b/test/tests-no-moment.js similarity index 67% rename from test/fuelux-test.js rename to test/tests-no-moment.js index 7b68a84e0..19acbd370 100644 --- a/test/fuelux-test.js +++ b/test/tests-no-moment.js @@ -6,7 +6,7 @@ define(function(require){ var $ = require('jquery'); QUnit.start(); // starting qunit, or phantom js will have a problem - + // Needed for saucelab testing var log = []; var testName; @@ -42,23 +42,6 @@ define(function(require){ }; }); - require('test/checkbox-test'); - require('test/combobox-test'); require('test/datepicker-test'); - require('test/datepicker-moment-test'); - require('test/infinite-scroll-test'); - require('test/loader-test'); - require('test/pillbox-test'); - require('test/placard-test'); - require('test/radio-test'); - require('test/repeater-test'); - require('test/repeater-list-test'); - require('test/repeater-thumbnail-test'); - require('test/scheduler-test'); - require('test/search-test'); - require('test/selectlist-test'); - require('test/spinbox-test'); - require('test/tree-test'); - require('test/wizard-test'); }); diff --git a/test/tests.js b/test/tests.js new file mode 100644 index 000000000..c28bf18c4 --- /dev/null +++ b/test/tests.js @@ -0,0 +1,64 @@ +/*global QUnit:false, module:false, test:false, asyncTest:false, expect:false*/ +/*global start:false, stop:false ok:false, equal:false, notEqual:false, deepEqual:false*/ +/*global notDeepEqual:false, strictEqual:false, notStrictEqual:false, raises:false*/ + +define(function(require){ + var $ = require('jquery'); + + QUnit.start(); // starting qunit, or phantom js will have a problem + + // Needed for saucelab testing + 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; + + // hide passed tests, helps with VM testing screencasts + if (!$('#qunit-filter-pass').is(':checked')) { + $('#qunit-filter-pass').click(); + } + + }); + QUnit.testStart(function(testDetails){ + QUnit.log = function(details){ + if (!details.result) { + details.name = testDetails.name; + log.push(details); + } + }; + }); + + require('moment'); + require('../test/checkbox-test'); + require('../test/combobox-test'); + require('../test/datepicker-moment-test'); + require('../test/infinite-scroll-test'); + require('../test/loader-test'); + require('../test/pillbox-test'); + require('../test/placard-test'); + require('../test/radio-test'); + require('../test/repeater-test'); + require('../test/repeater-list-test'); + require('../test/repeater-thumbnail-test'); + require('../test/scheduler-test'); + require('../test/search-test'); + require('../test/selectlist-test'); + require('../test/spinbox-test'); + require('../test/tree-test'); + require('../test/wizard-test'); + +});