diff --git a/lib/server.js b/lib/server.js
index 080216c..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 = /(.*)<\/head>/;
+ 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 += "" + tag_name + ">";
file = file.replace(matcher, patch);
}