Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 += "<script type='text/javascript' src='/_patch/" + script + "'></script>\n";
});

// adding framework scripts
if (config['test_framework'] && config['test_framework'] == "jasmine") {
if (framework === "jasmine") {
framework_scripts['jasmine'].forEach(function(script) {
patch += "<script type='text/javascript' src='/_patch/" + script + "'></script>\n";
});
patch += "<script type='text/javascript'>jasmine.getEnv().addReporter(new jasmine.JSReporter());</script>\n";
} else if (config['test_framework'] && config['test_framework'] == "jasmine2") {
} else if (framework === "jasmine2") {
framework_scripts['jasmine2'].forEach(function(script) {
patch += "<script type='text/javascript' src='/_patch/" + script + "'></script>\n";
});
} else if (config['test_framework'] && config['test_framework'] == "mocha") {
} else if (framework === "mocha") {
framework_scripts['mocha'].forEach(function(script) {
patch += "<script type='text/javascript' src='/_patch/" + script + "'></script>\n";
});
Expand All @@ -118,7 +120,7 @@ exports.Server = function Server(bsClient, workers) {
patch += "<script type='text/javascript' src='/_patch/" + script + "'></script>\n";
});
}
patch += "</head>";
patch += "</" + tag_name + ">";

file = file.replace(matcher, patch);
}
Expand Down