info@54: /* info@54: * grunt-contrib-qunit info@54: * http://gruntjs.com/ info@54: * info@54: * Copyright (c) 2013 "Cowboy" Ben Alman, contributors info@54: * Licensed under the MIT license. info@54: */ info@54: info@54: /*global QUnit:true, alert:true*/ info@54: (function () { info@54: 'use strict'; info@54: info@54: // Don't re-order tests. info@54: QUnit.config.reorder = false info@54: // Run tests serially, not in parallel. info@54: QUnit.config.autorun = false info@54: info@54: // Send messages to the parent PhantomJS process via alert! Good times!! info@54: function sendMessage() { info@54: var args = [].slice.call(arguments) info@54: alert(JSON.stringify(args)) info@54: } info@54: info@54: // These methods connect QUnit to PhantomJS. info@54: QUnit.log = function(obj) { info@54: // What is this I don’t even info@54: if (obj.message === '[object Object], undefined:undefined') { return } info@54: // Parse some stuff before sending it. info@54: var actual = QUnit.jsDump.parse(obj.actual) info@54: var expected = QUnit.jsDump.parse(obj.expected) info@54: // Send it. info@54: sendMessage('qunit.log', obj.result, actual, expected, obj.message, obj.source) info@54: } info@54: info@54: QUnit.testStart = function(obj) { info@54: sendMessage('qunit.testStart', obj.name) info@54: } info@54: info@54: QUnit.testDone = function(obj) { info@54: sendMessage('qunit.testDone', obj.name, obj.failed, obj.passed, obj.total) info@54: } info@54: info@54: QUnit.moduleStart = function(obj) { info@54: sendMessage('qunit.moduleStart', obj.name) info@54: } info@54: info@54: QUnit.begin = function () { info@54: sendMessage('qunit.begin') info@54: console.log("Starting test suite") info@54: console.log("================================================\n") info@54: } info@54: info@54: QUnit.moduleDone = function (opts) { info@54: if (opts.failed === 0) { info@54: console.log("\r\u2714 All tests passed in '" + opts.name + "' module") info@54: } else { info@54: console.log("\u2716 " + opts.failed + " tests failed in '" + opts.name + "' module") info@54: } info@54: sendMessage('qunit.moduleDone', opts.name, opts.failed, opts.passed, opts.total) info@54: } info@54: info@54: QUnit.done = function (opts) { info@54: console.log("\n================================================") info@54: console.log("Tests completed in " + opts.runtime + " milliseconds") info@54: console.log(opts.passed + " tests of " + opts.total + " passed, " + opts.failed + " failed.") info@54: sendMessage('qunit.done', opts.failed, opts.passed, opts.total, opts.runtime) info@54: } info@54: info@54: }())