FIX qunit test runner for phantomjs 2.0
This commit is contained in:
parent
124fc4daf7
commit
294669c856
|
@ -2,13 +2,17 @@
|
||||||
/*global QUnit, ANSI */
|
/*global QUnit, ANSI */
|
||||||
// THIS FILE IS CALLED BY "qunit_runner.rb" IN AUTOSPEC
|
// 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 + " <URL>");
|
console.log("Usage: " + phantom.scriptName + " <URL>");
|
||||||
phantom.exit(1);
|
phantom.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
var system = require('system'),
|
var fs = require('fs'),
|
||||||
fs = require('fs'),
|
|
||||||
page = require('webpage').create(),
|
page = require('webpage').create(),
|
||||||
QUNIT_RESULT = "./tmp/qunit_result";
|
QUNIT_RESULT = "./tmp/qunit_result";
|
||||||
|
|
||||||
|
@ -34,7 +38,7 @@ page.start = new Date();
|
||||||
// -----------------------------------WARNING --------------------------------------
|
// -----------------------------------WARNING --------------------------------------
|
||||||
// calling "console.log" BELOW this line will go through the "page.onConsoleMessage"
|
// calling "console.log" BELOW this line will go through the "page.onConsoleMessage"
|
||||||
// -----------------------------------WARNING --------------------------------------
|
// -----------------------------------WARNING --------------------------------------
|
||||||
page.open(phantom.args[0], function (status) {
|
page.open(args[0], function (status) {
|
||||||
if (status !== "success") {
|
if (status !== "success") {
|
||||||
console.log("\nNO NETWORK :(\n");
|
console.log("\nNO NETWORK :(\n");
|
||||||
phantom.exit(1);
|
phantom.exit(1);
|
||||||
|
|
|
@ -35,7 +35,7 @@ task "qunit:test" => :environment do
|
||||||
begin
|
begin
|
||||||
success = true
|
success = true
|
||||||
test_path = "#{Rails.root}/vendor/assets/javascripts"
|
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
|
# wait for server to respond, will exception out on failure
|
||||||
tries = 0
|
tries = 0
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { acceptance } from "helpers/qunit-helpers";
|
||||||
|
|
||||||
acceptance("Category Edit", { loggedIn: true });
|
acceptance("Category Edit", { loggedIn: true });
|
||||||
|
|
||||||
test("Can open the category modal", (assert) => {
|
test("Can open the category modal", assert => {
|
||||||
visit("/c/bug");
|
visit("/c/bug");
|
||||||
|
|
||||||
click('.edit-category');
|
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");
|
visit("/c/bug");
|
||||||
|
|
||||||
click('.edit-category');
|
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");
|
visit("/c/bug");
|
||||||
|
|
||||||
click('.edit-category');
|
click('.edit-category');
|
||||||
|
|
|
@ -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");
|
visit("/t/not-found/404");
|
||||||
andThen(() => {
|
andThen(() => {
|
||||||
assert.ok(!exists("#topic"), "The topic was not rendered");
|
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");
|
visit("/t/i-dont-have-access/403");
|
||||||
andThen(() => {
|
andThen(() => {
|
||||||
assert.ok(!exists("#topic"), "The topic was not rendered");
|
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");
|
visit("/t/throws-error/500");
|
||||||
andThen(() => {
|
andThen(() => {
|
||||||
assert.ok(!exists("#topic"), "The topic was not rendered");
|
assert.ok(!exists("#topic"), "The topic was not rendered");
|
||||||
|
|
|
@ -2,18 +2,21 @@
|
||||||
|
|
||||||
/*globals QUnit phantom*/
|
/*globals QUnit phantom*/
|
||||||
|
|
||||||
var args = phantom.args;
|
var system = require("system"),
|
||||||
|
args = system.args;
|
||||||
|
|
||||||
|
args.shift();
|
||||||
|
|
||||||
if (args.length < 1 || args.length > 2) {
|
if (args.length < 1 || args.length > 2) {
|
||||||
console.log("Usage: " + phantom.scriptName + " <URL> <timeout>");
|
console.log("Usage: " + phantom.scriptName + " <URL> <timeout>");
|
||||||
phantom.exit(1);
|
phantom.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
var system = require("system"),
|
var page = require("webpage").create();
|
||||||
page = require('webpage').create();
|
|
||||||
|
|
||||||
page.onConsoleMessage = function(msg) {
|
page.onConsoleMessage = function(msg) {
|
||||||
if (msg.slice(0,8) === 'WARNING:') { return; }
|
if (msg.slice(0, 8) === "WARNING:") { return; }
|
||||||
if (msg.slice(0,6) === 'DEBUG:') { return; }
|
if (msg.slice(0, 6) === "DEBUG:") { return; }
|
||||||
|
|
||||||
console.log(msg);
|
console.log(msg);
|
||||||
};
|
};
|
||||||
|
@ -24,14 +27,15 @@ page.onCallback = function (message) {
|
||||||
};
|
};
|
||||||
|
|
||||||
page.open(args[0], function(status) {
|
page.open(args[0], function(status) {
|
||||||
if (status !== 'success') {
|
if (status !== "success") {
|
||||||
console.error("Unable to access network");
|
console.error("Unable to access network");
|
||||||
phantom.exit(1);
|
phantom.exit(1);
|
||||||
} else {
|
} else {
|
||||||
page.evaluate(logQUnit);
|
page.evaluate(logQUnit);
|
||||||
|
|
||||||
var timeout = parseInt(args[1] || 120000, 10);
|
var timeout = parseInt(args[1] || 120000, 10),
|
||||||
var start = Date.now();
|
start = Date.now();
|
||||||
|
|
||||||
var interval = setInterval(function() {
|
var interval = setInterval(function() {
|
||||||
if (Date.now() > start + timeout) {
|
if (Date.now() > start + timeout) {
|
||||||
console.error("Tests timed out");
|
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(" ");
|
var msg = " Test Failed: " + context.name + assertionErrors.join(" ");
|
||||||
testErrors.push(msg);
|
testErrors.push(msg);
|
||||||
assertionErrors = [];
|
assertionErrors = [];
|
||||||
window.callPhantom('F');
|
window.callPhantom("F");
|
||||||
} else {
|
} else {
|
||||||
window.callPhantom('.');
|
window.callPhantom(".");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -96,7 +100,7 @@ function logQUnit() {
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.done(function(context) {
|
QUnit.done(function(context) {
|
||||||
console.log('\n');
|
console.log("\n");
|
||||||
|
|
||||||
if (moduleErrors.length > 0) {
|
if (moduleErrors.length > 0) {
|
||||||
for (var idx=0; idx<moduleErrors.length; idx++) {
|
for (var idx=0; idx<moduleErrors.length; idx++) {
|
||||||
|
|
Loading…
Reference in New Issue