From 4314a28524f23b672fb7e74aba74db9f0fa3e017 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=CC=88rn=20Zaefferer?= Date: Mon, 28 Apr 2014 22:02:22 +0200 Subject: [PATCH 1/2] Server: Append injected scripts to body instead of head Any setup that loads QUnit in the body instead of head will timeout out otherwise. --- lib/server.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/server.js b/lib/server.js index 080216c..3225012 100644 --- a/lib/server.js +++ b/lib/server.js @@ -92,7 +92,7 @@ exports.Server = function Server(bsClient, workers) { pathMatches = (filePath == config.test_path); } if (pathMatches && mimeType === 'text/html') { - var matcher = /(.*)<\/head>/; + var matcher = /(.*)<\/body>/; var patch = "$1"; scripts.forEach(function(script) { patch += "\n"; @@ -118,7 +118,7 @@ exports.Server = function Server(bsClient, workers) { patch += "\n"; }); } - patch += ""; + patch += ""; file = file.replace(matcher, patch); } From 62e940f89977976fce2066394f84e32111a293f0 Mon Sep 17 00:00:00 2001 From: Nakul Date: Wed, 21 May 2014 17:10:10 +0530 Subject: [PATCH 2/2] minor modification to support mocha --- lib/server.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/server.js b/lib/server.js index 3225012..c1c780a 100644 --- a/lib/server.js +++ b/lib/server.js @@ -92,23 +92,25 @@ exports.Server = function Server(bsClient, workers) { pathMatches = (filePath == config.test_path); } if (pathMatches && mimeType === 'text/html') { - var matcher = /(.*)<\/body>/; + var framework = config['test_framework']; + var tag_name = (framework === "mocha") ? "head" : "body"; + var matcher = new RegExp("(.*)<\/" + tag_name + ">"); ///(.*)<\/body>/; var patch = "$1"; scripts.forEach(function(script) { patch += "\n"; }); // adding framework scripts - if (config['test_framework'] && config['test_framework'] == "jasmine") { + if (framework === "jasmine") { framework_scripts['jasmine'].forEach(function(script) { patch += "\n"; }); patch += "\n"; - } else if (config['test_framework'] && config['test_framework'] == "jasmine2") { + } else if (framework === "jasmine2") { framework_scripts['jasmine2'].forEach(function(script) { patch += "\n"; }); - } else if (config['test_framework'] && config['test_framework'] == "mocha") { + } else if (framework === "mocha") { framework_scripts['mocha'].forEach(function(script) { patch += "\n"; }); @@ -118,7 +120,7 @@ exports.Server = function Server(bsClient, workers) { patch += "\n"; }); } - patch += ""; + patch += ""; file = file.replace(matcher, patch); }