diff --git a/lib/autospec/run-qunit.js b/lib/autospec/run-qunit.js index 59d1524586b..2200aac6236 100644 --- a/lib/autospec/run-qunit.js +++ b/lib/autospec/run-qunit.js @@ -2,13 +2,17 @@ /*global QUnit, ANSI */ // THIS FILE IS CALLED BY "qunit_runner.rb" IN AUTOSPEC -if (phantom.args.length !== 1) { +var system = require('system'), + args = system.args; + +args.shift(); + +if (args.length !== 1) { console.log("Usage: " + phantom.scriptName + " "); phantom.exit(1); } -var system = require('system'), - fs = require('fs'), +var fs = require('fs'), page = require('webpage').create(), QUNIT_RESULT = "./tmp/qunit_result"; @@ -34,7 +38,7 @@ page.start = new Date(); // -----------------------------------WARNING -------------------------------------- // calling "console.log" BELOW this line will go through the "page.onConsoleMessage" // -----------------------------------WARNING -------------------------------------- -page.open(phantom.args[0], function (status) { +page.open(args[0], function (status) { if (status !== "success") { console.log("\nNO NETWORK :(\n"); phantom.exit(1); diff --git a/lib/tasks/qunit.rake b/lib/tasks/qunit.rake index a35b41a8e93..061ae69ffb6 100644 --- a/lib/tasks/qunit.rake +++ b/lib/tasks/qunit.rake @@ -35,7 +35,7 @@ task "qunit:test" => :environment do begin success = true test_path = "#{Rails.root}/vendor/assets/javascripts" - cmd = "phantomjs #{test_path}/run-qunit.js \"http://localhost:#{port}/qunit\"" + cmd = "phantomjs #{test_path}/run-qunit.js http://localhost:#{port}/qunit" # wait for server to respond, will exception out on failure tries = 0 diff --git a/test/javascripts/acceptance/category-edit-test.js.es6 b/test/javascripts/acceptance/category-edit-test.js.es6 index 46d3a2125ed..fc13ab53769 100644 --- a/test/javascripts/acceptance/category-edit-test.js.es6 +++ b/test/javascripts/acceptance/category-edit-test.js.es6 @@ -3,7 +3,7 @@ import { acceptance } from "helpers/qunit-helpers"; acceptance("Category Edit", { loggedIn: true }); -test("Can open the category modal", (assert) => { +test("Can open the category modal", assert => { visit("/c/bug"); click('.edit-category'); @@ -17,7 +17,7 @@ test("Can open the category modal", (assert) => { }); }); -test("Change the category color", (assert) => { +test("Change the category color", assert => { visit("/c/bug"); click('.edit-category'); @@ -29,7 +29,7 @@ test("Change the category color", (assert) => { }); }); -test("Change the topic template", (assert) => { +test("Change the topic template", assert => { visit("/c/bug"); click('.edit-category'); diff --git a/test/javascripts/acceptance/topic-anonymous-test.js.es6 b/test/javascripts/acceptance/topic-anonymous-test.js.es6 index 8e5ddf45c2f..831968a21c3 100644 --- a/test/javascripts/acceptance/topic-anonymous-test.js.es6 +++ b/test/javascripts/acceptance/topic-anonymous-test.js.es6 @@ -16,7 +16,7 @@ test("Enter without an id", () => { }); }); -test("Enter a 404 topic", (assert) => { +test("Enter a 404 topic", assert => { visit("/t/not-found/404"); andThen(() => { assert.ok(!exists("#topic"), "The topic was not rendered"); @@ -24,7 +24,7 @@ test("Enter a 404 topic", (assert) => { }); }); -test("Enter without access", (assert) => { +test("Enter without access", assert => { visit("/t/i-dont-have-access/403"); andThen(() => { assert.ok(!exists("#topic"), "The topic was not rendered"); @@ -32,7 +32,7 @@ test("Enter without access", (assert) => { }); }); -test("Enter with 500 errors", (assert) => { +test("Enter with 500 errors", assert => { visit("/t/throws-error/500"); andThen(() => { assert.ok(!exists("#topic"), "The topic was not rendered"); diff --git a/vendor/assets/javascripts/run-qunit.js b/vendor/assets/javascripts/run-qunit.js index b650fa926cd..2d707294865 100644 --- a/vendor/assets/javascripts/run-qunit.js +++ b/vendor/assets/javascripts/run-qunit.js @@ -2,18 +2,21 @@ /*globals QUnit phantom*/ -var args = phantom.args; +var system = require("system"), + args = system.args; + +args.shift(); + if (args.length < 1 || args.length > 2) { console.log("Usage: " + phantom.scriptName + " "); phantom.exit(1); } -var system = require("system"), - page = require('webpage').create(); +var page = require("webpage").create(); page.onConsoleMessage = function(msg) { - if (msg.slice(0,8) === 'WARNING:') { return; } - if (msg.slice(0,6) === 'DEBUG:') { return; } + if (msg.slice(0, 8) === "WARNING:") { return; } + if (msg.slice(0, 6) === "DEBUG:") { return; } console.log(msg); }; @@ -24,14 +27,15 @@ page.onCallback = function (message) { }; page.open(args[0], function(status) { - if (status !== 'success') { + if (status !== "success") { console.error("Unable to access network"); phantom.exit(1); } else { page.evaluate(logQUnit); - var timeout = parseInt(args[1] || 120000, 10); - var start = Date.now(); + var timeout = parseInt(args[1] || 120000, 10), + start = Date.now(); + var interval = setInterval(function() { if (Date.now() > start + timeout) { console.error("Tests timed out"); @@ -50,7 +54,7 @@ page.open(args[0], function(status) { } } } - }, 500); + }, 250); } }); @@ -74,9 +78,9 @@ function logQUnit() { var msg = " Test Failed: " + context.name + assertionErrors.join(" "); testErrors.push(msg); assertionErrors = []; - window.callPhantom('F'); + window.callPhantom("F"); } else { - window.callPhantom('.'); + window.callPhantom("."); } }); @@ -96,7 +100,7 @@ function logQUnit() { }); QUnit.done(function(context) { - console.log('\n'); + console.log("\n"); if (moduleErrors.length > 0) { for (var idx=0; idx