diff --git a/Gruntfile.js b/Gruntfile.js index ffa94ba7..812393da 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,5 +1,5 @@ -_ = require('lodash') module.exports = function(grunt) { + _ = require('lodash'); var version = "0.1.19" @@ -70,7 +70,7 @@ module.exports = function(grunt) { ]; var sauceOnTestComplete = function(result, callback) { - var request = require('request') + var request = require('request'); var user = process.env.SAUCE_USERNAME; var pass = process.env.SAUCE_ACCESS_KEY; @@ -198,7 +198,7 @@ module.exports = function(grunt) { grunt.loadNpmTasks('grunt-zip'); grunt.loadNpmTasks('grunt-contrib-qunit'); grunt.loadNpmTasks('grunt-contrib-connect'); - grunt.loadNpmTasks('grunt-saucelabs') + grunt.loadNpmTasks('grunt-saucelabs'); grunt.registerTask("build", ["test", "uglify", "zip", "md2html", "replace", "copy", "clean"]); grunt.registerTask("test", ["concat", "execute"]); @@ -207,5 +207,5 @@ module.exports = function(grunt) { grunt.registerTask("sauce-qunit", ["connect", "saucelabs-qunit"]); grunt.registerTask("sauce-custom", ["connect", "saucelabs-custom"]); - grunt.registerTask("sauce-all", ["connect", "saucelabs-qunit", "saucelabs-custom"]) + grunt.registerTask("sauce-all", ["connect", "saucelabs-qunit", "saucelabs-custom"]); }; diff --git a/archive/v0.1.19/mithril-tests.js b/archive/v0.1.19/mithril-tests.js index 6367c542..401f832e 100644 --- a/archive/v0.1.19/mithril-tests.js +++ b/archive/v0.1.19/mithril-tests.js @@ -674,9 +674,39 @@ if (typeof define == "function" && define.amd) define(function() {return m}) ;;; function test(condition) { - try {if (!condition()) throw new Error} - catch (e) {console.error(e);test.failures.push(condition)} + var duration = 0; + var start = 0; + var result = true; test.total++ + + if (typeof window != "undefined") { + if (typeof performance != "undefined") { + start = performance.now(); + } + try {if (!condition()) throw new Error} + catch (e) {result = false;console.error(e);test.failures.push(condition)} + if (typeof performance != "undefined") { + duration = performance.now() - start; + } + + + test_obj = { + name: "" + test.total, + result: result, + duration: duration + } + if (!result) { + message: "failed: " + condition, + window.global_test_results.tests.push(test_obj) + } + + window.global_test_results.duration += duration; + if (result) { + window.global_test_results.passed++; + } else { + window.global_test_results.failed++; + } + } } test.total = 0 test.failures = [] @@ -2381,7 +2411,17 @@ function testMithril(mock) { } -//mocks -testMithril(mock.window) +//test reporting for saucelabs +if (typeof window != "undefined") { + window.global_test_results = { + tests: [], + duration: 0, + passed: 0, + failed: 0 + }; +} -test.print(console.log) +//mock +testMithril(mock.window); + +test.print(function(value){console.log(value)}); \ No newline at end of file diff --git a/package.json b/package.json index e37ba73d..b188a2fc 100644 --- a/package.json +++ b/package.json @@ -17,11 +17,21 @@ "grunt-contrib-qunit": "*", "grunt-contrib-connect": "*", "grunt-zip": "*", + + "grunt-contrib-connect": "~0.7.1", + "grunt-contrib-jshint": "~0.10.0", + "grunt-contrib-watch": "~0.6.1", + "grunt-jscs-checker": "^0.4.4", + "grunt-sauce-tunnel": "^0.2.1", + "load-grunt-config": "^0.9.2", + "merge": "^1.1.3", + "publish": "~0.3.2", + "grunt-saucelabs": "*", "request": "~2.35.0", "q": "~1.0.0", "saucelabs": "~0.1.1", "sauce-tunnel": "~2.0.6", "colors": "~0.6.2", "lodash": "~2.4.1" - }, + } } diff --git a/tests/mithril-tests.js b/tests/mithril-tests.js index c92e55ed..7142e5ac 100644 --- a/tests/mithril-tests.js +++ b/tests/mithril-tests.js @@ -1576,12 +1576,14 @@ function testMithril(mock) { } //test reporting for saucelabs -window.global_test_results = { - tests: [], - duration: 0, - passed: 0, - failed: 0 -}; +if (typeof window != "undefined") { + window.global_test_results = { + tests: [], + duration: 0, + passed: 0, + failed: 0 + }; +} //mock testMithril(mock.window); diff --git a/tests/test.js b/tests/test.js index dcffee06..025d8216 100644 --- a/tests/test.js +++ b/tests/test.js @@ -1,33 +1,36 @@ function test(condition) { var duration = 0; var start = 0; - var result = true - if (performance.now) { - start = performance.now(); - } - try {if (!condition()) throw new Error} - catch (e) {result = false;console.error(e);test.failures.push(condition)} - if (performance.now) { - duration = performance.now() - start; - } - + var result = true; test.total++ - test_obj = { - name: "" + test.total, - result: result, - duration: duration - } - if (!result) { - message: "failed: " + condition, - window.global_test_results.tests.push(test_obj) - } + if (typeof window != "undefined") { + if (typeof performance != "undefined") { + start = performance.now(); + } + try {if (!condition()) throw new Error} + catch (e) {result = false;console.error(e);test.failures.push(condition)} + if (typeof performance != "undefined") { + duration = performance.now() - start; + } - window.global_test_results.duration += duration; - if (result) { - window.global_test_results.passed++; - } else { - window.global_test_results.failed++; + + test_obj = { + name: "" + test.total, + result: result, + duration: duration + } + if (!result) { + message: "failed: " + condition, + window.global_test_results.tests.push(test_obj) + } + + window.global_test_results.duration += duration; + if (result) { + window.global_test_results.passed++; + } else { + window.global_test_results.failed++; + } } } test.total = 0