Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix the pkg.testling.html feature

It was failing due to
 * not serving static files
 * exiting getHTML too early
 * wrong number of ready() calls
 * when using custom html - the "__testling_output" div might not exist
  • Loading branch information...
commit dacfc87dbdf06abfcaa6e2637162abf5ddbe242b 1 parent cad810e
Karolis Narkevicius KidkArolis authored committed
Showing with 15 additions and 4 deletions.
  1. +11 −2 bin/cmd.js
  2. +4 −2 browser/prelude.js
13 bin/cmd.js
View
@@ -105,6 +105,10 @@ if ((process.stdin.isTTY || argv._.length) && argv._[0] !== '-') {
}
});
}
+
+ if (pkg.testling.html) {
+ ready();
+ }
}
else {
process.stdin.pipe(concat(function (src) {
@@ -145,6 +149,9 @@ var server = http.createServer(function (req, res) {
req.url = req.url.replace(/^\/__testling/, '');
ecstatic(req, res);
}
+ else {
+ ecstatic(req, res);
+ }
});
server.listen(0, ready);
@@ -231,8 +238,7 @@ function ready () {
}
function getHTML (cb) {
- if (bundle === undefined) return htmlQueue.push(cb);
-
+
if (pkg.testling.html) {
fs.readFile(path.join(dir, pkg.testling.html), function (err, src) {
if (err) console.error('while loading testling.html: ' + err);
@@ -242,6 +248,9 @@ function getHTML (cb) {
});
return;
}
+
+ if (bundle === undefined) return htmlQueue.push(cb);
+
var before = '', after = '';
if (/^mocha(-|$)/.test(pkg.testling.harness)) {
var mochaFile = path.relative(dir,
6 browser/prelude.js
View
@@ -97,8 +97,10 @@ console.log = function (msg) {
if (params.show === undefined || parseBoolean(params.show)) {
var elem = document.getElementById('__testling_output');
- var txt = document.createTextNode(msg + '\n');
- elem.appendChild(txt);
+ if (elem) {
+ var txt = document.createTextNode(msg + '\n');
+ elem.appendChild(txt);
+ }
}
process.stdout.write(msg + '\n');
Please sign in to comment.
Something went wrong with that request. Please try again.