mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 20:12:45 +08:00
FIX qunit test runner for phantomjs 2.0
This commit is contained in:
parent
124fc4daf7
commit
294669c856
|
@ -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 + " <URL>");
|
||||
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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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");
|
||||
|
|
28
vendor/assets/javascripts/run-qunit.js
vendored
28
vendor/assets/javascripts/run-qunit.js
vendored
|
@ -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 + " <URL> <timeout>");
|
||||
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<moduleErrors.length; idx++) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user